Completed
Pull Request — master (#110)
by Franco
02:00
created

DMSGridFieldAddNewButtonTest::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
Bug introduced by
Possible parse error: class missing opening or closing brace
Loading history...
4
{
5
    protected static $fixture_file = 'dmstest.yml';
6
7
<<<<<<< HEAD
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

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