Skip to content

Commit

Permalink
Travis and phpunit configuration, first test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Blazek committed Jun 3, 2016
1 parent 04d5e7b commit 3185922
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions Tests/Cache/NullTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Netgen\Bundle\OpenWeatherMapBundle\Tests\Cache;

use Netgen\Bundle\OpenWeatherMapBundle\Cache\HandlerInterface;
use Netgen\Bundle\OpenWeatherMapBundle\Cache\Null;

class NullTest extends \PHPUnit_Framework_TestCase
{
public function testInstanceOfHandlerInterface()
{
$this->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);
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"require": {
"ezsystems/ezpublish-kernel": "*"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-0": { "Netgen\\Bundle\\OpenWeatherMapBundle": "" }
},
"target-dir": "Netgen/Bundle/OpenWeatherMapBundle"
}
}
23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
colors="true"
>
<testsuites>
<testsuite name="Netgen\OpenWeatherMapBundle\Tests">
<directory>Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>Tests</directory>
<directory>vendor</directory>
<file>NetgenOpenWeatherMapBundle.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 3185922

Please sign in to comment.