FieldEntryTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\FieldEntry;
  12. class FieldEntryTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testConstructor()
  15. {
  16. $ace = $this->getAce();
  17. $this->assertEquals('foo', $ace->getField());
  18. }
  19. public function testSerializeUnserialize()
  20. {
  21. $ace = $this->getAce();
  22. $serialized = serialize($ace);
  23. $uAce = unserialize($serialized);
  24. $this->assertNull($uAce->getAcl());
  25. $this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity());
  26. $this->assertEquals($ace->getId(), $uAce->getId());
  27. $this->assertEquals($ace->getField(), $uAce->getField());
  28. $this->assertEquals($ace->getMask(), $uAce->getMask());
  29. $this->assertEquals($ace->getStrategy(), $uAce->getStrategy());
  30. $this->assertEquals($ace->isGranting(), $uAce->isGranting());
  31. $this->assertEquals($ace->isAuditSuccess(), $uAce->isAuditSuccess());
  32. $this->assertEquals($ace->isAuditFailure(), $uAce->isAuditFailure());
  33. }
  34. protected function getAce($acl = null, $sid = null)
  35. {
  36. if (null === $acl) {
  37. $acl = $this->getAcl();
  38. }
  39. if (null === $sid) {
  40. $sid = $this->getSid();
  41. }
  42. return new FieldEntry(
  43. 123,
  44. $acl,
  45. 'foo',
  46. $sid,
  47. 'foostrat',
  48. 123456,
  49. true,
  50. false,
  51. true
  52. );
  53. }
  54. protected function getAcl()
  55. {
  56. return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface');
  57. }
  58. protected function getSid()
  59. {
  60. return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
  61. }
  62. }