Set up mutation testing for unit tests

This commit is contained in:
Timothy Warren 2016-08-01 14:38:23 -04:00
parent e62558d607
commit 47e67d5d1a
7 changed files with 71 additions and 5 deletions

1
.gitignore vendored
View File

@ -26,3 +26,4 @@ app/config/*.toml
phinx.yml
.idea/
Caddyfile
build/humbuglog.txt

View File

@ -28,6 +28,7 @@
"phploc/phploc": "^3.0",
"phpmd/phpmd": "^2.4",
"phpunit/phpunit": "^5.4",
"robmorgan/phinx": "^0.6.4"
"robmorgan/phinx": "^0.6.4",
"humbug/humbug": "~1.0@dev"
}
}

12
humbug.json.dist Normal file
View File

@ -0,0 +1,12 @@
{
"source": {
"directories": [
"src"
]
},
"timeout": 10,
"logs": {
"text": "build\/humbuglog.txt",
"json": "build\/humbug.json"
}
}

29
phpunit.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
beStrictAboutTestsThatDoNotTestAnything="true"
>
<filter>
<whitelist>
<directory suffix=".php">src/Aviat/Ion</directory>
<directory suffix=".php">src/Aviat/AnimeClient</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="Ion">
<directory>tests/Ion</directory>
</testsuite>
<testsuite name="AnimeClient">
<directory>tests/AnimeClient</directory>
</testsuite>
</testsuites>
<php>
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0" />
<server name="HTTP_HOST" value="localhost" />
<server name="SERVER_NAME" value="localhost" />
<server name="REQUEST_URI" value="/" />
<server name="REQUEST_METHOD" value="GET" />
</php>
</phpunit>

View File

@ -23,7 +23,8 @@ class ConfigTest extends AnimeClient_TestCase {
public function testConfigSet()
{
$this->config->set('foo', 'foobar');
$ret = $this->config->set('foo', 'foobar');
$this->assertInstanceOf('Aviat\Ion\Config', $ret);
$this->assertEquals('foobar', $this->config->get('foo'));
$this->config->set(['apple', 'sauce', 'is'], 'great');
@ -31,6 +32,7 @@ class ConfigTest extends AnimeClient_TestCase {
$this->assertEquals('great', $apple['sauce']['is'], "Config value not set correctly");
$this->assertEquals('great', $this->config->get(['apple', 'sauce', 'is']), "Array argument get for config failed.");
}
public function testConfigBadSet()

View File

@ -51,6 +51,15 @@ class ContainerTest extends AnimeClient_TestCase {
}
}
public function testGetSet()
{
$container = $this->container->set('foo', function() {});
$this->assertInstanceOf('Aviat\Ion\Di\Container', $container);
$this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $container);
$this->assertTrue(is_callable($container->get('foo')));
}
public function testLoggerMethods()
{
// Does the container have the default logger?
@ -63,8 +72,11 @@ class ContainerTest extends AnimeClient_TestCase {
$logger2->pushHandler(new TestHandler());
// Set the logger channels
$this->container->setLogger($logger1);
$this->container->setLogger($logger2, 'test');
$container = $this->container->setLogger($logger1);
$container2 = $this->container->setLogger($logger2, 'test');
$this->assertInstanceOf('Aviat\Ion\Di\ContainerInterface', $container);
$this->assertInstanceOf('Aviat\Ion\Di\Container', $container2);
$this->assertEquals($logger1, $this->container->getLogger('default'));
$this->assertEquals($logger2, $this->container->getLogger('test'));

View File

@ -79,6 +79,15 @@ class ArrayTypeTest extends AnimeClient_TestCase {
$this->assertEquals($expected, $actual);
}
public function testSet()
{
$obj = $this->arr([]);
$arraytype = $obj->set('foo', 'bar');
$this->assertInstanceOf('Aviat\Ion\Type\ArrayType', $arraytype);
$this->assertEquals('bar', $obj->get('foo'));
}
public function testGet()
{
$array = [1, 2, 3, 4, 5];