2009-05-04 03:20:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class VirtualPageTest extends SapphireTest {
|
|
|
|
static $fixture_file = 'sapphire/tests/model/VirtualPageTest.yml';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that, after you update the source page of a virtual page, all the virtual pages
|
|
|
|
* are updated
|
|
|
|
*/
|
|
|
|
function testEditingSourcePageUpdatesVirtualPages() {
|
|
|
|
$master = $this->objFromFixture('Page', 'master');
|
|
|
|
$master->Title = "New title";
|
2009-05-14 07:26:47 +02:00
|
|
|
$master->MenuTitle = "New menutitle";
|
2009-05-04 03:20:12 +02:00
|
|
|
$master->Content = "<p>New content</p>";
|
|
|
|
$master->write();
|
|
|
|
|
|
|
|
$vp1 = $this->objFromFixture('VirtualPage', 'vp1');
|
|
|
|
$vp2 = $this->objFromFixture('VirtualPage', 'vp2');
|
|
|
|
|
|
|
|
$this->assertEquals("New title", $vp1->Title);
|
|
|
|
$this->assertEquals("New title", $vp2->Title);
|
2009-05-14 07:26:47 +02:00
|
|
|
$this->assertEquals("New menutitle", $vp1->MenuTitle);
|
|
|
|
$this->assertEquals("New menutitle", $vp2->MenuTitle);
|
2009-05-04 03:20:12 +02:00
|
|
|
$this->assertEquals("<p>New content</p>", $vp1->Content);
|
|
|
|
$this->assertEquals("<p>New content</p>", $vp2->Content);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that, after you publish the source page of a virtual page, all the virtual pages
|
|
|
|
* are published
|
|
|
|
*/
|
|
|
|
function testPublishingSourcePagePublishesVirtualPages() {
|
2009-10-16 00:41:55 +02:00
|
|
|
$this->logInWithPermssion('ADMIN');
|
|
|
|
|
2009-05-04 03:20:12 +02:00
|
|
|
$master = $this->objFromFixture('Page', 'master');
|
|
|
|
$master->Title = "New title";
|
2009-05-14 07:26:47 +02:00
|
|
|
$master->MenuTitle = "New menutitle";
|
2009-05-04 03:20:12 +02:00
|
|
|
$master->Content = "<p>New content</p>";
|
|
|
|
$master->write();
|
|
|
|
$master->doPublish();
|
|
|
|
|
|
|
|
Versioned::reading_stage("Live");
|
|
|
|
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
|
|
|
|
$vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2'));
|
|
|
|
|
|
|
|
$this->assertNotNull($vp1);
|
|
|
|
$this->assertNotNull($vp2);
|
|
|
|
|
|
|
|
$this->assertEquals("New title", $vp1->Title);
|
|
|
|
$this->assertEquals("New title", $vp2->Title);
|
2009-05-14 07:26:47 +02:00
|
|
|
$this->assertEquals("New menutitle", $vp1->MenuTitle);
|
|
|
|
$this->assertEquals("New menutitle", $vp2->MenuTitle);
|
2009-05-04 03:20:12 +02:00
|
|
|
$this->assertEquals("<p>New content</p>", $vp1->Content);
|
|
|
|
$this->assertEquals("<p>New content</p>", $vp2->Content);
|
|
|
|
Versioned::reading_stage("Stage");
|
|
|
|
}
|
|
|
|
|
2009-05-14 07:26:47 +02:00
|
|
|
/**
|
|
|
|
* Test that virtual pages get the content from the master page when they are created.
|
|
|
|
*/
|
|
|
|
function testNewVirtualPagesGrabTheContentFromTheirMaster() {
|
|
|
|
$vp = new VirtualPage();
|
|
|
|
$vp->write();
|
|
|
|
|
|
|
|
$vp->CopyContentFromID = $this->idFromFixture('Page', 'master');
|
|
|
|
$vp->write();
|
|
|
|
|
|
|
|
$this->assertEquals("My Page", $vp->Title);
|
|
|
|
$this->assertEquals("My Page Nav", $vp->MenuTitle);
|
|
|
|
|
|
|
|
$vp->CopyContentFromID = $this->idFromFixture('Page', 'master2');
|
|
|
|
$vp->write();
|
|
|
|
|
|
|
|
$this->assertEquals("My Other Page", $vp->Title);
|
|
|
|
$this->assertEquals("My Other Page Nav", $vp->MenuTitle);
|
|
|
|
}
|
|
|
|
|
2009-05-04 03:20:12 +02:00
|
|
|
}
|