2017-05-03 03:26:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class DMSGridFieldAddNewButtonTest extends SapphireTest
|
|
|
|
{
|
|
|
|
protected static $fixture_file = 'dmstest.yml';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var DMSGridFieldAddNewButton
|
|
|
|
*/
|
|
|
|
protected $button;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var GridField
|
|
|
|
*/
|
|
|
|
protected $gridField;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$fakeList = DMSDocument::get();
|
|
|
|
$this->gridField = GridField::create('TestGridField', false, $fakeList);
|
|
|
|
$this->button = new DMSGridFieldAddNewButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-02 04:49:41 +02:00
|
|
|
* Test that when no document set ID is present then it is not added to the URL for "add document"
|
2017-05-03 03:26:17 +02:00
|
|
|
*/
|
|
|
|
public function testNoPageIdInAddUrlWhenNotProvided()
|
|
|
|
{
|
|
|
|
$fragments = $this->button->getHTMLFragments($this->gridField);
|
|
|
|
$result = array_pop($fragments)->getValue();
|
2017-05-02 04:49:41 +02:00
|
|
|
$this->assertNotContains('?dsid', $result);
|
2017-05-03 03:26:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-02 04:49:41 +02:00
|
|
|
* Test that when a document set ID is provided, it is added onto the "add document" link
|
2017-05-03 03:26:17 +02:00
|
|
|
*/
|
|
|
|
public function testPageIdAddedToLinkWhenProvided()
|
|
|
|
{
|
2017-05-02 04:49:41 +02:00
|
|
|
$this->button->setDocumentSetId(123);
|
2017-05-03 03:26:17 +02:00
|
|
|
|
|
|
|
$fragments = $this->button->getHTMLFragments($this->gridField);
|
|
|
|
$result = array_pop($fragments)->getValue();
|
2017-05-02 04:49:41 +02:00
|
|
|
$this->assertContains('?dsid=123', $result);
|
2017-05-03 03:26:17 +02:00
|
|
|
}
|
|
|
|
}
|