From f7abf23ac79385997859df9336e688a57b077457 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 1 Mar 2010 21:38:59 +0000 Subject: [PATCH] MINOR: Added test for link rewriting on SubsitesVirtualPages (from r89909) --- tests/SubsitesVirtualPageTest.php | 43 ++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/SubsitesVirtualPageTest.php b/tests/SubsitesVirtualPageTest.php index fd43bf3..a6f60b2 100644 --- a/tests/SubsitesVirtualPageTest.php +++ b/tests/SubsitesVirtualPageTest.php @@ -1,7 +1,10 @@ assertEquals($svp->SubsiteID, $subsite->ID); $this->assertEquals($svp->Title, $linky->Title); } + + 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('', + DB::query("SELECT \"Content\" FROM \"SiteTree\" WHERE \"ID\" = $svp->ID")->value()); + $this->assertContains('', + 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); + } + + } + } \ No newline at end of file