public function testBagContainer() { $container = new AttributeBagContainer(); $bag = new AttributeBagNamespaced($container, 'test.'); $this->assertSame($bag, $bag->getAttributeBag()); $container->setAttribute('a.b', 'c'); $container->setAttribute('test.d', 'e'); $this->assertEquals('e', $bag->getAttribute('d')); $this->assertNull($bag->getAttribute('unknown')); $this->assertEquals('default', $bag->getAttribute('unknown', 'default')); $bag->setAttribute('d', 'test'); $this->assertEquals('test', $bag->getAttribute('d')); $this->assertEquals('test', $container->getAttribute('test.d')); $bag->setAttributes(array('d' => 'd', 'e' => 'e')); $this->assertEquals(array('a.b' => 'c', 'test.d' => 'd', 'test.e' => 'e'), $container->getAttributes()); }
public function testSome() { $bag = new AttributeBagContainer(); $bag->setAttribute('true', true); $bag->setAttribute('two', 2); $this->assertSame(true, $bag->getAttribute('true')); $this->assertSame(2, $bag->getAttribute('two')); $this->assertEquals(array('true' => true, 'two' => 2), $bag->getAttributes()); $bag->setAttribute('float', '1.2'); $bag->setAttributes(array('two' => 'two', 'three' => 3)); $expected = array('true' => true, 'two' => 'two', 'float' => 1.2, 'three' => 3); $this->assertEquals($expected, $bag->getAttributes()); }