silverstripe-dms/tests/DMSGridFieldAddNewButtonTest.php
Robbie Averill e4bc553521 API Add document sets, remove *Page methods from DMSDocument
* Add 2.0.0 changelog
* Update DMSInterface and DMSDocumentInterface removing *page and adding getDocumentSetsByPage to DMSInterface
* Update use documentation and update unit tests

This commit changes the relationship from Pages has_many Documents to Pages has_many DocumentSets which are many_many to Documents. The upload field has been upated to attach documents to a set instead of a page, the tests updated and the DMSInterface and DMSDocumentInterface updated to be less relevant to pages and more relevant to document sets.
2017-05-09 13:04:29 +12:00

48 lines
1.2 KiB
PHP

<?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;
}
/**
* Test that when no document set ID is present then it is not added to the URL for "add document"
*/
public function testNoPageIdInAddUrlWhenNotProvided()
{
$fragments = $this->button->getHTMLFragments($this->gridField);
$result = array_pop($fragments)->getValue();
$this->assertNotContains('?dsid', $result);
}
/**
* Test that when a document set ID is provided, it is added onto the "add document" link
*/
public function testPageIdAddedToLinkWhenProvided()
{
$this->button->setDocumentSetId(123);
$fragments = $this->button->getHTMLFragments($this->gridField);
$result = array_pop($fragments)->getValue();
$this->assertContains('?dsid=123', $result);
}
}