X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FDefinitionTest.php;h=5fe4236ad938428bfec15bebad94bcb3c63a8b08;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=1e385da5477ab9a8a30601127a00fc5828fc9035;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/vendor/symfony/dependency-injection/Tests/DefinitionTest.php b/vendor/symfony/dependency-injection/Tests/DefinitionTest.php index 1e385da54..5fe4236ad 100644 --- a/vendor/symfony/dependency-injection/Tests/DefinitionTest.php +++ b/vendor/symfony/dependency-injection/Tests/DefinitionTest.php @@ -20,6 +20,7 @@ class DefinitionTest extends TestCase { $def = new Definition('stdClass'); $this->assertEquals('stdClass', $def->getClass(), '__construct() takes the class name as its first argument'); + $this->assertSame(array('class' => true), $def->getChanges()); $def = new Definition('stdClass', array('foo')); $this->assertEquals(array('foo'), $def->getArguments(), '__construct() takes an optional array of arguments as its second argument'); @@ -27,13 +28,14 @@ class DefinitionTest extends TestCase public function testSetGetFactory() { - $def = new Definition('stdClass'); + $def = new Definition(); $this->assertSame($def, $def->setFactory('foo'), '->setFactory() implements a fluent interface'); $this->assertEquals('foo', $def->getFactory(), '->getFactory() returns the factory'); $def->setFactory('Foo::bar'); $this->assertEquals(array('Foo', 'bar'), $def->getFactory(), '->setFactory() converts string static method call to the array'); + $this->assertSame(array('factory' => true), $def->getChanges()); } public function testSetGetClass() @@ -307,10 +309,64 @@ class DefinitionTest extends TestCase { $def = new Definition('stdClass'); $this->assertFalse($def->isAutowired()); + $def->setAutowired(true); $this->assertTrue($def->isAutowired()); + + $def->setAutowired(false); + $this->assertFalse($def->isAutowired()); + } + + public function testChangesNoChanges() + { + $def = new Definition(); + + $this->assertSame(array(), $def->getChanges()); + } + + public function testGetChangesWithChanges() + { + $def = new Definition('stdClass', array('fooarg')); + + $def->setAbstract(true); + $def->setAutowired(true); + $def->setConfigurator('configuration_func'); + $def->setDecoratedService(null); + $def->setDeprecated(true); + $def->setFactory('factory_func'); + $def->setFile('foo.php'); + $def->setLazy(true); + $def->setPublic(true); + $def->setShared(true); + $def->setSynthetic(true); + // changes aren't tracked for these, class or arguments + $def->setInstanceofConditionals(array()); + $def->addTag('foo_tag'); + $def->addMethodCall('methodCall'); + $def->setProperty('fooprop', true); + $def->setAutoconfigured(true); + + $this->assertSame(array( + 'class' => true, + 'autowired' => true, + 'configurator' => true, + 'decorated_service' => true, + 'deprecated' => true, + 'factory' => true, + 'file' => true, + 'lazy' => true, + 'public' => true, + 'shared' => true, + 'autoconfigured' => true, + ), $def->getChanges()); + + $def->setChanges(array()); + $this->assertSame(array(), $def->getChanges()); } + /** + * @group legacy + */ public function testTypes() { $def = new Definition('stdClass'); @@ -323,4 +379,21 @@ class DefinitionTest extends TestCase $this->assertSame($def, $def->removeAutowiringType('Foo')); $this->assertEquals(array('Bar'), $def->getAutowiringTypes()); } + + public function testShouldAutoconfigure() + { + $def = new Definition('stdClass'); + $this->assertFalse($def->isAutoconfigured()); + $def->setAutoconfigured(true); + $this->assertTrue($def->isAutoconfigured()); + } + + public function testAddError() + { + $def = new Definition('stdClass'); + $this->assertEmpty($def->getErrors()); + $def->addError('First error'); + $def->addError('Second error'); + $this->assertSame(array('First error', 'Second error'), $def->getErrors()); + } }