ObjectIdentityRetrievalStrategyTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Acl\Tests\Domain;
  11. use Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy;
  12. class ObjectIdentityRetrievalStrategyTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetObjectIdentityReturnsNullForInvalidDomainObject()
  15. {
  16. $strategy = new ObjectIdentityRetrievalStrategy();
  17. $this->assertNull($strategy->getObjectIdentity('foo'));
  18. }
  19. public function testGetObjectIdentity()
  20. {
  21. $strategy = new ObjectIdentityRetrievalStrategy();
  22. $domainObject = new DomainObject();
  23. $objectIdentity = $strategy->getObjectIdentity($domainObject);
  24. $this->assertEquals($domainObject->getId(), $objectIdentity->getIdentifier());
  25. $this->assertEquals(get_class($domainObject), $objectIdentity->getType());
  26. }
  27. }
  28. class DomainObject
  29. {
  30. public function getId()
  31. {
  32. return 'foo';
  33. }
  34. }