silverstripe-dms/tests/DMSShortcodeTest.php
Andrew Short 76c4692d13 NEW: Add metadata to DMS links.
Shortlink links are now augmented with data attributes containing the
file extension and size.
2013-10-09 20:54:08 +11:00

24 lines
759 B
PHP

<?php
/**
* Tests DMS shortcode linking functionality.
*/
class DMSShortcodeTest extends SapphireTest {
public function testShortcodeOperation() {
$file = 'dms/tests/DMS-test-lorum-file.pdf';
$document = DMS::inst()->storeDocument($file);
$result = ShortcodeParser::get('default')->parse(sprintf(
'<p><a href="[dms_document_link,id=\'%d\']">Document</a></p>', $document->ID
));
$value = Injector::inst()->create('HTMLValue', $result);
$link = $value->query('//a')->item(0);
$this->assertEquals("/dmsdocument/$document->ID", $link->getAttribute('href'));
$this->assertEquals($document->getExtension(), $link->getAttribute('data-ext'));
$this->assertEquals($document->getFileSizeFormatted(), $link->getAttribute('data-size'));
}
}