mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
MINOR: Added test for link rewriting on SubsitesVirtualPages (from r89909) (from r96322)
This commit is contained in:
parent
61649efe3e
commit
d3e666c09a
@ -194,4 +194,42 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
|||||||
$this->assertEquals($svp->MetaTitle, 'SVPTitle');
|
$this->assertEquals($svp->MetaTitle, 'SVPTitle');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testFileLinkRewritingOnVirtualPages() {
|
||||||
|
// File setup
|
||||||
|
$this->logInWithPermssion('ADMIN');
|
||||||
|
touch(Director::baseFolder() . '/assets/testscript-test-file.pdf');
|
||||||
|
|
||||||
|
// Publish the source page
|
||||||
|
$page = $this->objFromFixture('Page', 'page1');
|
||||||
|
$this->assertTrue($page->doPublish());
|
||||||
|
|
||||||
|
$svp = new SubsitesVirtualPage();
|
||||||
|
$svp->CopyContentFromID = $page->ID;
|
||||||
|
$svp->write();
|
||||||
|
$svp->doPublish();
|
||||||
|
|
||||||
|
// Create a virtual page from it, and publish that
|
||||||
|
|
||||||
|
// Rename the file
|
||||||
|
$file = $this->objFromFixture('File', 'file1');
|
||||||
|
$file->Name = 'renamed-test-file.pdf';
|
||||||
|
|
||||||
|
// Verify that the draft and publish virtual pages both have the corrected link
|
||||||
|
$this->assertContains('<img src="assets/renamed-test-file.pdf" />',
|
||||||
|
DB::query("SELECT \"Content\" FROM \"SiteTree\" WHERE \"ID\" = $svp->ID")->value());
|
||||||
|
$this->assertContains('<img src="assets/renamed-test-file.pdf" />',
|
||||||
|
DB::query("SELECT \"Content\" FROM \"SiteTree_Live\" WHERE \"ID\" = $svp->ID")->value());
|
||||||
|
|
||||||
|
// File teardown
|
||||||
|
$testFiles = array(
|
||||||
|
'/assets/testscript-test-file.pdf',
|
||||||
|
'/assets/renamed-test-file.pdf',
|
||||||
|
);
|
||||||
|
foreach($testFiles as $file) {
|
||||||
|
if(file_exists(Director::baseFolder().$file)) unlink(Director::baseFolder().$file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user