1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace Suilven\FreeTextSearch\Tests\Page; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Dev\FunctionalTest; |
6
|
|
|
use Suilven\FreeTextSearch\Page\SearchPage; |
7
|
|
|
use Suilven\FreeTextSearch\Tests\Models\FlickrPhoto; |
8
|
|
|
|
9
|
|
|
class SearchPageControllerTest extends FunctionalTest |
10
|
|
|
{ |
11
|
|
|
protected static $fixture_file = [ |
12
|
|
|
'tests/fixtures/pages.yml', |
13
|
|
|
'tests/fixtures/sitetree.yml', |
14
|
|
|
'tests/fixtures/flickrphotos.yml', |
15
|
|
|
]; |
16
|
|
|
|
17
|
|
|
protected static $extra_dataobjects = [ |
18
|
|
|
FlickrPhoto::class, |
19
|
|
|
]; |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
public function testEmptySearchNoResults(): void |
23
|
|
|
{ |
24
|
|
|
$this->markTestSkipped('@todo'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
public function testEmptySearchShowResults(): void |
29
|
|
|
{ |
30
|
|
|
$this->markTestSkipped('@todo'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
public function testSearch(): void |
35
|
|
|
{ |
36
|
|
|
/** @var \Suilven\FreeTextSearch\Page\SearchPage $photoSearchPage */ |
37
|
|
|
$photoSearchPage = $this->objFromFixture(SearchPage::class, 'photo-search'); |
38
|
|
|
$photoSearchPage->publishRecursive(); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$this->assertInstanceOf('Suilven\FreeTextSearch\Page\SearchPage', $photoSearchPage); |
41
|
|
|
|
42
|
|
|
$page = $this->get('/photo-search/?q=Fish'); |
43
|
|
|
\error_log('PAGE:'); |
44
|
|
|
\error_log($page->getBody()); |
45
|
|
|
|
46
|
|
|
// @todo assertions |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
public function testSearchNotFirstPage(): void |
51
|
|
|
{ |
52
|
|
|
/** @var \Suilven\FreeTextSearch\Page\SearchPage $photoSearchPage */ |
53
|
|
|
$photoSearchPage = $this->objFromFixture(SearchPage::class, 'photo-search'); |
54
|
|
|
$photoSearchPage->publishRecursive(); |
55
|
|
|
|
56
|
|
|
$this->assertInstanceOf('Suilven\FreeTextSearch\Page\SearchPage', $photoSearchPage); |
57
|
|
|
|
58
|
|
|
$page = $this->get('/photo-search/?q=Fish&start=10'); |
59
|
|
|
\error_log('PAGE:'); |
60
|
|
|
\error_log($page->getBody()); |
61
|
|
|
|
62
|
|
|
// @todo more search results and assertions |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|