Skip to content

Commit

Permalink
[DependencyInjection] replaced assertEquals(spl_object_hash()) with a…
Browse files Browse the repository at this point in the history
…ssertSame
  • Loading branch information
avalanche123 authored and fabpot committed Nov 21, 2010
1 parent bfba386 commit 21f088d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Expand Up @@ -22,7 +22,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
public function testConstructor()
{
$sc = new Container();
$this->assertEquals(spl_object_hash($sc), spl_object_hash($sc->get('service_container')), '__construct() automatically registers itself as a service');
$this->assertSame($sc, $sc->get('service_container'), '__construct() automatically registers itself as a service');

$sc = new Container(new ParameterBag(array('foo' => 'bar')));
$this->assertEquals(array('foo' => 'bar'), $sc->getParameterBag()->all(), '__construct() takes an array of parameters as its first argument');
Expand Down Expand Up @@ -140,7 +140,7 @@ public function testGet()
$this->assertEquals($sc->__foo_baz, $sc->get('foo.baz'), '->get() returns the service if a get*Method() is defined');

$sc->set('bar', $bar = new \stdClass());
$this->assertEquals(spl_object_hash($sc->get('bar')), spl_object_hash($bar), '->getServiceIds() prefers to return a service defined with a getXXXService() method than one defined with set()');
$this->assertSame($sc->get('bar'), $bar, '->getServiceIds() prefers to return a service defined with a getXXXService() method than one defined with set()');

try {
$sc->get(new \stdClass());
Expand Down
Expand Up @@ -33,7 +33,7 @@ public function testConstructor()
public function testSetGetConstructor()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setFactoryMethod('foo')), '->setFactoryMethod() implements a fluent interface');
$this->assertSame($def, $def->setFactoryMethod('foo'), '->setFactoryMethod() implements a fluent interface');
$this->assertEquals('foo', $def->getFactoryMethod(), '->getFactoryMethod() returns the factory method name');
}

Expand All @@ -52,7 +52,7 @@ public function testSetGetFactoryService()
public function testSetGetClass()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setClass('foo')), '->setClass() implements a fluent interface');
$this->assertSame($def, $def->setClass('foo'), '->setClass() implements a fluent interface');
$this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name');
}

Expand All @@ -64,9 +64,9 @@ public function testSetGetClass()
public function testArguments()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setArguments(array('foo'))), '->setArguments() implements a fluent interface');
$this->assertSame($def, $def->setArguments(array('foo')), '->setArguments() implements a fluent interface');
$this->assertEquals(array('foo'), $def->getArguments(), '->getArguments() returns the arguments');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->addArgument('bar')), '->addArgument() implements a fluent interface');
$this->assertSame($def, $def->addArgument('bar'), '->addArgument() implements a fluent interface');
$this->assertEquals(array('foo', 'bar'), $def->getArguments(), '->addArgument() adds an argument');
}

Expand All @@ -79,13 +79,13 @@ public function testArguments()
public function testMethodCalls()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setMethodCalls(array(array('foo', array('foo'))))), '->setMethodCalls() implements a fluent interface');
$this->assertSame($def, $def->setMethodCalls(array(array('foo', array('foo')))), '->setMethodCalls() implements a fluent interface');
$this->assertEquals(array(array('foo', array('foo'))), $def->getMethodCalls(), '->getMethodCalls() returns the methods to call');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->addMethodCall('bar', array('bar'))), '->addMethodCall() implements a fluent interface');
$this->assertSame($def, $def->addMethodCall('bar', array('bar')), '->addMethodCall() implements a fluent interface');
$this->assertEquals(array(array('foo', array('foo')), array('bar', array('bar'))), $def->getMethodCalls(), '->addMethodCall() adds a method to call');
$this->assertTrue($def->hasMethodCall('bar'), '->hasMethodCall() returns true if first argument is a method to call registered');
$this->assertFalse($def->hasMethodCall('no_registered'), '->hasMethodCall() returns false if first argument is not a method to call registered');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->removeMethodCall('bar')), '->removeMethodCall() implements a fluent interface');
$this->assertSame($def, $def->removeMethodCall('bar'), '->removeMethodCall() implements a fluent interface');
$this->assertEquals(array(array('foo', array('foo'))), $def->getMethodCalls(), '->removeMethodCall() removes a method to call');
}

Expand All @@ -96,7 +96,7 @@ public function testMethodCalls()
public function testSetGetFile()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setFile('foo')), '->setFile() implements a fluent interface');
$this->assertSame($def, $def->setFile('foo'), '->setFile() implements a fluent interface');
$this->assertEquals('foo', $def->getFile(), '->getFile() returns the file to include');
}

Expand All @@ -108,7 +108,7 @@ public function testSetIsShared()
{
$def = new Definition('stdClass');
$this->assertTrue($def->isShared(), '->isShared() returns true by default');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setShared(false)), '->setShared() implements a fluent interface');
$this->assertSame($def, $def->setShared(false), '->setShared() implements a fluent interface');
$this->assertFalse($def->isShared(), '->isShared() returns false if the instance must not be shared');
}

Expand All @@ -119,7 +119,7 @@ public function testSetIsShared()
public function testSetGetConfigurator()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->setConfigurator('foo')), '->setConfigurator() implements a fluent interface');
$this->assertSame($def, $def->setConfigurator('foo'), '->setConfigurator() implements a fluent interface');
$this->assertEquals('foo', $def->getConfigurator(), '->getConfigurator() returns the configurator');
}

Expand All @@ -129,7 +129,7 @@ public function testSetGetConfigurator()
public function testClearTags()
{
$def = new Definition('stdClass');
$this->assertEquals(spl_object_hash($def), spl_object_hash($def->clearTags()), '->clearTags() implements a fluent interface');
$this->assertSame($def, $def->clearTags(), '->clearTags() implements a fluent interface');
$def->addTag('foo', array('foo' => 'bar'));
$def->clearTags();
$this->assertEquals(array(), $def->getTags(), '->clearTags() removes all current tags');
Expand All @@ -144,7 +144,7 @@ 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->assertEquals(spl_object_hash($def), spl_object_hash($def->addTag('foo')), '->addTag() implements a fluent interface');
$this->assertSame($def, $def->addTag('foo'), '->addTag() implements a fluent interface');
$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');
Expand Down

0 comments on commit 21f088d

Please sign in to comment.