Passed
Push — master ( f2132c...503c0b )
by Simon
16:29 queued 08:41
created

FluentIndexExtensionTest::testOnBeforeInit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
4
namespace Firesphere\SolrFluent\Tests;
5
6
7
use Firesphere\SolrFluent\Extensions\FluentIndexExtension;
8
use Firesphere\SolrSearch\Queries\BaseQuery;
9
use Firesphere\SolrSearch\States\SiteState;
10
use SilverStripe\Dev\SapphireTest;
11
use Solarium\QueryType\Select\Query\Query;
12
use TractorCow\Fluent\Model\Locale;
13
use TractorCow\Fluent\State\FluentState;
14
15
class FluentIndexExtensionTest extends SapphireTest
16
{
17
    protected static $fixture_file = '../fixtures/FluentTest.yml';
18
19
    public function testOnBeforeInit()
20
    {
21
        $extension = new FluentIndexExtension();
22
23
        $extension->onBeforeInit();
24
25
        $this->assertEquals(Locale::get()->count(), SiteState::getStates());
26
    }
27
28
    public function testOnBeforeSearch()
29
    {
30
        FluentState::singleton()->setLocale('en_NZ');
31
        $query = new BaseQuery();
32
        $clientQuery = new Query();
33
        $index = new \CircleCITestIndex();
0 ignored issues
show
Bug introduced by
The type CircleCITestIndex was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
35
        $extension = new FluentIndexExtension();
36
37
        $extension->setOwner($index);
38
39
        $extension->onBeforeSearch($query, $clientQuery);
40
41
        $field = $clientQuery->getQueryDefaultField();
42
43
        $this->assertEquals('en_NZ_text', $field);
44
    }
45
}
46