Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Improve Travis matrix #207

Merged
merged 14 commits into from
Apr 21, 2017
22 changes: 14 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
language: php
sudo: false

php:
- 5.6
- 7.0
- 7.1
- hhvm

env:
- COMPOSER_FLAGS=--prefer-lowest
- COMPOSER_FLAGS=

matrix:
include:
- php: 7.1
env: PHPUNIT_FLAGS=--coverage-text
exclude:
- php: 7.1
env: COMPOSER_FLAGS=
fast_finish: true
allow_failures:
- php: 7.0
- php: hhvm

cache:
directories:
- $HOME/.composer/cache

before_install:
- travis_retry composer self-update

before_script:
- travis_retry composer install --no-interaction
- composer update --no-interaction --no-suggest --prefer-dist $COMPOSER_FLAGS

script:
- vendor/bin/phpunit --coverage-text
- vendor/bin/behat
- vendor/bin/phpunit $PHPUNIT_FLAGS
- vendor/bin/behat -vv -f progress
6 changes: 3 additions & 3 deletions tests/Adapter/Phpunit/ConfigurationLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use Humbug\Adapter\Phpunit\ConfigurationLocator;
use Humbug\Adapter\Phpunit\XmlConfiguration;
use Humbug\Exception\RuntimeException;

class ConfigurationLocatorTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -40,12 +39,13 @@ public function testShouldLocateDistConfiguration()
$this->assertEquals($expectedXmlPath, $configurationFile);
}

/**
* @expectedException \Humbug\Exception\RuntimeException
*/
public function testShouldRiseExceptionWhileLocatingConfiguration()
{
$directory = __DIR__;

$this->expectException(RuntimeException::class);

(new ConfigurationLocator())->locate($directory);
}
}
5 changes: 3 additions & 2 deletions tests/Adapter/Phpunit/XmlConfiguration/ObjectVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ public function testShouldAddManyDifferentArguments()
$this->assertEquals('object', $argumentList->item(2)->tagName);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testShouldRiseExceptionWhenArgumentTypeIsNotSupported()
{
$this->expectException(\InvalidArgumentException::class);

$objectVisitor = new ObjectVisitor('This\Is\Test\ClassName', [new \stdClass()]);

$objectVisitor->visitElement($this->visitedObject);
Expand Down
11 changes: 6 additions & 5 deletions tests/Adapter/Phpunit/XmlConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

class XmlConfigurationTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \LogicException
* @expectedExceptionMessage No document element present. Document should not be empty!
*/
public function testShouldThrowExceptionIfNoDocumentElementIsPresent()
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('No document element present. Document should not be empty!');

$dom = new \DOMDocument();
new XmlConfiguration($dom);
}
Expand Down Expand Up @@ -166,7 +167,7 @@ public function testShouldAddListener()

$xmlConfiguration = new XmlConfiguration($dom);

$visitor = $this->createMock(XmlConfiguration\Visitor::class);
$visitor = $this->getMockBuilder(XmlConfiguration\Visitor::class)->getMock();
$visitor->expects($this->once())->method('visitElement')->with($this->isInstanceOf('\DOMElement'));

$xmlConfiguration->addListener($visitor);
Expand All @@ -182,7 +183,7 @@ public function testShouldAddListeners()

$xmlConfiguration = new XmlConfiguration($dom);

$visitor = $this->createMock(XmlConfiguration\Visitor::class);
$visitor = $this->getMockBuilder(XmlConfiguration\Visitor::class)->getMock();
$visitor->expects($this->exactly(2))->method('visitElement')->with($this->isInstanceOf('\DOMElement'));

$xmlConfiguration->addListener($visitor);
Expand Down
20 changes: 12 additions & 8 deletions tests/Config/JsonParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Humbug\Test\Config;

use Humbug\Config\JsonParser;
use Humbug\Exception\JsonConfigException;

class JsonParserTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -40,24 +39,29 @@ public function testParseShouldReturnDistConfigIfNoOther()
$this->assertInstanceOf('stdClass', $config);
}

/**
* @expectedException \Humbug\Exception\JsonConfigException
*/
public function testParsesNonDistFilePreferentially()
{
$this->expectException(JsonConfigException::class);
$config = $this->parser->parseFile(__DIR__ . '/../_files/config4/');
$this->parser->parseFile(__DIR__ . '/../_files/config4/');
}

/**
* @expectedException \Humbug\Exception\JsonConfigException
* @expectedExceptionMessage Please create a humbug.json(.dist) file.
*/
public function testShouldRiseExceptionWhenFileNotExists()
{
$this->expectException(JsonConfigException::class);
$this->expectExceptionMessage('Please create a humbug.json(.dist) file.');
$this->parser->parseFile('it/not/exists/');
}

/**
* @expectedException \Humbug\Exception\JsonConfigException
* @expectedExceptionMessageRegExp |Error parsing configuration file JSON.*|
*/
public function testShouldRiseExceptionWhenFileContainsInvalidJson()
{
$this->expectException(JsonConfigException::class);
$this->expectExceptionMessageRegExp('/Error parsing configuration file JSON.*/');

$this->parser->parseFile(__DIR__ . '/../_files/config2/');
}
}
22 changes: 12 additions & 10 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Humbug\Test;

use Humbug\Config;
use Humbug\Exception\JsonConfigException;

class ConfigTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -56,27 +55,29 @@ public function validSourceDataProvider()
];
}

/**
* @expectedException \Humbug\Exception\JsonConfigException
* @expectedExceptionMessage Source code data is not included in configuration file
*/
public function testShouldRiseExceptionWhenSourceIsNotPresent()
{
$configData = new \stdClass();

$config = new Config($configData);

$this->expectException(JsonConfigException::class);
$this->expectExceptionMessage('Source code data is not included in configuration file');

$config->getSource();
}

/**
* @expectedException \Humbug\Exception\JsonConfigException
* @expectedExceptionMessage You must set at least one source directory or exclude in the configuration file
*/
public function testShouldRiseExceptionWhenSourceDirectoriesAndExcludesAreNotPresent()
{
$configData = (object)[
'source' => (object)[]
];

$this->expectException(JsonConfigException::class);
$this->expectExceptionMessage('You must set at least one source directory or exclude in the configuration file');

$config = new Config($configData);

$config->getSource();
Expand Down Expand Up @@ -123,6 +124,10 @@ public function testShouldHaveEmptyChDir()
$this->assertNull($config->getChDir());
}

/**
* @expectedException \Humbug\Exception\JsonConfigException
* @expectedExceptionMessageRegExp /Directory in which to run tests does not exist: .+/
*/
public function testShouldRiseExceptionWhenChDirNotExists()
{
$configData = (object)[
Expand All @@ -131,9 +136,6 @@ public function testShouldRiseExceptionWhenChDirNotExists()

$config = new Config($configData);

$this->expectException(JsonConfigException::class);
$this->expectExceptionMessageRegExp('/Directory in which to run tests does not exist: .+/');

$config->getChDir();
}

Expand Down
9 changes: 7 additions & 2 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ public function testGetShouldReturnInputOption()
$this->assertSame('test-option', $container->get('test'));
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetShouldRiseExceptionForUnknownOption()
{
$input = [
'options' => null
];
$this->expectException(\InvalidArgumentException::class);

$container = new Container($input);
$container->get('invalid-option');
}
Expand Down Expand Up @@ -87,9 +90,11 @@ public function testsetTempDirectory()
$this->assertSame($this->container, $result);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testsetTempDirectoryThrowsExceptionOnUnwriteableParam()
{
$this->expectException(InvalidArgumentException::class);
$result = $this->container->setTempDirectory('/really/does/not/exist');
}

Expand Down