Skip to content

Commit

Permalink
Merge pull request #4 from moufmouf/humbug
Browse files Browse the repository at this point in the history
Adding humbug mutation tests
  • Loading branch information
moufmouf committed Sep 17, 2017
2 parents 9b95ddd + 5c16c7a commit 6abc750
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,5 @@ composer.lock
composer.phar
/vendor/
/build/
.discovery/
.discovery/
/humbuglog.txt
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -8,7 +8,8 @@ before_script:
- composer install --no-interaction

script:
- phpunit
- vendor/bin/phpunit
- vendor/bin/humbug

after_script:
- php vendor/bin/coveralls -v
5 changes: 3 additions & 2 deletions composer.json
@@ -1,7 +1,7 @@
{
"name": "thecodingmachine/service-provider-registry",
"type": "library",
"description": "This package provides a service provider registry than can lazily instantiate the service providers it contains.",
"description": "This package provides a service provider registry that can lazily instantiate the service providers it contains.",
"license": "MIT",
"autoload": {
"psr-4": {
Expand All @@ -21,7 +21,8 @@
"phpunit/phpunit": "^4.5",
"satooshi/php-coveralls": "^1.0",
"mouf/picotainer": "^1.0",
"thecodingmachine/discovery": "^1.0"
"thecodingmachine/discovery": "^1.0",
"humbug/humbug": "~1.0@dev"
},
"suggest": {
"thecodingmachine/discovery": "Discover service providers automatically."
Expand Down
11 changes: 11 additions & 0 deletions humbug.json.dist
@@ -0,0 +1,11 @@
{
"source": {
"directories": [
"src\/"
]
},
"timeout": 10,
"logs": {
"text": "humbuglog.txt"
}
}
2 changes: 1 addition & 1 deletion tests/Fixtures/TestStatefulServiceProvider.php
Expand Up @@ -8,7 +8,7 @@ class TestStatefulServiceProvider implements ServiceProvider
{
public $foo;

public function __construct($foo)
public function __construct($foo = null)
{
$this->foo = $foo;
}
Expand Down
15 changes: 14 additions & 1 deletion tests/ServiceProviderRegistryTest.php
Expand Up @@ -28,6 +28,16 @@ public function testRegistryInjectInstance()
$this->assertSame($registry[0], $registry[0]);
}

public function testRegistryArrayWithNoParams()
{
$registry = new Registry([
[TestStatefulServiceProvider::class],
]);

$this->assertInstanceOf(TestStatefulServiceProvider::class, $registry[0]);
$this->assertEquals(null, $registry[0]->foo);
}

public function testRegistryArrayWithParams()
{
$registry = new Registry([
Expand Down Expand Up @@ -132,11 +142,14 @@ public function testIterator()
{
$registry = new Registry([
TestServiceProvider::class,
TestServiceProvider::class,
]);

$i = 0;
foreach ($registry as $key => $serviceProvider) {
$this->assertEquals(0, $key);
$this->assertEquals($i, $key);
$this->assertInstanceOf(TestServiceProvider::class, $serviceProvider);
$i++;
}
}
}

0 comments on commit 6abc750

Please sign in to comment.