Code Duplication    Length = 24-30 lines in 3 locations

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

@@ 133-156 (lines=24) @@
130
     *
131
     * @return \PHPUnit_Framework_MockObject_MockObject
132
     */
133
    private function generateRepositoryMockForDepth($depth)
134
    {
135
        $locationServiceMock = $this->createMock(LocationService::class);
136
        $locationServiceMock->expects($this->once())
137
            ->method('loadLocation')
138
            ->with(42)
139
            ->will(
140
                $this->returnValue(
141
                    $this->getLocationMock(['depth' => $depth])
142
                )
143
            );
144
145
        $repository = $this->getRepositoryMock();
146
        $repository
147
            ->expects($this->once())
148
            ->method('getLocationService')
149
            ->will($this->returnValue($locationServiceMock));
150
        $repository
151
            ->expects($this->once())
152
            ->method('getPermissionResolver')
153
            ->will($this->returnValue($this->getPermissionResolverMock()));
154
155
        return $repository;
156
    }
157
}
158

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

@@ 124-147 (lines=24) @@
121
     *
122
     * @return \PHPUnit_Framework_MockObject_MockObject
123
     */
124
    private function generateRepositoryMockForParentLocationId($parentLocationId)
125
    {
126
        $locationServiceMock = $this->createMock(LocationService::class);
127
        $locationServiceMock->expects($this->once())
128
            ->method('loadLocation')
129
            ->with(42)
130
            ->will(
131
                $this->returnValue(
132
                    $this->getLocationMock(['parentLocationId' => $parentLocationId])
133
                )
134
            );
135
136
        $repository = $this->getRepositoryMock();
137
        $repository
138
            ->expects($this->once())
139
            ->method('getLocationService')
140
            ->will($this->returnValue($locationServiceMock));
141
        $repository
142
            ->expects($this->any())
143
            ->method('getPermissionResolver')
144
            ->will($this->returnValue($this->getPermissionResolverMock()));
145
146
        return $repository;
147
    }
148
}
149

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

@@ 37-66 (lines=30) @@
34
     *
35
     * @return \PHPUnit_Framework_MockObject_MockObject
36
     */
37
    private function generateRepositoryMockForSectionIdentifier($sectionIdentifier)
38
    {
39
        $sectionServiceMock = $this->createMock(SectionService::class);
40
        $sectionServiceMock->expects($this->once())
41
            ->method('loadSection')
42
            ->will(
43
                $this->returnValue(
44
                    $this
45
                        ->getMockBuilder(Section::class)
46
                        ->setConstructorArgs(
47
                            [
48
                                ['identifier' => $sectionIdentifier],
49
                            ]
50
                        )
51
                        ->getMockForAbstractClass()
52
                )
53
            );
54
55
        $repository = $this->getRepositoryMock();
56
        $repository
57
            ->expects($this->once())
58
            ->method('getSectionService')
59
            ->will($this->returnValue($sectionServiceMock));
60
        $repository
61
            ->expects($this->any())
62
            ->method('getPermissionResolver')
63
            ->will($this->returnValue($this->getPermissionResolverMock()));
64
65
        return $repository;
66
    }
67
68
    /**
69
     * @dataProvider matchSectionProvider