@@ 198-209 (lines=12) @@ | ||
195 | ||
196 | ||
197 | ||
198 | public function testCannotWriteInvalidClassname() { |
|
199 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
|
200 | $searchPage->ClassesToSearch = 'ThisClassDoesNotExist'; |
|
201 | $searchPage->SiteTreeOnly = false; |
|
202 | ||
203 | try { |
|
204 | $searchPage->write(); |
|
205 | $this->fail('Page should not be writeable'); |
|
206 | } catch (ValidationException $e) { |
|
207 | $this->assertEquals('The class ThisClassDoesNotExist does not exist', $e->getMessage()); |
|
208 | } |
|
209 | } |
|
210 | ||
211 | public function testCannotWriteNoSiteTreeOnlyNoClassNames() { |
|
212 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
|
@@ 211-222 (lines=12) @@ | ||
208 | } |
|
209 | } |
|
210 | ||
211 | public function testCannotWriteNoSiteTreeOnlyNoClassNames() { |
|
212 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
|
213 | $searchPage->ClassesToSearch = ''; |
|
214 | $searchPage->SiteTreeOnly = false; |
|
215 | ||
216 | try { |
|
217 | $searchPage->write(); |
|
218 | $this->fail('Page should not be writeable'); |
|
219 | } catch (ValidationException $e) { |
|
220 | $this->assertEquals('At least one searchable class must be available, or SiteTreeOnly flag set', $e->getMessage()); |
|
221 | } |
|
222 | } |
|
223 | ||
224 | ||
225 | public function testEmptySearchableClass() { |
|
@@ 225-241 (lines=17) @@ | ||
222 | } |
|
223 | ||
224 | ||
225 | public function testEmptySearchableClass() { |
|
226 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
|
227 | ||
228 | // This does not implement searchable |
|
229 | $searchPage->ClassesToSearch = ''; |
|
230 | $searchPage->SiteTreeOnly = false; |
|
231 | ||
232 | try { |
|
233 | $searchPage->write(); |
|
234 | $this->fail('Page should not be writeable'); |
|
235 | } catch (ValidationException $e) { |
|
236 | $this->assertEquals( |
|
237 | 'At least one searchable class must be available, or SiteTreeOnly flag set', |
|
238 | $e->getMessage() |
|
239 | ); |
|
240 | } |
|
241 | } |
|
242 | ||
243 | ||
244 | public function testNonSearchableClass() { |
|
@@ 374-384 (lines=11) @@ | ||
371 | } |
|
372 | ||
373 | ||
374 | public function testValidateClassesToSearchNonExistent() { |
|
375 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
|
376 | $searchPage->ClassesToSearch = 'WibbleWobble'; // does not exist |
|
377 | $searchPage->SiteTreeOnly = false; |
|
378 | try { |
|
379 | $searchPage->write(); |
|
380 | $this->fail('Test should have failed as WibbleWobble is not a valid class'); |
|
381 | } catch (ValidationException $e) { |
|
382 | $this->assertEquals('The class WibbleWobble does not exist', $e->getMessage()); |
|
383 | } |
|
384 | } |
|
385 | ||
386 | ||
387 | public function testValidateClassesToSearchNotSearchable() { |
|
@@ 387-397 (lines=11) @@ | ||
384 | } |
|
385 | ||
386 | ||
387 | public function testValidateClassesToSearchNotSearchable() { |
|
388 | $searchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
|
389 | $searchPage->ClassesToSearch = 'member'; // does not implement Searchable |
|
390 | $searchPage->SiteTreeOnly = false; |
|
391 | try { |
|
392 | $searchPage->write(); |
|
393 | $this->fail('Test should have failed as WibbleWobble is not a valid class'); |
|
394 | } catch (ValidationException $e) { |
|
395 | $this->assertEquals('The class member must have the Searchable extension', $e->getMessage()); |
|
396 | } |
|
397 | } |
|
398 | } |
|
399 |