| 1 | <?php |
||
| 3 | class DMSGridFieldAddNewButtonTest extends SapphireTest |
||
|
|
|||
| 4 | { |
||
| 5 | protected static $fixture_file = 'dmstest.yml'; |
||
| 6 | |||
| 7 | <<<<<<< HEAD |
||
| 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 | |||
| 54 |