public function testAddParameters() { $sc = new Container(array('foo' => 'bar')); $sc->addParameters(array('bar' => 'foo')); $this->assertEquals(array('foo' => 'bar', 'bar' => 'foo'), $sc->getParameters(), '->addParameters() adds parameters to the existing ones'); $sc->addParameters(array('Bar' => 'fooz')); $this->assertEquals(array('foo' => 'bar', 'bar' => 'fooz'), $sc->getParameters(), '->addParameters() converts keys to lowercase'); }
$t->pass('->offsetGet() thrown an \\InvalidArgumentException if the key does not exist'); } // ->hasParameter() $t->diag('->hasParameter()'); $sc = new Container(array('foo' => 'bar')); $t->ok($sc->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined'); $t->ok($sc->hasParameter('Foo'), '->hasParameter() converts the key to lowercase'); $t->ok(isset($sc['Foo']), '->offsetExists() converts the key to lowercase'); $t->ok(!$sc->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined'); $t->ok(isset($sc['foo']), '->offsetExists() returns true if a parameter is defined'); $t->ok(!isset($sc['bar']), '->offsetExists() returns false if a parameter is not defined'); // ->addParameters() $t->diag('->addParameters()'); $sc = new Container(array('foo' => 'bar')); $sc->addParameters(array('bar' => 'foo')); $t->is($sc->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones'); $sc->addParameters(array('Bar' => 'fooz')); $t->is($sc->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase'); // ->setService() ->hasService() ->getService() $t->diag('->setService() ->hasService() ->getService()'); $sc = new Container(); $sc->setService('foo', $obj = new stdClass()); $t->is(spl_object_hash($sc->getService('foo')), spl_object_hash($obj), '->setService() registers a service under a key name'); $sc->foo1 = $obj1 = new stdClass(); $t->is(spl_object_hash($sc->foo1), spl_object_hash($obj1), '->__set() sets a service'); $t->is(spl_object_hash($sc->foo), spl_object_hash($obj), '->__get() gets a service by name'); $t->ok($sc->hasService('foo'), '->hasService() returns true if the service is defined'); $t->ok(isset($sc->foo), '->__isset() returns true if the service is defined'); $t->ok(!$sc->hasService('bar'), '->hasService() returns false if the service is not defined'); $t->ok(!isset($sc->bar), '->__isset() returns false if the service is not defined'); // ->getServiceIds()