Passed
Push — master ( 8fefff...2b8aa5 )
by Simon
09:30 queued 07:32
created

SubsiteStateTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 2
b 0
f 0
dl 0
loc 30
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testActivateState() 0 6 1
A testSetDefaultState() 0 5 1
A testCurrentState() 0 5 1
A testIsApplicable() 0 5 1
1
<?php
2
3
4
namespace Firesphere\SolrSubsites\Tests;
5
6
7
use Firesphere\SolrSubsites\States\SubsiteState;
8
use SilverStripe\Dev\SapphireTest;
9
use SilverStripe\Subsites\Model\Subsite;
10
11
class SubsiteStateTest extends SapphireTest
12
{
13
14
    public function testIsApplicable()
15
    {
16
        $state = new SubsiteState();
17
18
        $this->assertFalse($state->stateIsApplicable(0));
19
    }
20
21
    public function testSetDefaultState()
22
    {
23
        $state = new SubsiteState();
24
25
        $this->assertNull($state->setDefaultState(0));
1 ignored issue
show
Bug introduced by
Are you sure the usage of $state->setDefaultState(0) targeting Firesphere\SolrSubsites\...tate::setDefaultState() 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...
26
    }
27
28
    public function testCurrentState()
29
    {
30
        $state = new SubsiteState();
31
32
        $this->assertNull($state->currentState());
33
    }
34
35
    public function testActivateState()
36
    {
37
        $state = new SubsiteState();
38
        $state->activateState(0);
39
40
        $this->assertTrue(Subsite::$disable_subsite_filter);
41
    }
42
}
43