1
|
|
|
<?php |
2
|
|
|
namespace Suilven\FreeTextSearch\Tests\Factory; |
3
|
|
|
|
4
|
|
|
use SilverStripe\Dev\SapphireTest; |
5
|
|
|
use Suilven\FreeTextSearch\Factory\SearcherFactory; |
6
|
|
|
use Suilven\FreeTextSearch\Page\SearchPage; |
7
|
|
|
|
8
|
|
|
class SearchPageTest extends SapphireTest |
9
|
|
|
{ |
10
|
|
|
/** @var SearchPage */ |
11
|
|
|
private $searchPage; |
12
|
|
|
|
13
|
|
|
public function setUp() |
14
|
|
|
{ |
15
|
|
|
parent::setUp(); |
16
|
|
|
$this->searchPage = new SearchPage(); |
17
|
|
|
$this->searchPage->IndexToSearch = 'flickrphotos'; |
18
|
|
|
$this->searchPage->write(); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testGetCMSFields() |
22
|
|
|
{ |
23
|
|
|
// this will contain the root tab |
24
|
|
|
$fields = $this->searchPage->getCMSFields(); |
25
|
|
|
|
26
|
|
|
/** @var TabSet $rootTab */ |
27
|
|
|
$rootTab = $fields->fieldByName('Root'); |
28
|
|
|
|
29
|
|
|
/** @var Tab $indexTab */ |
30
|
|
|
$indexTab = $rootTab->fieldByName('Index'); |
31
|
|
|
$fields = $indexTab->FieldList()->toArray(); |
32
|
|
|
|
33
|
|
|
$titles = array_map(function($field) { |
34
|
|
|
return $field->Name; |
35
|
|
|
}, $fields); |
36
|
|
|
|
37
|
|
|
$this->assertEquals(['IndexToSearch', 'PageSize', 'ShowTagCloudFor', 'ShowAllIfEmptyQuery'], $titles); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testGetFacets() |
41
|
|
|
{ |
42
|
|
|
$fields = $this->searchPage->getFacetFields(); |
43
|
|
|
// @todo Check what the case sensitivy issues are here |
44
|
|
|
$this->assertEquals(['Aperture', 'ShutterSpeed', 'ISO'], $fields); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetMany() |
48
|
|
|
{ |
49
|
|
|
$fields = $this->searchPage->getHasManyFields(); |
50
|
|
|
// @todo Check what the case sensitivy issues are here |
51
|
|
|
$this->assertEquals(['Suilven\ManticoreSearch\Tests\Models\FlickrTag'], $fields); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testGetHasOne() |
55
|
|
|
{ |
56
|
|
|
$fields = $this->searchPage->getHasOneFields(); |
57
|
|
|
// @todo Check what the case sensitivy issues are here |
58
|
|
|
$this->assertEquals(['Suilven\ManticoreSearch\Tests\Models\FlickrAuthor'], $fields); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|