adds hasTag() to Definition
This commit is contained in:
parent
b3d55850df
commit
e55f150fb7
@ -296,6 +296,18 @@ class Definition
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this definition has a tag with the given name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function hasTag($name)
|
||||
{
|
||||
return isset($this->tags[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the tags for this definition.
|
||||
*
|
||||
|
@ -164,12 +164,15 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
* @covers Symfony\Component\DependencyInjection\Definition::addTag
|
||||
* @covers Symfony\Component\DependencyInjection\Definition::getTag
|
||||
* @covers Symfony\Component\DependencyInjection\Definition::getTags
|
||||
* @covers Symfony\Component\DependencyInjection\Definition::hasTag
|
||||
*/
|
||||
public function testTags()
|
||||
{
|
||||
$def = new Definition('stdClass');
|
||||
$this->assertEquals(array(), $def->getTag('foo'), '->getTag() returns an empty array if the tag is not defined');
|
||||
$this->assertFalse($def->hasTag('foo'));
|
||||
$this->assertSame($def, $def->addTag('foo'), '->addTag() implements a fluent interface');
|
||||
$this->assertTrue($def->hasTag('foo'));
|
||||
$this->assertEquals(array(array()), $def->getTag('foo'), '->getTag() returns attributes for a tag name');
|
||||
$def->addTag('foo', array('foo' => 'bar'));
|
||||
$this->assertEquals(array(array(), array('foo' => 'bar')), $def->getTag('foo'), '->addTag() can adds the same tag several times');
|
||||
|
Reference in New Issue
Block a user