1 | <?php |
||
10 | class ElasticaAdapterTest extends TestCase |
||
11 | { |
||
12 | /** |
||
13 | * @var ElasticaAdapter |
||
14 | */ |
||
15 | private $adapter; |
||
16 | private $resultSet; |
||
17 | private $searchable; |
||
18 | private $query; |
||
19 | private $options; |
||
20 | |||
21 | protected function setUp() |
||
22 | { |
||
23 | $this->query = $this->getMockBuilder('Elastica\\Query')->disableOriginalConstructor()->getMock(); |
||
24 | $this->resultSet = $this->getMockBuilder('Elastica\\ResultSet')->disableOriginalConstructor()->getMock(); |
||
25 | $this->searchable = $this->getMockBuilder('Elastica\\SearchableInterface')->disableOriginalConstructor()->getMock(); |
||
26 | |||
27 | $this->options = array("option1" => "value1", "option2" => "value2"); |
||
28 | |||
29 | $this->adapter = new ElasticaAdapter($this->searchable, $this->query, $this->options); |
||
30 | } |
||
31 | |||
32 | public function testGetResultSet() |
||
33 | { |
||
34 | $this->assertNull($this->adapter->getResultSet()); |
||
35 | |||
36 | $this->searchable->expects($this->any()) |
||
37 | ->method('search') |
||
38 | ->with($this->query, array('from' => 0, 'size' => 1, 'option1' => 'value1', 'option2' => 'value2')) |
||
39 | ->will($this->returnValue($this->resultSet)); |
||
40 | |||
41 | $this->adapter->getSlice(0, 1); |
||
42 | |||
43 | $this->assertSame($this->resultSet, $this->adapter->getResultSet()); |
||
44 | } |
||
45 | |||
46 | public function testGetSlice() |
||
47 | { |
||
48 | $this->searchable->expects($this->any()) |
||
49 | ->method('search') |
||
50 | ->with($this->query, array('from' => 10, 'size' => 30, 'option1' => 'value1', 'option2' => 'value2')) |
||
51 | ->will($this->returnValue($this->resultSet)); |
||
52 | |||
53 | $resultSet = $this->adapter->getSlice(10, 30); |
||
54 | |||
55 | $this->assertSame($this->resultSet, $resultSet); |
||
56 | $this->assertSame($this->resultSet, $this->adapter->getResultSet()); |
||
57 | } |
||
58 | |||
59 | public function testGetNbResults() |
||
60 | { |
||
61 | $this->searchable->expects($this->any()) |
||
62 | ->method('search') |
||
63 | ->with($this->query, $this->options) |
||
64 | ->will($this->returnValue($this->resultSet)); |
||
65 | |||
66 | $this->resultSet->expects($this->once()) |
||
67 | ->method('getTotalHits') |
||
68 | ->will($this->returnValue(100)); |
||
69 | |||
70 | $this->assertSame(100, $this->adapter->getNbResults()); |
||
71 | } |
||
72 | |||
73 | public function testGetNbResultsWithMaxResultsSet() |
||
88 | } |
||
89 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: