GridFieldResourceTitleTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetHTMLFragments() 0 23 1
1
<?php
2
3
namespace SilverStripe\CKANRegistry\Tests\Forms;
4
5
use SilverStripe\CKANRegistry\Forms\GridFieldResourceTitle;
6
use SilverStripe\CKANRegistry\Model\Resource;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\Forms\GridField\GridField;
9
10
class GridFieldResourceTitleTest extends SapphireTest
11
{
12
    public function testGetHTMLFragments()
13
    {
14
        $resource = new Resource();
15
        $resource->Name = 'Ministry of Silly Walks';
16
        $resource->ResourceName = 'Face the Press';
17
18
        $gridField = new GridField('Test');
19
        $component = new GridFieldResourceTitle($resource, 'my-target-fragment');
20
        $result = $component->getHTMLFragments($gridField);
21
22
        $this->assertNotEmpty(
23
            $result['my-target-fragment'],
24
            'Should be assigned to the specified fragment'
25
        );
26
        $this->assertContains(
27
            'Ministry of Silly Walks | Face the Press',
28
            $result['my-target-fragment'],
29
            'Should contain title'
30
        );
31
        $this->assertContains(
32
            'Edit resource',
33
            $result['my-target-fragment'],
34
            'Edit button should exist'
35
        );
36
    }
37
}
38