mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
e4bc553521
* 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.
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
class DMSDocumentSetTest extends SapphireTest
|
|
{
|
|
protected static $fixture_file = 'dmstest.yml';
|
|
|
|
/**
|
|
* Ensure that getDocuments is extensible
|
|
*/
|
|
public function testGetDocumentsIsExtensible()
|
|
{
|
|
DMSDocumentSet::add_extension('StubRelatedDocumentExtension');
|
|
|
|
$set = new DMSDocumentSet;
|
|
$documents = $set->getDocuments();
|
|
|
|
$this->assertCount(1, $documents);
|
|
$this->assertSame('Extended', $documents->first()->Filename);
|
|
}
|
|
|
|
public function testRelations()
|
|
{
|
|
$s1 = $this->objFromFixture('SiteTree', 's1');
|
|
$s2 = $this->objFromFixture('SiteTree', 's2');
|
|
$s4 = $this->objFromFixture('SiteTree', 's4');
|
|
|
|
$ds1 = $this->objFromFixture('DMSDocumentSet', 'ds1');
|
|
$ds2 = $this->objFromFixture('DMSDocumentSet', 'ds2');
|
|
$ds3 = $this->objFromFixture('DMSDocumentSet', 'ds3');
|
|
|
|
$this->assertCount(0, $s4->getDocumentSets(), 'Page 4 has no document sets associated');
|
|
$this->assertCount(2, $s1->getDocumentSets(), 'Page 1 has 2 document sets');
|
|
$this->assertEquals(array($ds1->ID, $ds2->ID), $s1->getDocumentSets()->column('ID'));
|
|
}
|
|
}
|