File tree 2 files changed +17
-3
lines changed
test/lib/Elastica/Test/Query
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Elastica \Query ;
4
4
5
- use Elastica \Type ;
5
+ use Elastica \Type as ElasticaType ;
6
6
7
7
/**
8
8
* Ids Query.
@@ -50,7 +50,7 @@ public function addId($id)
50
50
*/
51
51
public function addType ($ type )
52
52
{
53
- if ($ type instanceof Type ) {
53
+ if ($ type instanceof ElasticaType ) {
54
54
$ type = $ type ->getName ();
55
55
} elseif (empty ($ type ) && !is_numeric ($ type )) {
56
56
// A type can be 0, but cannot be empty
@@ -71,7 +71,7 @@ public function addType($type)
71
71
*/
72
72
public function setType ($ type )
73
73
{
74
- if ($ type instanceof Type ) {
74
+ if ($ type instanceof ElasticaType ) {
75
75
$ type = $ type ->getName ();
76
76
} elseif (empty ($ type ) && !is_numeric ($ type )) {
77
77
// A type can be 0, but cannot be empty
Original file line number Diff line number Diff line change 4
4
5
5
use Elastica \Document ;
6
6
use Elastica \Query \Ids ;
7
+ use Elastica \Query \Type ;
7
8
use Elastica \Test \Base as BaseTest ;
8
9
9
10
class IdsTest extends BaseTest
@@ -185,4 +186,17 @@ public function testSetTypeArraySearchSingle()
185
186
186
187
$ this ->assertEquals (1 , $ resultSet ->count ());
187
188
}
189
+
190
+ public function testQueryTypeAndTypeCollision ()
191
+ {
192
+ // This test ensures that Elastica\Type and Elastica\Query\Type
193
+ // do not collide when used together, which at one point
194
+ // happened because of a use statement in Elastica\Query\Ids
195
+ // Test goal is to make sure a Fatal Error is not triggered
196
+ //
197
+ // adapted fix for Elastica\Filter\Type
198
+ // see https://github.com/ruflin/Elastica/pull/438
199
+ $ queryType = new Type ();
200
+ $ filter = new Ids ();
201
+ }
188
202
}
You can’t perform that action at this time.
0 commit comments