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

ResourceFieldTest::testReadableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 19
rs 9.8333
c 0
b 0
f 0
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