Skip to content

Commit 3185922

Browse files
author
Mario Blazek
committed
Travis and phpunit configuration, first test
1 parent 04d5e7b commit 3185922

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

.travis.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
language: php
2+
3+
cache:
4+
directories:
5+
- vendor
6+
7+
matrix:
8+
# mark as finished before allow_failures are run
9+
fast_finish: true
10+
include:
11+
- php: 5.4
12+
- php: 5.5
13+
- php: 5.6
14+
- php: 7.0
15+
16+
# test only master (+ pull requests)
17+
branches:
18+
only:
19+
- master
20+
21+
# make sure to update composer to latest available version
22+
before_install:
23+
- composer self-update
24+
25+
# install dependencies
26+
install: composer install --prefer-source
27+
28+
# execute phpunit as the script command
29+
script:
30+
- ./vendor/bin/phpunit -d memory_limit=-1 --colors -c phpunit.xml
31+
32+
# disable mail notifications
33+
notification:
34+
email: false
35+
36+
# reduce depth (history) of git checkout
37+
git:
38+
depth: 30
39+
40+
# we don't need sudo
41+
sudo: false

Tests/Cache/NullTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Netgen\Bundle\OpenWeatherMapBundle\Tests\Cache;
4+
5+
use Netgen\Bundle\OpenWeatherMapBundle\Cache\HandlerInterface;
6+
use Netgen\Bundle\OpenWeatherMapBundle\Cache\Null;
7+
8+
class NullTest extends \PHPUnit_Framework_TestCase
9+
{
10+
public function testInstanceOfHandlerInterface()
11+
{
12+
$this->assertInstanceOf(HandlerInterface::class, new Null());
13+
}
14+
15+
public function testHasMethodMustAlwaysReturnFalse()
16+
{
17+
$nullHandler = new Null();
18+
19+
$this->assertFalse($nullHandler->has('some_key'));
20+
$this->assertFalse($nullHandler->has('test'));
21+
$this->assertFalse($nullHandler->has('weather'));
22+
}
23+
24+
public function testGetMethodMustAlwaysReturnFalse()
25+
{
26+
$nullHandler = new Null();
27+
28+
$this->assertFalse($nullHandler->get('some_key'));
29+
$this->assertFalse($nullHandler->get('test'));
30+
$this->assertFalse($nullHandler->get('weather'));
31+
}
32+
33+
public function testSetMethodShouldDoNothing()
34+
{
35+
$nullHandler = new Null();
36+
37+
$nullHandler->set('some_key', 'data', 120);
38+
$nullHandler->set('test', 'data', 1000);
39+
$nullHandler->set('weather', 'data', 3600);
40+
}
41+
}

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
"require": {
1212
"ezsystems/ezpublish-kernel": "*"
1313
},
14+
"require-dev": {
15+
"phpunit/phpunit": "*"
16+
},
1417
"autoload": {
1518
"psr-0": { "Netgen\\Bundle\\OpenWeatherMapBundle": "" }
1619
},
1720
"target-dir": "Netgen/Bundle/OpenWeatherMapBundle"
18-
}
21+
}

phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<phpunit backupGlobals="false"
2+
backupStaticAttributes="false"
3+
convertErrorsToExceptions="true"
4+
convertNoticesToExceptions="true"
5+
convertWarningsToExceptions="true"
6+
colors="true"
7+
>
8+
<testsuites>
9+
<testsuite name="Netgen\OpenWeatherMapBundle\Tests">
10+
<directory>Tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
<filter>
14+
<whitelist>
15+
<directory>.</directory>
16+
<exclude>
17+
<directory>Tests</directory>
18+
<directory>vendor</directory>
19+
<file>NetgenOpenWeatherMapBundle.php</file>
20+
</exclude>
21+
</whitelist>
22+
</filter>
23+
</phpunit>

0 commit comments

Comments
 (0)