ObjectIdentityRetrievalStrategyTest.php 979 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Symfony\Tests\Component\Security\Acl\Domain;
  3. use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
  4. use Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy;
  5. class ObjectIdentityRetrievalStrategyTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testGetObjectIdentityReturnsNullForInvalidDomainObject()
  8. {
  9. $strategy = new ObjectIdentityRetrievalStrategy();
  10. $this->assertNull($strategy->getObjectIdentity('foo'));
  11. }
  12. public function testGetObjectIdentity()
  13. {
  14. $strategy = new ObjectIdentityRetrievalStrategy();
  15. $domainObject = new DomainObject();
  16. $objectIdentity = $strategy->getObjectIdentity($domainObject);
  17. $this->assertEquals($domainObject->getId(), $objectIdentity->getIdentifier());
  18. $this->assertEquals(get_class($domainObject), $objectIdentity->getType());
  19. }
  20. }
  21. class DomainObject
  22. {
  23. public function getId()
  24. {
  25. return 'foo';
  26. }
  27. }