ExtensionsTest::testIPExtension()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 13
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace LeKoala\CommonExtensions\Test;
4
5
use SilverStripe\Dev\SapphireTest;
6
use LeKoala\CommonExtensions\IPExtension;
7
use SilverStripe\Control\Controller;
8
9
class ExtensionsTest extends SapphireTest
10
{
11
    /**
12
     * Defines the fixture file to use for this test class
13
     * @var string
14
     */
15
    protected static $fixture_file = 'Test_CommonExtensions.yml';
16
17
    protected static $extra_dataobjects = array(
18
        Test_CommonExtensions::class,
19
    );
20
21
    public function testHasExtensions()
22
    {
23
        $model = new Test_CommonExtensions();
24
25
        $this->assertTrue($model->hasExtension(IPExtension::class));
26
    }
27
28
    public function testIPExtension()
29
    {
30
        $controller = Controller::curr();
31
32
        $model = new Test_CommonExtensions();
33
        $model->write();
34
        if ($controller) {
0 ignored issues
show
introduced by
$controller is of type SilverStripe\Control\Controller, thus it always evaluated to true.
Loading history...
35
            $this->assertNotEmpty($model->IP);
0 ignored issues
show
Bug Best Practice introduced by
The property IP does not exist on LeKoala\CommonExtensions...t\Test_CommonExtensions. Since you implemented __get, consider adding a @property annotation.
Loading history...
36
        }
37
38
        $ip = '127.0.0.1';
39
        $model->IP = $ip;
0 ignored issues
show
Bug Best Practice introduced by
The property IP does not exist on LeKoala\CommonExtensions...t\Test_CommonExtensions. Since you implemented __set, consider adding a @property annotation.
Loading history...
40
        $this->assertEquals($ip, $model->IP);
41
    }
42
}
43