Passed
Pull Request — master (#40)
by Robbie
02:47
created

ResourceFieldTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testReadableName() 0 19 1
1
<?php
2
3
namespace SilverStripe\CKANRegistry\Tests\Model;
4
5
use SilverStripe\CKANRegistry\Model\ResourceField;
6
use SilverStripe\Dev\SapphireTest;
7
8
class ResourceFieldTest extends SapphireTest
9
{
10
    protected $usesDatabase = true;
11
12
    public function testReadableName()
13
    {
14
        $field = new ResourceField();
15
        $field->Name = 'Teachers_In-mY-Country';
0 ignored issues
show
Bug Best Practice introduced by
The property Name does not exist on SilverStripe\CKANRegistry\Model\ResourceField. Since you implemented __set, consider adding a @property annotation.
Loading history...
16
        $field->write();
17
18
        $this->assertSame(
19
            'Teachers in my country',
20
            $field->ReadableName,
21
            'Readable name should be generated on write'
22
        );
23
24
        $field->Name = 'Some-new_Name';
25
        $field->write();
26
27
        $this->assertSame(
28
            'Teachers in my country',
29
            $field->ReadableName,
30
            'Readable name should not be changed automatically once it is set'
31
        );
32
    }
33
}
34