Completed
Push — master ( 1f0706...385015 )
by Franco
15s queued 10s
created

testNoPageIdInAddUrlWhenNotProvided()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
class DMSGridFieldAddNewButtonTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    protected static $fixture_file = 'dmstest.yml';
6
7
    /**
8
     * @var DMSGridFieldAddNewButton
9
     */
10
    protected $button;
11
12
    /**
13
     * @var GridField
14
     */
15
    protected $gridField;
16
17
    public function setUp()
18
    {
19
        parent::setUp();
20
21
        $fakeList = DMSDocument::get();
22
        $this->gridField = GridField::create('TestGridField', false, $fakeList);
23
        $this->button = new DMSGridFieldAddNewButton;
24
    }
25
26
    /**
27
     * Test that when no page ID is present then it is not added to the URL for "add document"
28
     */
29
    public function testNoPageIdInAddUrlWhenNotProvided()
30
    {
31
        $fragments = $this->button->getHTMLFragments($this->gridField);
32
        $result = array_pop($fragments)->getValue();
33
        $this->assertNotContains('?ID', $result);
34
    }
35
36
    /**
37
     * Test that when a page ID is provided, it is added onto the "add document" link
38
     */
39
    public function testPageIdAddedToLinkWhenProvided()
40
    {
41
        $this->button->setPageId(123);
42
43
        $fragments = $this->button->getHTMLFragments($this->gridField);
44
        $result = array_pop($fragments)->getValue();
45
        $this->assertContains('?ID=123', $result);
46
    }
47
}
48