Code Duplication    Length = 52-53 lines in 2 locations

eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/Compound/CompoundAndTest.php 1 location

@@ 269-321 (lines=53) @@
266
        $this->assertNull($compoundMatcher->reverseMatch($siteAccessName));
267
    }
268
269
    public function testReverseMatch()
270
    {
271
        $request = $this->createMock(SimplifiedRequest::class);
272
        $siteAccessName = 'fr_eng';
273
        $mapUriConfig = array('eng' => true);
274
        $mapHostConfig = array('fr.ezpublish.dev' => true);
275
        $compoundMatcher = new LogicalAnd(
276
            array(
277
                array(
278
                    'matchers' => array(
279
                        'Map\URI' => $mapUriConfig,
280
                        'Map\Host' => $mapHostConfig,
281
                    ),
282
                    'match' => $siteAccessName,
283
                ),
284
            )
285
        );
286
        $compoundMatcher->setRequest($request);
287
288
        $matcher1 = $this->createMock(VersatileMatcher::class);
289
        $matcher2 = $this->createMock(VersatileMatcher::class);
290
        $this->matcherBuilder
291
            ->expects($this->exactly(2))
292
            ->method('buildMatcher')
293
            ->will(
294
                $this->returnValueMap(
295
                    array(
296
                        array('Map\URI', $mapUriConfig, $request, $matcher1),
297
                        array('Map\Host', $mapHostConfig, $request, $matcher2),
298
                    )
299
                )
300
            );
301
302
        $reverseMatchedMatcher1 = $this->createMock(VersatileMatcher::class);
303
        $matcher1
304
            ->expects($this->once())
305
            ->method('reverseMatch')
306
            ->with($siteAccessName)
307
            ->will($this->returnValue($reverseMatchedMatcher1));
308
        $reverseMatchedMatcher2 = $this->createMock(VersatileMatcher::class);
309
        $matcher2
310
            ->expects($this->once())
311
            ->method('reverseMatch')
312
            ->with($siteAccessName)
313
            ->will($this->returnValue($reverseMatchedMatcher2));
314
315
        $compoundMatcher->setMatcherBuilder($this->matcherBuilder);
316
        $result = $compoundMatcher->reverseMatch($siteAccessName);
317
        $this->assertInstanceOf(LogicalAnd::class, $result);
318
        foreach ($result->getSubMatchers() as $subMatcher) {
319
            $this->assertInstanceOf(VersatileMatcher::class, $subMatcher);
320
        }
321
    }
322
323
    public function testSerialize()
324
    {

eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/Compound/CompoundOrTest.php 1 location

@@ 278-329 (lines=52) @@
275
        }
276
    }
277
278
    public function testReverseMatch2()
279
    {
280
        $request = $this->createMock(SimplifiedRequest::class);
281
        $siteAccessName = 'fr_eng';
282
        $mapUriConfig = array('eng' => true);
283
        $mapHostConfig = array('fr.ezpublish.dev' => true);
284
        $compoundMatcher = new LogicalOr(
285
            array(
286
                array(
287
                    'matchers' => array(
288
                        'Map\URI' => $mapUriConfig,
289
                        'Map\Host' => $mapHostConfig,
290
                    ),
291
                    'match' => $siteAccessName,
292
                ),
293
            )
294
        );
295
        $compoundMatcher->setRequest($request);
296
297
        $matcher1 = $this->createMock(VersatileMatcher::class);
298
        $matcher2 = $this->createMock(VersatileMatcher::class);
299
        $this->matcherBuilder
300
            ->expects($this->exactly(2))
301
            ->method('buildMatcher')
302
            ->will(
303
                $this->returnValueMap(
304
                    array(
305
                        array('Map\URI', $mapUriConfig, $request, $matcher1),
306
                        array('Map\Host', $mapHostConfig, $request, $matcher2),
307
                    )
308
                )
309
            );
310
311
        $matcher1
312
            ->expects($this->once())
313
            ->method('reverseMatch')
314
            ->with($siteAccessName)
315
            ->will($this->returnValue(null));
316
        $reverseMatchedMatcher2 = $this->createMock(VersatileMatcher::class);
317
        $matcher2
318
            ->expects($this->once())
319
            ->method('reverseMatch')
320
            ->with($siteAccessName)
321
            ->will($this->returnValue($reverseMatchedMatcher2));
322
323
        $compoundMatcher->setMatcherBuilder($this->matcherBuilder);
324
        $result = $compoundMatcher->reverseMatch($siteAccessName);
325
        $this->assertInstanceOf(LogicalOr::class, $result);
326
        foreach ($result->getSubMatchers() as $subMatcher) {
327
            $this->assertInstanceOf(VersatileMatcher::class, $subMatcher);
328
        }
329
    }
330
331
    public function testSerialize()
332
    {