Completed
Push — master ( eb83f4...bb238e )
by Maximilian
14s
created

PathInfoBuilderSlashesTest::testBuildWithAcl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Route;
13
14
use Sonata\DoctrinePHPCRAdminBundle\Route\PathInfoBuilderSlashes;
15
16
class PathInfoBuilderSlashesTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testBuild()
19
    {
20
        $collectionChild = $this->createMock('Sonata\\AdminBundle\\Route\\RouteCollection');
21
22
        $adminChild = $this->createMock('Sonata\\AdminBundle\\Admin\\AbstractAdmin');
23
        $adminChild->expects($this->once())
24
            ->method('getRoutes')
25
            ->will($this->returnValue($collectionChild));
26
27
        $admin = $this->createMock('Sonata\\AdminBundle\\Admin\\AbstractAdmin');
28
        $admin->expects($this->once())
29
            ->method('getChildren')
30
            ->will($this->returnValue(array($adminChild)));
31
32
        $collection = $this->createMock('Sonata\\AdminBundle\\Route\\RouteCollection');
33
        $collection->expects($this->once())
34
            ->method('addCollection')
35
            ->with($this->anything());
36
        $collection->expects($this->exactly(7))
37
            ->method('add')
38
            ->with($this->anything());
39
40
        $builder = new PathInfoBuilderSlashes();
41
        $builder->build($admin, $collection);
42
    }
43
44
    public function testBuildWithAcl()
45
    {
46
        $admin = $this->createMock('Sonata\\AdminBundle\\Admin\\AbstractAdmin');
47
        $admin->expects($this->once())
48
            ->method('getChildren')
49
            ->will($this->returnValue(array()));
50
        $admin->expects($this->once())
51
            ->method('isAclEnabled')
52
            ->will($this->returnValue(true));
53
54
        $collection = $this->createMock('Sonata\\AdminBundle\\Route\\RouteCollection');
55
        $collection->expects($this->exactly(8))
56
            ->method('add')
57
            ->with($this->anything());
58
59
        $builder = new PathInfoBuilderSlashes();
60
        $builder->build($admin, $collection);
61
    }
62
}
63