AbstractAttributeAwareTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use Fhaculty\Graph\Attribute\AttributeAware;
  3. abstract class AbstractAttributeAwareTest extends TestCase
  4. {
  5. abstract protected function createAttributeAware();
  6. public function testAttributeAwareInterface()
  7. {
  8. $entity = $this->createAttributeAware();
  9. $this->assertInstanceOf('Fhaculty\Graph\Attribute\AttributeAware', $entity);
  10. return $entity;
  11. }
  12. /**
  13. * @depends testAttributeAwareInterface
  14. * @param AttributeAware $entity
  15. */
  16. public function testAttributeSetGetDefault(AttributeAware $entity)
  17. {
  18. $entity->setAttribute('test', 'value');
  19. $this->assertEquals('value', $entity->getAttribute('test'));
  20. $this->assertEquals(null, $entity->getAttribute('unknown'));
  21. $this->assertEquals('default', $entity->getAttribute('unknown', 'default'));
  22. }
  23. /**
  24. * @depends testAttributeAwareInterface
  25. * @param AttributeAware $entity
  26. */
  27. public function testAttributeBag(AttributeAware $entity)
  28. {
  29. $bag = $entity->getAttributeBag();
  30. $this->assertInstanceOf('Fhaculty\Graph\Attribute\AttributeBag', $bag);
  31. }
  32. }