diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bbd2168 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +language: php + +cache: + directories: + - vendor + +matrix: + # mark as finished before allow_failures are run + fast_finish: true + include: + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + +# test only master (+ pull requests) +branches: + only: + - master + +# make sure to update composer to latest available version +before_install: + - composer self-update + +# install dependencies +install: composer install --prefer-source + +# execute phpunit as the script command +script: + - ./vendor/bin/phpunit -d memory_limit=-1 --colors -c phpunit.xml + +# disable mail notifications +notification: + email: false + +# reduce depth (history) of git checkout +git: + depth: 30 + +# we don't need sudo +sudo: false diff --git a/Tests/Cache/NullTest.php b/Tests/Cache/NullTest.php new file mode 100644 index 0000000..0626e5c --- /dev/null +++ b/Tests/Cache/NullTest.php @@ -0,0 +1,41 @@ +assertInstanceOf(HandlerInterface::class, new Null()); + } + + public function testHasMethodMustAlwaysReturnFalse() + { + $nullHandler = new Null(); + + $this->assertFalse($nullHandler->has('some_key')); + $this->assertFalse($nullHandler->has('test')); + $this->assertFalse($nullHandler->has('weather')); + } + + public function testGetMethodMustAlwaysReturnFalse() + { + $nullHandler = new Null(); + + $this->assertFalse($nullHandler->get('some_key')); + $this->assertFalse($nullHandler->get('test')); + $this->assertFalse($nullHandler->get('weather')); + } + + public function testSetMethodShouldDoNothing() + { + $nullHandler = new Null(); + + $nullHandler->set('some_key', 'data', 120); + $nullHandler->set('test', 'data', 1000); + $nullHandler->set('weather', 'data', 3600); + } +} diff --git a/composer.json b/composer.json index e1f362c..98256b7 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,11 @@ "require": { "ezsystems/ezpublish-kernel": "*" }, + "require-dev": { + "phpunit/phpunit": "*" + }, "autoload": { "psr-0": { "Netgen\\Bundle\\OpenWeatherMapBundle": "" } }, "target-dir": "Netgen/Bundle/OpenWeatherMapBundle" -} \ No newline at end of file +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..6c46e98 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + Tests + + + + + . + + Tests + vendor + NetgenOpenWeatherMapBundle.php + + + +