@@ -112,4 +112,54 @@ public function testSingleMust()
112
112
];
113
113
$ this ->assertEquals ($ expected , $ bool ->toArray ());
114
114
}
115
+
116
+ /**
117
+ * Tests if BoolQuery::getQueries returns an empty array.
118
+ */
119
+ public function testGetQueriesEmpty ()
120
+ {
121
+ $ bool = new BoolQuery ();
122
+
123
+ $ this ->assertInternalType ('array ' , $ bool ->getQueries ());
124
+ }
125
+
126
+ /**
127
+ * Tests if BoolQuery::getQueries returns an array with the added queries of all bool types.
128
+ */
129
+ public function testGetQueries ()
130
+ {
131
+ $ query = new TermQuery ('key1 ' , 'value1 ' );
132
+ $ query2 = new TermQuery ('key2 ' , 'value2 ' );
133
+
134
+ $ bool = new BoolQuery ();
135
+ $ bool ->add ($ query , BoolQuery::MUST , 'query ' );
136
+ $ bool ->add ($ query2 , BoolQuery::SHOULD , 'query2 ' );
137
+
138
+ $ this ->assertSame (array ('query ' => $ query , 'query2 ' => $ query2 ), $ bool ->getQueries ());
139
+ }
140
+
141
+ /**
142
+ * Tests if BoolQuery::getQueries with specified bool type returns an empty array.
143
+ */
144
+ public function testGetQueriesByBoolTypeEmpty ()
145
+ {
146
+ $ bool = new BoolQuery ();
147
+
148
+ $ this ->assertInternalType ('array ' , $ bool ->getQueries (BoolQuery::MUST ));
149
+ }
150
+
151
+ /**
152
+ * Tests if BoolQuery::getQueries with specified bool type returns an array with added queries.
153
+ */
154
+ public function testGetQueriesByBoolTypeWithQueryAddedToBoolType ()
155
+ {
156
+ $ query = new TermQuery ('key1 ' , 'value1 ' );
157
+ $ query2 = new TermQuery ('key2 ' , 'value2 ' );
158
+
159
+ $ bool = new BoolQuery ();
160
+ $ bool ->add ($ query , BoolQuery::MUST , 'query ' );
161
+ $ bool ->add ($ query2 , BoolQuery::SHOULD , 'query2 ' );
162
+
163
+ $ this ->assertSame (array ('query ' => $ query ), $ bool ->getQueries (BoolQuery::MUST ));
164
+ }
115
165
}
0 commit comments