From: Timo Tijhof Date: Sat, 1 Apr 2017 01:07:59 +0000 (-0700) Subject: ObjectFactory: Complete code coverage for ObjectFactoryTest X-Git-Tag: 1.31.0-rc.0~3637^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=8bada02a0f142b76c615ab2e73e763a2679a8da6;p=lhc%2Fweb%2Fwiklou.git ObjectFactory: Complete code coverage for ObjectFactoryTest Cover missing case of expandClosures() where the array contains both a closure and a non-closure. Change-Id: I30ea8cf3fb909a499a95bf9bd24792f4dd6b5c64 --- diff --git a/tests/phpunit/includes/libs/ObjectFactoryTest.php b/tests/phpunit/includes/libs/ObjectFactoryTest.php index f8dda6f8af..3e0a61ee7c 100644 --- a/tests/phpunit/includes/libs/ObjectFactoryTest.php +++ b/tests/phpunit/includes/libs/ObjectFactoryTest.php @@ -26,20 +26,24 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { public function testClosureExpansionDisabled() { $obj = ObjectFactory::getObjectFromSpec( [ 'class' => 'ObjectFactoryTestFixture', - 'args' => [ function() { - return 'unwrapped'; - }, ], + 'args' => [ + function() { + return 'wrapped'; + }, + 'unwrapped', + ], 'calls' => [ 'setter' => [ function() { - return 'unwrapped'; + return 'wrapped'; }, ], ], 'closure_expansion' => false, ] ); $this->assertInstanceOf( 'Closure', $obj->args[0] ); - $this->assertSame( 'unwrapped', $obj->args[0]() ); + $this->assertSame( 'wrapped', $obj->args[0]() ); + $this->assertSame( 'unwrapped', $obj->args[1] ); $this->assertInstanceOf( 'Closure', $obj->setterArgs[0] ); - $this->assertSame( 'unwrapped', $obj->setterArgs[0]() ); + $this->assertSame( 'wrapped', $obj->setterArgs[0]() ); } /** @@ -49,20 +53,24 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { public function testClosureExpansionEnabled() { $obj = ObjectFactory::getObjectFromSpec( [ 'class' => 'ObjectFactoryTestFixture', - 'args' => [ function() { - return 'unwrapped'; - }, ], + 'args' => [ + function() { + return 'wrapped'; + }, + 'unwrapped', + ], 'calls' => [ 'setter' => [ function() { - return 'unwrapped'; + return 'wrapped'; }, ], ], 'closure_expansion' => true, ] ); $this->assertInternalType( 'string', $obj->args[0] ); - $this->assertSame( 'unwrapped', $obj->args[0] ); + $this->assertSame( 'wrapped', $obj->args[0] ); + $this->assertSame( 'unwrapped', $obj->args[1] ); $this->assertInternalType( 'string', $obj->setterArgs[0] ); - $this->assertSame( 'unwrapped', $obj->setterArgs[0] ); + $this->assertSame( 'wrapped', $obj->setterArgs[0] ); $obj = ObjectFactory::getObjectFromSpec( [ 'class' => 'ObjectFactoryTestFixture',