Merge branch '3' into 4

This commit is contained in:
Daniel Hensby 2017-07-25 12:02:31 +01:00
commit 0758f66932
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
6 changed files with 27 additions and 3 deletions

View File

@ -121,7 +121,8 @@ abstract class SilverStripeNavigatorItem extends ViewableData
*/
public function isArchived()
{
if (!$this->record->hasExtension(Versioned::class)) {
$recordClass = get_class($this->record);
if (!$recordClass::has_extension(Versioned::class)) {
return false;
}

View File

@ -53,8 +53,9 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem
public function canView($member = null)
{
$recordClass = get_class($this->record);
return (
$this->record->hasExtension(Versioned::class)
$recordClass::has_extension(Versioned::class)
&& $this->isArchived()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)

View File

@ -51,8 +51,9 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
public function canView($member = null)
{
$recordClass = get_class($this->record);
return (
$this->record->hasExtension(Versioned::class)
$recordClass::has_extension(Versioned::class)
&& $this->getLivePage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)

View File

@ -630,6 +630,25 @@ class VirtualPageTest extends FunctionalTest
$this->assertEquals('http://google.com', $response->getHeader('Location'));
}
public function testVirtualPageRendersCorrectTemplate()
{
$this->useDraftSite(true);
$this->useTestTheme(dirname(__FILE__), 'virtualpagetest', function () {
$page = new VirtualPageTest_ClassA();
$page->Title = 'Test Page';
$page->Content = 'NotThisContent';
$page->MyInitiallyCopiedField = 'TestContent';
$page->write();
$vp = new VirtualPage();
$vp->CopyContentFromID = $page->ID;
$vp->write();
$response = $this->get($vp->Link());
$this->assertEquals(200, $response->getStatusCode());
$this->assertContains('TestContent', $response->getBody());
$this->assertNotContains('NotThisContent', $response->getBody());
});
}
public function testMethod()
{
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp4');

View File

@ -0,0 +1 @@
<div>$Content</div>

View File

@ -0,0 +1 @@
<div>$MyInitiallyCopiedField</div>