Code Duplication    Length = 24-30 lines in 3 locations

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

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

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