Skip to content

Commit c10b047

Browse files
committed
Add missing pull request ids
2 parents a780fe6 + 04b19db commit c10b047

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

changes.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
CHANGES
22

3+
2014-11-20
4+
- add cache control parameters support to Elastica\Filter\Bool #725
5+
36
2014-11-19
47
- Avoid remove previously added params when adding a suggest to the query #726
58

69
2014-11-13
7-
- fixed reserved words in queries which composed of upper case letters (Util::replaceBooleanWords)
10+
- fixed reserved words in queries which composed of upper case letters (Util::replaceBooleanWords) #722
811

912
2014-10-31
10-
- Adding PSR-4 autoloading support
13+
- Adding PSR-4 autoloading support #714
1114

1215
2014-10-29
1316
- Updated Type::getDocument() exception handling. \Elastica\Exception\ResponseException will be thrown instead of \Elastica\Exception\NotFoundException if the ES response contains any error (i.e: Missing index) (BC break) #687

lib/Elastica/Filter/Bool.php

+4
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ public function toArray()
127127
$args['bool']['must_not'] = $this->_mustNot;
128128
}
129129

130+
if (isset($args['bool'])) {
131+
$args['bool'] = array_merge($args['bool'], $this->getParams());
132+
}
133+
130134
return $args;
131135
}
132136

test/lib/Elastica/Test/Filter/BoolTest.php

+43-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Elastica\Test\Filter;
44

5+
use Elastica\Filter\Terms;
56
use \Elastica\Query;
67
use Elastica\Filter\Bool;
78
use Elastica\Filter\Term;
@@ -10,8 +11,15 @@
1011

1112
class BoolTest extends BaseTest
1213
{
13-
public function testToArray()
14+
15+
/**
16+
* @return array
17+
*/
18+
public function getTestToArrayData()
1419
{
20+
$out = array();
21+
22+
// case #0
1523
$mainBool = new Bool();
1624

1725
$idsFilter1 = new Ids();
@@ -44,8 +52,41 @@ public function testToArray()
4452
)
4553
)
4654
);
55+
$out[] = array($mainBool, $expectedArray);
56+
57+
// case #1 _cache parameter should be supported
58+
$bool = new Bool();
59+
$terms = new Terms('field1', array('value1', 'value2'));
60+
$termsNot = new Terms('field2', array('value1', 'value2'));
61+
$bool->addMust($terms);
62+
$bool->addMustNot($termsNot);
63+
$bool->setCached(true);
64+
$bool->setCacheKey('my-cache-key');
65+
$expected = array(
66+
'bool' => array(
67+
'must' => array(
68+
$terms->toArray()
69+
),
70+
'must_not' => array(
71+
$termsNot->toArray()
72+
),
73+
'_cache' => true,
74+
'_cache_key' => 'my-cache-key'
75+
)
76+
);
77+
$out[] = array($bool, $expected);
78+
79+
return $out;
80+
}
4781

48-
$this->assertEquals($expectedArray, $mainBool->toArray());
82+
/**
83+
* @dataProvider getTestToArrayData()
84+
* @param Bool $bool
85+
* @param array $expectedArray
86+
*/
87+
public function testToArray(Bool $bool, $expectedArray)
88+
{
89+
$this->assertEquals($expectedArray, $bool->toArray());
4990
}
5091

5192
public function testBoolFilter()

0 commit comments

Comments
 (0)