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
![]() |
|||
35 | $this->assertNotEmpty($model->IP); |
||
0 ignored issues
–
show
The property
IP does not exist on LeKoala\CommonExtensions...t\Test_CommonExtensions . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
36 | } |
||
37 | |||
38 | $ip = '127.0.0.1'; |
||
39 | $model->IP = $ip; |
||
0 ignored issues
–
show
The property
IP does not exist on LeKoala\CommonExtensions...t\Test_CommonExtensions . Since you implemented __set , consider adding a @property annotation.
![]() |
|||
40 | $this->assertEquals($ip, $model->IP); |
||
41 | } |
||
42 | } |
||
43 |