ObjectIdentityRetrievalStrategyTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\Tests\Component\Security\Acl\Domain;
  11. use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
  12. use Symfony\Component\Security\Acl\Domain\ObjectIdentityRetrievalStrategy;
  13. class ObjectIdentityRetrievalStrategyTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testGetObjectIdentityReturnsNullForInvalidDomainObject()
  16. {
  17. $strategy = new ObjectIdentityRetrievalStrategy();
  18. $this->assertNull($strategy->getObjectIdentity('foo'));
  19. }
  20. public function testGetObjectIdentity()
  21. {
  22. $strategy = new ObjectIdentityRetrievalStrategy();
  23. $domainObject = new DomainObject();
  24. $objectIdentity = $strategy->getObjectIdentity($domainObject);
  25. $this->assertEquals($domainObject->getId(), $objectIdentity->getIdentifier());
  26. $this->assertEquals(get_class($domainObject), $objectIdentity->getType());
  27. }
  28. }
  29. class DomainObject
  30. {
  31. public function getId()
  32. {
  33. return 'foo';
  34. }
  35. }