MaskBuilderTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Tests\Admin\Security\Acl\Permission;
  11. use Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder;
  12. class MaskBuilderTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetPattern()
  15. {
  16. $builder = new MaskBuilder();
  17. $this->assertEquals(MaskBuilder::ALL_OFF, $builder->getPattern());
  18. $builder->add('view');
  19. $this->assertEquals(str_repeat('.', 31).'V', $builder->getPattern());
  20. $builder->add('owner');
  21. $this->assertEquals(str_repeat('.', 24).'N......V', $builder->getPattern());
  22. $builder->add('list');
  23. $this->assertEquals(str_repeat('.', 19).'L....N......V', $builder->getPattern());
  24. $builder->add('export');
  25. $this->assertEquals(str_repeat('.', 18).'EL....N......V', $builder->getPattern());
  26. $builder->add(1 << 10);
  27. $this->assertEquals(str_repeat('.', 18).'EL.'.MaskBuilder::ON.'..N......V', $builder->getPattern());
  28. }
  29. }