Code Duplication    Length = 24-30 lines in 3 locations

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

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

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

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

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

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