2012-08-21 04:21:23 +02:00
|
|
|
<?php
|
2015-12-17 19:48:37 +01:00
|
|
|
class ShortCodeRelationFinderTest extends SapphireTest
|
|
|
|
{
|
2017-05-01 05:54:48 +02:00
|
|
|
protected static $fixture_file = 'dmstest.yml';
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
public function testFindInRate()
|
|
|
|
{
|
2017-05-17 07:24:50 +02:00
|
|
|
Config::inst()->update('DMS', 'shortcode_handler_key', 'dms_document_link');
|
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$d1 = $this->objFromFixture('DMSDocument', 'd1');
|
|
|
|
$d2 = $this->objFromFixture('DMSDocument', 'd2');
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$page1 = new SiteTree();
|
2017-05-01 05:54:48 +02:00
|
|
|
$page1->Content = 'Condition: <a title="document test 1" href="[dms_document_link,id=' . $d1->ID . ']">';
|
2015-12-17 19:48:37 +01:00
|
|
|
$page1ID = $page1->write();
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$page2 = new SiteTree();
|
2017-05-01 05:54:48 +02:00
|
|
|
$page2->Content = 'Condition: <a title="document test 2" href="[dms_document_link,id=' . $d2->ID . ']">';
|
2015-12-17 19:48:37 +01:00
|
|
|
$page2ID = $page2->write();
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$page3 = new SiteTree();
|
2017-05-01 05:54:48 +02:00
|
|
|
$page3->Content = 'Condition: <a title="document test 1" href="[dms_document_link,id=' . $d1->ID . ']">';
|
2015-12-17 19:48:37 +01:00
|
|
|
$page3ID = $page3->write();
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$finder = new ShortCodeRelationFinder();
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$ids = $finder->findPageIDs('UnknownShortcode');
|
|
|
|
$this->assertEquals(0, count($ids));
|
2012-08-21 04:21:23 +02:00
|
|
|
|
2015-12-17 19:48:37 +01:00
|
|
|
$ids = $finder->findPageIDs($d1->ID);
|
|
|
|
$this->assertNotContains($page2ID, $ids);
|
|
|
|
$this->assertContains($page1ID, $ids);
|
|
|
|
$this->assertContains($page3ID, $ids);
|
|
|
|
}
|
|
|
|
}
|