Changeset 30571 for branches/2.0/tests
- Timestamp:
- 08/06/10 19:45:09 (3 years ago)
- Files:
-
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/ContainerBuilderTest.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/containers/container9.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services1-1.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services1.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services8.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services9.php (modified) (2 diffs)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/xml/services9.xml (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/yaml/services9.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/ContainerBuilderTest.php
r30263 r30571 342 342 343 343 /** 344 * @covers Symfony\Components\DependencyInjection\ContainerBuilder::find AnnotatedServiceIds345 */ 346 public function test FindAnnotatedServiceIds()344 * @covers Symfony\Components\DependencyInjection\ContainerBuilder::findTaggedServiceIds 345 */ 346 public function testfindTaggedServiceIds() 347 347 { 348 348 $builder = new ContainerBuilder(); 349 349 $builder 350 350 ->register('foo', 'FooClass') 351 ->add Annotation('foo', array('foo' => 'foo'))352 ->add Annotation('bar', array('bar' => 'bar'))353 ->add Annotation('foo', array('foofoo' => 'foofoo'))351 ->addTag('foo', array('foo' => 'foo')) 352 ->addTag('bar', array('bar' => 'bar')) 353 ->addTag('foo', array('foofoo' => 'foofoo')) 354 354 ; 355 $this->assertEquals($builder->find AnnotatedServiceIds('foo'), array(355 $this->assertEquals($builder->findTaggedServiceIds('foo'), array( 356 356 'foo' => array( 357 357 array('foo' => 'foo'), 358 358 array('foofoo' => 'foofoo'), 359 359 ) 360 ), '->find AnnotatedServiceIds() returns an array of service ids and its annotationattributes');361 $this->assertEquals(array(), $builder->find AnnotatedServiceIds('foobar'), '->findAnnotatedServiceIds() returns an empty array if there is annotated services');360 ), '->findTaggedServiceIds() returns an array of service ids and its tag attributes'); 361 $this->assertEquals(array(), $builder->findTaggedServiceIds('foobar'), '->findTaggedServiceIds() returns an empty array if there is annotated services'); 362 362 } 363 363 branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/DefinitionTest.php
r30181 r30571 119 119 120 120 /** 121 * @covers Symfony\Components\DependencyInjection\Definition::clear Annotations121 * @covers Symfony\Components\DependencyInjection\Definition::clearTags 122 122 */ 123 public function testClear Annotations()123 public function testClearTags() 124 124 { 125 125 $def = new Definition('stdClass'); 126 $this->assertEquals(spl_object_hash($def), spl_object_hash($def->clear Annotations()), '->clearAnnotations() implements a fluent interface');127 $def->add Annotation('foo', array('foo' => 'bar'));128 $def->clear Annotations();129 $this->assertEquals(array(), $def->get Annotations(), '->clearAnnotations() removes all current annotations');126 $this->assertEquals(spl_object_hash($def), spl_object_hash($def->clearTags()), '->clearTags() implements a fluent interface'); 127 $def->addTag('foo', array('foo' => 'bar')); 128 $def->clearTags(); 129 $this->assertEquals(array(), $def->getTags(), '->clearTags() removes all current tags'); 130 130 } 131 131 132 132 /** 133 * @covers Symfony\Components\DependencyInjection\Definition::add Annotation134 * @covers Symfony\Components\DependencyInjection\Definition::get Annotation135 * @covers Symfony\Components\DependencyInjection\Definition::get Annotations133 * @covers Symfony\Components\DependencyInjection\Definition::addTag 134 * @covers Symfony\Components\DependencyInjection\Definition::getTag 135 * @covers Symfony\Components\DependencyInjection\Definition::getTags 136 136 */ 137 public function test Annotations()137 public function testTags() 138 138 { 139 139 $def = new Definition('stdClass'); 140 $this->assertEquals(array(), $def->get Annotation('foo'), '->getAnnotation() returns an empty array if the annotationis not defined');141 $this->assertEquals(spl_object_hash($def), spl_object_hash($def->add Annotation('foo')), '->addAnnotation() implements a fluent interface');142 $this->assertEquals(array(array()), $def->get Annotation('foo'), '->getAnnotation() returns attributes for an annotationname');143 $def->add Annotation('foo', array('foo' => 'bar'));144 $this->assertEquals(array(array(), array('foo' => 'bar')), $def->get Annotation('foo'), '->addAnnotation() can adds the same annotationseveral times');145 $def->add Annotation('bar', array('bar' => 'bar'));146 $this->assertEquals($def->get Annotations(), array(140 $this->assertEquals(array(), $def->getTag('foo'), '->getTag() returns an empty array if the tag is not defined'); 141 $this->assertEquals(spl_object_hash($def), spl_object_hash($def->addTag('foo')), '->addTag() implements a fluent interface'); 142 $this->assertEquals(array(array()), $def->getTag('foo'), '->getTag() returns attributes for a tag name'); 143 $def->addTag('foo', array('foo' => 'bar')); 144 $this->assertEquals(array(array(), array('foo' => 'bar')), $def->getTag('foo'), '->addTag() can adds the same tag several times'); 145 $def->addTag('bar', array('bar' => 'bar')); 146 $this->assertEquals($def->getTags(), array( 147 147 'foo' => array(array(), array('foo' => 'bar')), 148 148 'bar' => array(array('bar' => 'bar')), 149 ), '->get Annotations() returns all annotations');149 ), '->getTags() returns all tags'); 150 150 } 151 151 } branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/containers/container9.php
r30263 r30571 11 11 $container-> 12 12 register('foo', 'FooClass')-> 13 add Annotation('foo', array('foo' => 'foo'))->14 add Annotation('foo', array('bar' => 'bar'))->13 addTag('foo', array('foo' => 'foo'))-> 14 addTag('foo', array('bar' => 'bar'))-> 15 15 setFactoryMethod('getInstance')-> 16 16 setArguments(array('foo', new Reference('foo.baz'), array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, new Reference('service_container')))-> branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services1-1.php
r30062 r30571 26 26 27 27 /** 28 * Returns service ids for a given annotation.28 * Returns service ids for a given tag. 29 29 * 30 * @param string $name The annotationname30 * @param string $name The tag name 31 31 * 32 * @return array An array of annotations32 * @return array An array of tags 33 33 */ 34 public function find AnnotatedServiceIds($name)34 public function findTaggedServiceIds($name) 35 35 { 36 static $ annotations = array (36 static $tags = array ( 37 37 ); 38 38 39 return isset($ annotations[$name]) ? $annotations[$name] : array();39 return isset($tags[$name]) ? $tags[$name] : array(); 40 40 } 41 41 } branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services1.php
r30062 r30571 26 26 27 27 /** 28 * Returns service ids for a given annotation.28 * Returns service ids for a given tag. 29 29 * 30 * @param string $name The annotationname30 * @param string $name The tag name 31 31 * 32 * @return array An array of annotations32 * @return array An array of tags 33 33 */ 34 public function find AnnotatedServiceIds($name)34 public function findTaggedServiceIds($name) 35 35 { 36 static $ annotations = array (36 static $tags = array ( 37 37 ); 38 38 39 return isset($ annotations[$name]) ? $annotations[$name] : array();39 return isset($tags[$name]) ? $tags[$name] : array(); 40 40 } 41 41 } branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services8.php
r30263 r30571 26 26 27 27 /** 28 * Returns service ids for a given annotation.28 * Returns service ids for a given tag. 29 29 * 30 * @param string $name The annotationname30 * @param string $name The tag name 31 31 * 32 * @return array An array of annotations32 * @return array An array of tags 33 33 */ 34 public function find AnnotatedServiceIds($name)34 public function findTaggedServiceIds($name) 35 35 { 36 static $ annotations = array (36 static $tags = array ( 37 37 ); 38 38 39 return isset($ annotations[$name]) ? $annotations[$name] : array();39 return isset($tags[$name]) ? $tags[$name] : array(); 40 40 } 41 41 branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/php/services9.php
r30181 r30571 154 154 155 155 /** 156 * Returns service ids for a given annotation.156 * Returns service ids for a given tag. 157 157 * 158 * @param string $name The annotationname158 * @param string $name The tag name 159 159 * 160 * @return array An array of annotations160 * @return array An array of tags 161 161 */ 162 public function find AnnotatedServiceIds($name)162 public function findTaggedServiceIds($name) 163 163 { 164 static $ annotations = array (164 static $tags = array ( 165 165 'foo' => 166 166 array ( … … 179 179 ); 180 180 181 return isset($ annotations[$name]) ? $annotations[$name] : array();181 return isset($tags[$name]) ? $tags[$name] : array(); 182 182 } 183 183 branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/xml/services9.xml
r30181 r30571 11 11 <services> 12 12 <service id="foo" class="FooClass" factory-method="getInstance" shared="false"> 13 < annotationname="foo" foo="foo" />14 < annotationname="foo" bar="bar" />13 <tag name="foo" foo="foo" /> 14 <tag name="foo" bar="bar" /> 15 15 <file>%path%foo.php</file> 16 16 <argument>foo</argument> branches/2.0/tests/Symfony/Tests/Components/DependencyInjection/Fixtures/yaml/services9.yml
r30181 r30571 7 7 foo: 8 8 class: FooClass 9 annotations:9 tags: 10 10 - { name: foo, foo: foo } 11 11 - { name: foo, bar: bar }