Completed
Push — fulltext_indexing_test ( 4cf81d )
by André
33:01
created

Views::theViewContainsSearchHits()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * @license For full copyright and license information view LICENSE file distributed with this source code.
4
 */
5
namespace eZ\Bundle\EzPublishRestBundle\Features\Context\SubContext;
6
7
use eZ\Publish\API\Repository\Values\Content\Search\SearchHit;
8
use eZ\Publish\Core\REST\Client\Values\View;
9
use PHPUnit_Framework_Assert as Assertion;
10
11
/**
12
 * @method mixed getResponseObject
13
 */
14
trait Views
15
{
16
    /**
17
     * @Given /^the View contains Search Hits$/
18
     */
19
    public function theViewContainsSearchHits()
20
    {
21
        /** @var View $view */
22
        $view = $this->getResponseObject();
0 ignored issues
show
Bug introduced by
It seems like getResponseObject() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
23
        Assertion::assertGreaterThan(1, count($view->result->searchHits));
24
    }
25
26
    /**
27
     * @Given /^the Search Hits are Content objects$/
28
     */
29
    public function theSearchHitsAreContentObjects()
30
    {
31
        /** @var SearchHit[] $searchHits */
32
        $searchHits = $this->getResponseObject()->result->searchHits;
0 ignored issues
show
Bug introduced by
It seems like getResponseObject() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
33
        foreach ($searchHits as $searchHit) {
34
            Assertion::assertInstanceOf('eZ\Publish\API\Repository\Values\Content\Content', $searchHit->valueObject);
35
        }
36
    }
37
}
38