Code Duplication    Length = 33-33 lines in 2 locations

eZ/Bundle/EzPublishCoreBundle/Features/Context/QueryControllerContext.php 2 locations

@@ 263-295 (lines=33) @@
260
    /**
261
     * @Then the Query results assigned to the :arg1 twig variable is a :arg2 object
262
     */
263
    public function theQueryResultsAssignedToTheTwigVariableIsAObject($twigVariableName, $className)
264
    {
265
        $variableFound = false;
266
        $classNameFound = false;
267
268
        $page = $this->getSession()->getPage();
269
        $variableNodes = $page->findAll('css', 'pre.sf-dump > samp > span.sf-dump-key');
270
        $valueNodes = $page->findAll('css', 'pre.sf-dump > samp > abbr.sf-dump-note');
271
272
        /** @var NodeElement $variableNode */
273
        foreach ($variableNodes as $variableNode) {
274
            if ($variableNode->getText() === $twigVariableName) {
275
                $variableFound = true;
276
            }
277
        }
278
279
        /** @var NodeElement $valueNodes */
280
        foreach ($valueNodes as $valueNode) {
281
            if ($valueNode->getText() === $className) {
282
                $classNameFound = true;
283
            }
284
        }
285
286
        Assert::assertTrue(
287
            $variableFound,
288
            "The $twigVariableName twig variable was not set"
289
        );
290
291
        Assert::assertTrue(
292
            $classNameFound,
293
            "The $className twig variable object was not set"
294
        );
295
    }
296
297
    /**
298
     * @Given /^the following template defined in "([^"]*)":$/
@@ 381-413 (lines=33) @@
378
    /**
379
     * @Then the Query results assigned to the twig variable is a Pagerfanta object and has limit :arg1 and selected page :arg2
380
     */
381
    public function theQueryResultsAssignedToTheTwigVariableIsAObjectAndHasLimitAndCountParams($pageLimit, $pageValue)
382
    {
383
        $pageLimitFound = false;
384
        $currentPageFound = false;
385
386
        $page = $this->getSession()->getPage();
387
        $maxPerPage = $page->findAll('css', 'div#maxPerPage');
388
        $currentPage = $page->findAll('css', 'div#currentPage');
389
390
        /** @var NodeElement $variableNode */
391
        foreach ($maxPerPage as $variableNode) {
392
            if ($variableNode->getText() === $pageLimit) {
393
                $pageLimitFound = true;
394
            }
395
        }
396
397
        /** @var NodeElement $valueNodes */
398
        foreach ($currentPage as $valueNode) {
399
            if ($valueNode->getText() === $pageValue) {
400
                $currentPageFound = true;
401
            }
402
        }
403
404
        Assert::assertTrue(
405
            $pageLimitFound,
406
            "The maxPerPage $pageLimit twig variable was not set"
407
        );
408
409
        Assert::assertTrue(
410
            $currentPageFound,
411
            "The currentPage $pageValue twig variable  was not set"
412
        );
413
    }
414
}
415