2013-10-09 11:54:08 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Tests DMS shortcode linking functionality.
|
2014-01-10 03:19:12 +01:00
|
|
|
*
|
|
|
|
* @package dms
|
|
|
|
* @subpackage tests
|
2013-10-09 11:54:08 +02:00
|
|
|
*/
|
2015-12-17 19:48:37 +01:00
|
|
|
class DMSShortcodeTest extends SapphireTest
|
|
|
|
{
|
|
|
|
public function testShortcodeOperation()
|
|
|
|
{
|
|
|
|
$file = 'dms/tests/DMS-test-lorum-file.pdf';
|
|
|
|
$document = DMS::inst()->storeDocument($file);
|
2013-10-09 11:54:08 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$result = ShortcodeParser::get('default')->parse(sprintf(
|
2017-05-01 05:54:48 +02:00
|
|
|
'<p><a href="[dms_document_link id=\'%d\']">Document</a></p>',
|
|
|
|
$document->ID
|
2015-12-17 19:48:37 +01:00
|
|
|
));
|
2013-10-09 11:54:08 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$value = Injector::inst()->create('HTMLValue', $result);
|
|
|
|
$link = $value->query('//a')->item(0);
|
2013-10-09 11:54:08 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$this->assertStringEndsWith("/dmsdocument/$document->ID", $link->getAttribute('href'));
|
|
|
|
$this->assertEquals($document->getExtension(), $link->getAttribute('data-ext'));
|
|
|
|
$this->assertEquals($document->getFileSizeFormatted(), $link->getAttribute('data-size'));
|
|
|
|
}
|
2013-10-09 11:54:08 +02:00
|
|
|
}
|