AttributeBagContainerTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Fhaculty\Graph\Attribute\AttributeBagContainer;
  3. class AttributeBagContainerTest extends TestCase
  4. {
  5. public function testEmpty()
  6. {
  7. $bag = new AttributeBagContainer();
  8. $this->assertNull($bag->getAttribute('unknown'));
  9. $this->assertEquals('default', $bag->getAttribute('unknown', 'default'));
  10. $this->assertEquals(array(), $bag->getAttributes());
  11. $this->assertSame($bag, $bag->getAttributeBag());
  12. }
  13. public function testSome()
  14. {
  15. $bag = new AttributeBagContainer();
  16. $bag->setAttribute('true', true);
  17. $bag->setAttribute('two', 2);
  18. $this->assertSame(true, $bag->getAttribute('true'));
  19. $this->assertSame(2, $bag->getAttribute('two'));
  20. $this->assertEquals(array('true' => true, 'two' => 2), $bag->getAttributes());
  21. $bag->setAttribute('float', '1.2');
  22. $bag->setAttributes(array('two' => 'two', 'three' => 3));
  23. $expected = array('true' => true, 'two' => 'two', 'float' => 1.2, 'three' => 3);
  24. $this->assertEquals($expected, $bag->getAttributes());
  25. }
  26. }