mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge branch '3' into 4
This commit is contained in:
commit
0758f66932
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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');
|
||||
|
1
tests/model/themes/virtualpagetest/templates/Page.ss
Normal file
1
tests/model/themes/virtualpagetest/templates/Page.ss
Normal file
@ -0,0 +1 @@
|
||||
<div>$Content</div>
|
@ -0,0 +1 @@
|
||||
<div>$MyInitiallyCopiedField</div>
|
Loading…
Reference in New Issue
Block a user