Completed
Branch MORE_COVERAGE (733c77)
by Gordon
12:45
created

SearchPageTest::testGetFacets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
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