Code Duplication    Length = 27-33 lines in 3 locations

eZ/Publish/Core/MVC/Symfony/Matcher/Tests/ContentBased/DepthTest.php 1 location

@@ 135-161 (lines=27) @@
132
     *
133
     * @return \PHPUnit_Framework_MockObject_MockObject
134
     */
135
    private function generateRepositoryMockForDepth($depth)
136
    {
137
        $locationServiceMock = $this
138
            ->getMockBuilder('eZ\\Publish\\API\\Repository\\LocationService')
139
            ->disableOriginalConstructor()
140
            ->getMock();
141
        $locationServiceMock->expects($this->once())
142
            ->method('loadLocation')
143
            ->with(42)
144
            ->will(
145
                $this->returnValue(
146
                    $this->getLocationMock(array('depth' => $depth))
147
                )
148
            );
149
150
        $repository = $this->getRepositoryMock();
151
        $repository
152
            ->expects($this->once())
153
            ->method('getLocationService')
154
            ->will($this->returnValue($locationServiceMock));
155
        $repository
156
            ->expects($this->once())
157
            ->method('getPermissionService')
158
            ->will($this->returnValue($this->getPermissionServiceMock($repository)));
159
160
        return $repository;
161
    }
162
}
163

eZ/Publish/Core/MVC/Symfony/Matcher/Tests/ContentBased/Id/ParentLocationTest.php 1 location

@@ 125-151 (lines=27) @@
122
     *
123
     * @return \PHPUnit_Framework_MockObject_MockObject
124
     */
125
    private function generateRepositoryMockForParentLocationId($parentLocationId)
126
    {
127
        $locationServiceMock = $this
128
            ->getMockBuilder('eZ\\Publish\\API\\Repository\\LocationService')
129
            ->disableOriginalConstructor()
130
            ->getMock();
131
        $locationServiceMock->expects($this->once())
132
            ->method('loadLocation')
133
            ->with(42)
134
            ->will(
135
                $this->returnValue(
136
                    $this->getLocationMock(array('parentLocationId' => $parentLocationId))
137
                )
138
            );
139
140
        $repository = $this->getRepositoryMock();
141
        $repository
142
            ->expects($this->once())
143
            ->method('getLocationService')
144
            ->will($this->returnValue($locationServiceMock));
145
        $repository
146
            ->expects($this->any())
147
            ->method('getPermissionService')
148
            ->will($this->returnValue($this->getPermissionServiceMock($repository)));
149
150
        return $repository;
151
    }
152
}
153

eZ/Publish/Core/MVC/Symfony/Matcher/Tests/ContentBased/Identifier/SectionTest.php 1 location

@@ 37-69 (lines=33) @@
34
     *
35
     * @return \PHPUnit_Framework_MockObject_MockObject
36
     */
37
    private function generateRepositoryMockForSectionIdentifier($sectionIdentifier)
38
    {
39
        $sectionServiceMock = $this
40
            ->getMockBuilder('eZ\\Publish\\API\\Repository\\SectionService')
41
            ->disableOriginalConstructor()
42
            ->getMock();
43
        $sectionServiceMock->expects($this->once())
44
            ->method('loadSection')
45
            ->will(
46
                $this->returnValue(
47
                    $this
48
                        ->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\Section')
49
                        ->setConstructorArgs(
50
                            array(
51
                                array('identifier' => $sectionIdentifier),
52
                            )
53
                        )
54
                        ->getMockForAbstractClass()
55
                )
56
            );
57
58
        $repository = $this->getRepositoryMock();
59
        $repository
60
            ->expects($this->once())
61
            ->method('getSectionService')
62
            ->will($this->returnValue($sectionServiceMock));
63
        $repository
64
            ->expects($this->any())
65
            ->method('getPermissionService')
66
            ->will($this->returnValue($this->getPermissionServiceMock($repository)));
67
68
        return $repository;
69
    }
70
71
    /**
72
     * @dataProvider matchSectionProvider