Completed
Push — 3.x ( f37b5a...b37d45 )
by Christian
26:43
created

MaskBuilderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetPattern() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\AdminBundle\Tests\Security\Acl\Permission;
15
16
use PHPUnit\Framework\TestCase;
17
use Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder;
18
19
class MaskBuilderTest extends TestCase
20
{
21
    public function testGetPattern(): void
22
    {
23
        $builder = new MaskBuilder();
24
        $this->assertSame(MaskBuilder::ALL_OFF, $builder->getPattern());
25
26
        $builder->add('view');
27
        $this->assertSame(str_repeat('.', 31).'V', $builder->getPattern());
28
29
        $builder->add('owner');
30
        $this->assertSame(str_repeat('.', 24).'N......V', $builder->getPattern());
31
32
        $builder->add('list');
33
        $this->assertSame(str_repeat('.', 19).'L....N......V', $builder->getPattern());
34
35
        $builder->add('export');
36
        $this->assertSame(str_repeat('.', 18).'EL....N......V', $builder->getPattern());
37
38
        $builder->add(1 << 10);
39
        $this->assertSame(str_repeat('.', 18).'EL.'.MaskBuilder::ON.'..N......V', $builder->getPattern());
40
    }
41
}
42