Passed
Push — master ( 3569ea...46575d )
by Simon
10:49 queued 08:57
created

FluentSiteStateTest::testUpdateQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
4
namespace Firesphere\SolrFluent\Tests;
5
6
use Firesphere\SolrFluent\States\FluentSiteState;
7
use Firesphere\SolrSearch\Queries\BaseQuery;
8
use SilverStripe\CMS\Model\SiteTree;
9
use SilverStripe\Dev\SapphireTest;
10
use TractorCow\Fluent\State\FluentState;
11
12
class FluentSiteStateTest extends SapphireTest
13
{
14
    public function testAppliesTo()
15
    {
16
        $state = new FluentSiteState();
17
18
        $this->assertFalse($state->appliesTo(SiteTree::class));
19
    }
20
21
    public function testIsApplicable()
22
    {
23
        $state = new FluentSiteState();
24
25
        $this->assertFalse($state->stateIsApplicable('en_US'));
26
    }
27
28
    public function testCurrentState()
29
    {
30
        $state = new FluentSiteState();
31
32
        $this->assertNull($state->activateState('en_US'));
33
34
        $this->assertEquals('en_US', $state->currentState());
35
    }
36
37
    public function testDefaultState()
38
    {
39
        $state = new FluentSiteState();
40
41
        $this->assertNull($state->setDefaultState('en_US'));
42
    }
43
44
    public function testUpdateQuery()
45
    {
46
        $query = new BaseQuery();
47
        FluentState::singleton()->setLocale('');
48
        $query->addTerm('Test');
49
        $terms = $query->getTerms();
50
        $state = new FluentSiteState();
51
        $this->assertNull($state->updateQuery($query));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $state->updateQuery($query) targeting Firesphere\SolrFluent\St...iteState::updateQuery() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
52
53
        $this->assertEquals($terms, $query->getTerms());
54
    }
55
}
56