API Support renamed Versioned API

This commit is contained in:
Damian Mooyman 2016-04-01 16:17:37 +13:00
parent d22ad706a9
commit 716baa6b1f
28 changed files with 193 additions and 188 deletions

View File

@ -11,7 +11,7 @@ class CMSBatchAction_Publish extends CMSBatchAction {
} }
public function run(SS_List $pages) { public function run(SS_List $pages) {
return $this->batchaction($pages, 'doPublish', return $this->batchaction($pages, 'publishRecursive',
_t('CMSBatchActions.PUBLISHED_PAGES', 'Published %d pages, %d failures') _t('CMSBatchActions.PUBLISHED_PAGES', 'Published %d pages, %d failures')
); );
} }

View File

@ -909,7 +909,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// If the 'Save & Publish' button was clicked, also publish the page // If the 'Save & Publish' button was clicked, also publish the page
if ($doPublish) { if ($doPublish) {
$record->doPublish(); $record->publishRecursive();
$message = _t( $message = _t(
'CMSMain.PUBLISHED', 'CMSMain.PUBLISHED',
"Published '{title}' successfully.", "Published '{title}' successfully.",
@ -989,7 +989,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return Security::permissionFailure($this); return Security::permissionFailure($this);
} }
$record->doPublish(); $record->publishRecursive();
} }
/** /**
@ -1278,9 +1278,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$count = 0; $count = 0;
while($pages) { while($pages) {
foreach($pages as $page) { foreach($pages as $page) {
if($page && !$page->canPublish()) return Security::permissionFailure($this); if($page && !$page->canPublish()) {
return Security::permissionFailure($this);
}
$page->doPublish(); $page->publishRecursive();
$page->destroy(); $page->destroy();
unset($page); unset($page);
$count++; $count++;

View File

@ -110,7 +110,7 @@ class ErrorPage extends Page {
if(!$pageExists) { if(!$pageExists) {
$page = new ErrorPage($defaultData); $page = new ErrorPage($defaultData);
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
} }
// Check if static files are enabled // Check if static files are enabled
@ -227,8 +227,10 @@ class ErrorPage extends Page {
* *
* @return bool True if published * @return bool True if published
*/ */
public function doPublish() { public function publishSingle() {
if (!parent::doPublish()) return false; if (!parent::publishSingle()) {
return false;
}
return $this->writeStaticPage(); return $this->writeStaticPage();
} }

View File

@ -1104,7 +1104,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$combinedStageResult = array(); $combinedStageResult = array();
foreach(array('Stage', 'Live') as $stage) { foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
// Start by filling the array with the pages that actually exist // Start by filling the array with the pages that actually exist
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage"; $table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
@ -1355,7 +1355,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link'); $homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link');
$homepage->Sort = 1; $homepage->Sort = 1;
$homepage->write(); $homepage->write();
$homepage->publish('Stage', 'Live'); $homepage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$homepage->flushCache(); $homepage->flushCache();
DB::alteration_message('Home page created', 'created'); DB::alteration_message('Home page created', 'created');
} }
@ -1366,7 +1366,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$aboutus->Content = _t('SiteTree.DEFAULTABOUTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.<br /></p>'); $aboutus->Content = _t('SiteTree.DEFAULTABOUTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.<br /></p>');
$aboutus->Sort = 2; $aboutus->Sort = 2;
$aboutus->write(); $aboutus->write();
$aboutus->publish('Stage', 'Live'); $aboutus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$aboutus->flushCache(); $aboutus->flushCache();
DB::alteration_message('About Us page created', 'created'); DB::alteration_message('About Us page created', 'created');
@ -1375,7 +1375,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$contactus->Content = _t('SiteTree.DEFAULTCONTACTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.<br /></p>'); $contactus->Content = _t('SiteTree.DEFAULTCONTACTCONTENT', '<p>You can fill this page out with your own content, or delete it and create your own pages.<br /></p>');
$contactus->Sort = 3; $contactus->Sort = 3;
$contactus->write(); $contactus->write();
$contactus->publish('Stage', 'Live'); $contactus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$contactus->flushCache(); $contactus->flushCache();
DB::alteration_message('Contact Us page created', 'created'); DB::alteration_message('Contact Us page created', 'created');
} }
@ -2048,7 +2048,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return FieldList The available actions for this page. * @return FieldList The available actions for this page.
*/ */
public function getCMSActions() { public function getCMSActions() {
$existsOnLive = $this->getExistsOnLive(); $existsOnLive = $this->isPublished();
// Major actions appear as buttons immediately visible as page actions. // Major actions appear as buttons immediately visible as page actions.
$majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset noborder'); $majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset noborder');
@ -2100,7 +2100,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
); );
} }
if($this->stagesDiffer('Stage', 'Live') && !$this->getIsDeletedFromStage()) { if($this->stagesDiffer(Versioned::DRAFT, Versioned::LIVE) && !$this->getIsDeletedFromStage()) {
if($this->isPublished() && $this->canEdit()) { if($this->isPublished() && $this->canEdit()) {
// "rollback" // "rollback"
$moreOptions->push( $moreOptions->push(
@ -2181,7 +2181,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
); );
// Set up the initial state of the button to reflect the state of the underlying SiteTree object. // Set up the initial state of the button to reflect the state of the underlying SiteTree object.
if($this->stagesDiffer('Stage', 'Live')) { if($this->stagesDiffer(Versioned::DRAFT, Versioned::LIVE)) {
$publish->addExtraClass('ss-ui-alternate'); $publish->addExtraClass('ss-ui-alternate');
} }
} }
@ -2442,7 +2442,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
if(!$this->_cache_statusFlags || !$cached) { if(!$this->_cache_statusFlags || !$cached) {
$flags = array(); $flags = array();
if($this->getIsDeletedFromStage()) { if($this->getIsDeletedFromStage()) {
if($this->getExistsOnLive()) { if($this->isPublished()) {
$flags['removedfromdraft'] = array( $flags['removedfromdraft'] = array(
'text' => _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'), 'text' => _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'),
'title' => _t('SiteTree.REMOVEDFROMDRAFTHELP', 'Page is published, but has been deleted from draft'), 'title' => _t('SiteTree.REMOVEDFROMDRAFTHELP', 'Page is published, but has been deleted from draft'),
@ -2587,7 +2587,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
if(!$this->ID) return true; if(!$this->ID) return true;
if($this->isNew()) return false; if($this->isNew()) return false;
$stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID); $stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', Versioned::DRAFT, $this->ID);
// Return true for both completely deleted pages and for pages just deleted from stage // Return true for both completely deleted pages and for pages just deleted from stage
return !($stageVersion); return !($stageVersion);
@ -2599,7 +2599,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return bool * @return bool
*/ */
public function getExistsOnLive() { public function getExistsOnLive() {
return (bool)Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID); return $this->isPublished();
} }
/** /**

View File

@ -9,7 +9,7 @@
abstract class SiteTreeExtension extends DataExtension { abstract class SiteTreeExtension extends DataExtension {
/** /**
* Hook called before the page's {@link SiteTree::doPublish()} action is completed * Hook called before the page's {@link Versioned::publishSingle()} action is completed
* *
* @param SiteTree &$original The current Live SiteTree record prior to publish * @param SiteTree &$original The current Live SiteTree record prior to publish
*/ */
@ -17,7 +17,7 @@ abstract class SiteTreeExtension extends DataExtension {
} }
/** /**
* Hook called after the page's {@link SiteTree::doPublish()} action is completed * Hook called after the page's {@link Versioned::publishSingle()} action is completed
* *
* @param SiteTree &$original The current Live SiteTree record prior to publish * @param SiteTree &$original The current Live SiteTree record prior to publish
*/ */
@ -25,7 +25,7 @@ abstract class SiteTreeExtension extends DataExtension {
} }
/** /**
* Hook called before the page's {@link SiteTree::doUnpublish()} action is completed * Hook called before the page's {@link Versioned::doUnpublish()} action is completed
*/ */
public function onBeforeUnpublish() { public function onBeforeUnpublish() {
} }

View File

@ -317,7 +317,7 @@ in the other stage:<br />
$where[] = '"Parents"."ID" IS NULL'; $where[] = '"Parents"."ID" IS NULL';
$orphans = new ArrayList(); $orphans = new ArrayList();
foreach(array('Stage', 'Live') as $stage) { foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
$joinByStage = $join; $joinByStage = $join;
$table = $class; $table = $class;
$table .= ($stage == 'Live') ? '_Live' : ''; $table .= ($stage == 'Live') ? '_Live' : '';

View File

@ -40,7 +40,8 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte
foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) { foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class); $blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) { $blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
$obj->publish('Stage', 'Live'); /** @var \SiteTree $obj */
$obj->copyVersionToStage(\Versioned::DRAFT, \Versioned::LIVE);
}); });
$factory->define($class, $blueprint); $factory->define($class, $blueprint);
} }

View File

@ -31,6 +31,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
if (!$targetObj) $targetObj = $this->fixtureFactory->get($targetClass, $targetId); if (!$targetObj) $targetObj = $this->fixtureFactory->get($targetClass, $targetId);
$fields = array('LinkToID' => $targetObj->ID); $fields = array('LinkToID' => $targetObj->ID);
/** @var \RedirectorPage $obj */
$obj = $this->fixtureFactory->get($class, $id); $obj = $this->fixtureFactory->get($class, $id);
if ($obj) { if ($obj) {
$obj->update($fields); $obj->update($fields);
@ -38,7 +39,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
$obj = $this->fixtureFactory->createObject($class, $id, $fields); $obj = $this->fixtureFactory->createObject($class, $id, $fields);
} }
$obj->write(); $obj->write();
$obj->publish('Stage', 'Live'); $obj->copyVersionToStage(\Versioned::DRAFT, \Versioned::LIVE);
} }
/** /**

View File

@ -17,7 +17,7 @@ class AssetAdminTest extends SapphireTest {
// Create a test folders for each of the fixture references // Create a test folders for each of the fixture references
foreach(File::get()->filter('ClassName', 'Folder') as $folder) { foreach(File::get()->filter('ClassName', 'Folder') as $folder) {
/** @var Folder $folder */ /** @var Folder $folder */
$folder->doPublish(); $folder->publishSingle();
} }
// Create a test files for each of the fixture references // Create a test files for each of the fixture references
@ -25,7 +25,7 @@ class AssetAdminTest extends SapphireTest {
foreach(File::get()->exclude('ClassName', 'Folder') as $file) { foreach(File::get()->exclude('ClassName', 'Folder') as $file) {
/** @var File $file */ /** @var File $file */
$file->setFromString($content, $file->generateFilename()); $file->setFromString($content, $file->generateFilename());
$file->doPublish(); $file->publishSingle();
} }
} }

View File

@ -15,7 +15,7 @@ class CMSBatchActionsTest extends SapphireTest {
// published page // published page
$published = $this->objFromFixture('SiteTree', 'published'); $published = $this->objFromFixture('SiteTree', 'published');
$published->doPublish(); $published->publishSingle();
// Deleted / archived page // Deleted / archived page
$archived = $this->objFromFixture('SiteTree', 'archived'); $archived = $this->objFromFixture('SiteTree', 'archived');
@ -23,12 +23,12 @@ class CMSBatchActionsTest extends SapphireTest {
// Unpublished // Unpublished
$unpublished = $this->objFromFixture('SiteTree', 'unpublished'); $unpublished = $this->objFromFixture('SiteTree', 'unpublished');
$unpublished->doPublish(); $unpublished->publishSingle();
$unpublished->doUnpublish(); $unpublished->doUnpublish();
// Modified // Modified
$modified = $this->objFromFixture('SiteTree', 'modified'); $modified = $this->objFromFixture('SiteTree', 'modified');
$modified->doPublish(); $modified->publishSingle();
$modified->Title = 'modified2'; $modified->Title = 'modified2';
$modified->write(); $modified->write();
} }

View File

@ -156,7 +156,7 @@ class CMSMainTest extends FunctionalTest {
// $page->write(); // $page->write();
// $this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree\" WHERE \"ID\" = $page->ID")->value()); // $this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree\" WHERE \"ID\" = $page->ID")->value());
// $page->doPublish(); // $page->publishRecursive();
// $this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = $page->ID")->value()); // $this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = $page->ID")->value());
// // Check that you can visit the page // // Check that you can visit the page
@ -214,7 +214,7 @@ class CMSMainTest extends FunctionalTest {
// Set up a page that is delete from live // Set up a page that is delete from live
$page = $this->objFromFixture('Page', 'page1'); $page = $this->objFromFixture('Page', 'page1');
$pageID = $page->ID; $pageID = $page->ID;
$page->doPublish(); $page->publishRecursive();
$page->delete(); $page->delete();
$response = $this->get('admin/pages/edit/show/' . $pageID); $response = $this->get('admin/pages/edit/show/' . $pageID);
@ -236,7 +236,7 @@ class CMSMainTest extends FunctionalTest {
// Set up a page that is delete from live // Set up a page that is delete from live
$page1 = $this->objFromFixture('Page', 'page1'); $page1 = $this->objFromFixture('Page', 'page1');
$page1ID = $page1->ID; $page1ID = $page1->ID;
$page1->doPublish(); $page1->publishRecursive();
$page1->delete(); $page1->delete();
$cmsMain = new CMSMain(); $cmsMain = new CMSMain();
@ -448,9 +448,9 @@ class CMSMainTest extends FunctionalTest {
$page1->doUnpublish(); $page1->doUnpublish();
$page1->delete(); $page1->delete();
// Live and draft // Live and draft
$page11->publish('Stage', 'Live'); $page11->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
// Live only // Live only
$page12->publish('Stage', 'Live'); $page12->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page12->delete(); $page12->delete();
// Re-test all pages (stage) // Re-test all pages (stage)

View File

@ -26,7 +26,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest {
$this->page->Content = "some further content"; $this->page->Content = "some further content";
$this->page->write(); $this->page->write();
$this->page->publish('Stage', 'Live'); $this->page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$this->versionPublishCheck = $this->page->Version; $this->versionPublishCheck = $this->page->Version;
$this->page->Content = "No, more changes please"; $this->page->Content = "No, more changes please";
@ -36,7 +36,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest {
$this->page->Title = "Final Change"; $this->page->Title = "Final Change";
$this->page->write(); $this->page->write();
$this->page->publish('Stage', 'Live'); $this->page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$this->versionPublishCheck2 = $this->page->Version; $this->versionPublishCheck2 = $this->page->Version;
} }

View File

@ -48,11 +48,11 @@ class CMSSiteTreeFilterTest extends SapphireTest {
public function testChangedPagesFilter() { public function testChangedPagesFilter() {
$unchangedPage = $this->objFromFixture('Page', 'page1'); $unchangedPage = $this->objFromFixture('Page', 'page1');
$unchangedPage->doPublish(); $unchangedPage->publishRecursive();
$changedPage = $this->objFromFixture('Page', 'page2'); $changedPage = $this->objFromFixture('Page', 'page2');
$changedPage->Title = 'Original'; $changedPage->Title = 'Original';
$changedPage->publish('Stage', 'Live'); $changedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$changedPage->Title = 'Changed'; $changedPage->Title = 'Changed';
$changedPage->write(); $changedPage->write();
@ -75,7 +75,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
// If we roll back to an earlier version than what's on the published site, we should still show the changed // If we roll back to an earlier version than what's on the published site, we should still show the changed
$changedPage->Title = 'Changed 2'; $changedPage->Title = 'Changed 2';
$changedPage->publish('Stage', 'Live'); $changedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$changedPage->doRollbackTo(1); $changedPage->doRollbackTo(1);
$f = new CMSSiteTreeFilter_ChangedPages(array('Term' => 'Changed')); $f = new CMSSiteTreeFilter_ChangedPages(array('Term' => 'Changed'));
@ -87,7 +87,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
public function testDeletedPagesFilter() { public function testDeletedPagesFilter() {
$deletedPage = $this->objFromFixture('Page', 'page2'); $deletedPage = $this->objFromFixture('Page', 'page2');
$deletedPage->publish('Stage', 'Live'); $deletedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$deletedPageID = $deletedPage->ID; $deletedPageID = $deletedPage->ID;
$deletedPage->delete(); $deletedPage->delete();
$deletedPage = Versioned::get_one_by_stage( $deletedPage = Versioned::get_one_by_stage(
@ -106,7 +106,6 @@ class CMSSiteTreeFilterTest extends SapphireTest {
public function testStatusDraftPagesFilter() { public function testStatusDraftPagesFilter() {
$draftPage = $this->objFromFixture('Page', 'page4'); $draftPage = $this->objFromFixture('Page', 'page4');
$draftPage->publish('Stage', 'Stage');
$draftPage = Versioned::get_one_by_stage( $draftPage = Versioned::get_one_by_stage(
'SiteTree', 'SiteTree',
'Stage', 'Stage',
@ -141,7 +140,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
public function testStatusRemovedFromDraftFilter() { public function testStatusRemovedFromDraftFilter() {
$removedDraftPage = $this->objFromFixture('Page', 'page6'); $removedDraftPage = $this->objFromFixture('Page', 'page6');
$removedDraftPage->doPublish(); $removedDraftPage->publishRecursive();
$removedDraftPage->deleteFromStage('Stage'); $removedDraftPage->deleteFromStage('Stage');
$removedDraftPage = Versioned::get_one_by_stage( $removedDraftPage = Versioned::get_one_by_stage(
'SiteTree', 'SiteTree',
@ -165,7 +164,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
public function testStatusDeletedFilter() { public function testStatusDeletedFilter() {
$deletedPage = $this->objFromFixture('Page', 'page7'); $deletedPage = $this->objFromFixture('Page', 'page7');
$deletedPage->publish('Stage', 'Live'); $deletedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$deletedPageID = $deletedPage->ID; $deletedPageID = $deletedPage->ID;
// Can't use straight $blah->delete() as that blows it away completely and test fails // Can't use straight $blah->delete() as that blows it away completely and test fails

View File

@ -14,7 +14,7 @@ class ContentControllerPermissionsTest extends FunctionalTest {
$page = new Page(); $page = new Page();
$page->URLSegment = 'testpage'; $page->URLSegment = 'testpage';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
// Add a stage-only version // Add a stage-only version
$page->Content = "Version2"; $page->Content = "Version2";

View File

@ -6,7 +6,7 @@ class ContentControllerSearchExtensionTest extends SapphireTest {
$page->URLSegment = 'whatever'; $page->URLSegment = 'whatever';
$page->Content = 'oh really?'; $page->Content = 'oh really?';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$controller = new ContentController($page); $controller = new ContentController($page);
$form = $controller->SearchForm(); $form = $controller->SearchForm();

View File

@ -116,13 +116,13 @@ class ContentControllerTest extends FunctionalTest {
$linkedPage = new SiteTree(); $linkedPage = new SiteTree();
$linkedPage->URLSegment = 'linked-page'; $linkedPage->URLSegment = 'linked-page';
$linkedPage->write(); $linkedPage->write();
$linkedPage->publish('Stage', 'Live'); $linkedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page = new SiteTree(); $page = new SiteTree();
$page->URLSegment = 'linking-page'; $page->URLSegment = 'linking-page';
$page->Content = sprintf('<a href="[sitetree_link,id=%s]">Testlink</a>', $linkedPage->ID); $page->Content = sprintf('<a href="[sitetree_link,id=%s]">Testlink</a>', $linkedPage->ID);
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$this->assertContains( $this->assertContains(
sprintf('<a href="%s">Testlink</a>', $linkedPage->Link()), sprintf('<a href="%s">Testlink</a>', $linkedPage->Link()),
@ -146,7 +146,7 @@ class ContentControllerTest extends FunctionalTest {
$page = new ContentControllerTestPageWithoutController(); $page = new ContentControllerTestPageWithoutController();
$page->URLSegment = "test"; $page->URLSegment = "test";
$page->write(); $page->write();
$page->publish("Stage", "Live"); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $self->get($page->RelativeLink()); $response = $self->get($page->RelativeLink());
$self->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody())); $self->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody()));
@ -155,7 +155,7 @@ class ContentControllerTest extends FunctionalTest {
$page = new ContentControllerTestPage(); $page = new ContentControllerTestPage();
$page->URLSegment = "test"; $page->URLSegment = "test";
$page->write(); $page->write();
$page->publish("Stage", "Live"); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $self->get($page->RelativeLink()); $response = $self->get($page->RelativeLink());
$self->assertEquals("Page", trim($response->getBody())); $self->assertEquals("Page", trim($response->getBody()));
@ -165,7 +165,7 @@ class ContentControllerTest extends FunctionalTest {
$page = new ContentControllerTestPage(); $page = new ContentControllerTestPage();
$page->URLSegment = "page-without-controller"; $page->URLSegment = "page-without-controller";
$page->write(); $page->write();
$page->publish("Stage", "Live"); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $self->get($page->RelativeLink("test")); $response = $self->get($page->RelativeLink("test"));
$self->assertEquals("ContentControllerTestPage_test", trim($response->getBody())); $self->assertEquals("ContentControllerTestPage_test", trim($response->getBody()));

View File

@ -46,33 +46,33 @@ class ModelAsControllerTest extends FunctionalTest {
$level1->Title = 'First Level'; $level1->Title = 'First Level';
$level1->URLSegment = 'level1'; $level1->URLSegment = 'level1';
$level1->write(); $level1->write();
$level1->publish('Stage', 'Live'); $level1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$level1->URLSegment = 'newlevel1'; $level1->URLSegment = 'newlevel1';
$level1->write(); $level1->write();
$level1->publish('Stage', 'Live'); $level1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$level2 = new Page(); $level2 = new Page();
$level2->Title = 'Second Level'; $level2->Title = 'Second Level';
$level2->URLSegment = 'level2'; $level2->URLSegment = 'level2';
$level2->ParentID = $level1->ID; $level2->ParentID = $level1->ID;
$level2->write(); $level2->write();
$level2->publish('Stage', 'Live'); $level2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$level2->URLSegment = 'newlevel2'; $level2->URLSegment = 'newlevel2';
$level2->write(); $level2->write();
$level2->publish('Stage', 'Live'); $level2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$level3 = New Page(); $level3 = New Page();
$level3->Title = "Level 3"; $level3->Title = "Level 3";
$level3->URLSegment = 'level3'; $level3->URLSegment = 'level3';
$level3->ParentID = $level2->ID; $level3->ParentID = $level2->ID;
$level3->write(); $level3->write();
$level3->publish('Stage','Live'); $level3->copyVersionToStage('Stage','Live');
$level3->URLSegment = 'newlevel3'; $level3->URLSegment = 'newlevel3';
$level3->write(); $level3->write();
$level3->publish('Stage','Live'); $level3->copyVersionToStage('Stage','Live');
} }
/** /**
@ -125,39 +125,39 @@ class ModelAsControllerTest extends FunctionalTest {
$page->Title = 'First Level'; $page->Title = 'First Level';
$page->URLSegment = 'oldurl'; $page->URLSegment = 'oldurl';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page->URLSegment = 'newurl'; $page->URLSegment = 'newurl';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page2 = new Page(); $page2 = new Page();
$page2->Title = 'Second Level Page'; $page2->Title = 'Second Level Page';
$page2->URLSegment = 'level2'; $page2->URLSegment = 'level2';
$page2->ParentID = $page->ID; $page2->ParentID = $page->ID;
$page2->write(); $page2->write();
$page2->publish('Stage', 'Live'); $page2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page3 = new Page(); $page3 = new Page();
$page3->Title = 'Third Level Page'; $page3->Title = 'Third Level Page';
$page3->URLSegment = 'level3'; $page3->URLSegment = 'level3';
$page3->ParentID = $page2->ID; $page3->ParentID = $page2->ID;
$page3->write(); $page3->write();
$page3->publish('Stage', 'Live'); $page3->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page4 = new Page(); $page4 = new Page();
$page4->Title = 'Fourth Level Page'; $page4->Title = 'Fourth Level Page';
$page4->URLSegment = 'level4'; $page4->URLSegment = 'level4';
$page4->ParentID = $page3->ID; $page4->ParentID = $page3->ID;
$page4->write(); $page4->write();
$page4->publish('Stage', 'Live'); $page4->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page5 = new Page(); $page5 = new Page();
$page5->Title = 'Fifth Level Page'; $page5->Title = 'Fifth Level Page';
$page5->URLSegment = 'level5'; $page5->URLSegment = 'level5';
$page5->ParentID = $page4->ID; $page5->ParentID = $page4->ID;
$page5->write(); $page5->write();
$page5->publish('Stage', 'Live'); $page5->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
// Test that the redirect still works fine when trying to access the most nested page // Test that the redirect still works fine when trying to access the most nested page
$response = $this->get('oldurl/level2/level3/level4/level5/'); $response = $this->get('oldurl/level2/level3/level4/level5/');
@ -192,7 +192,7 @@ class ModelAsControllerTest extends FunctionalTest {
'URLSegment' => 'otherparent' 'URLSegment' => 'otherparent'
)); ));
$otherParent->write(); $otherParent->write();
$otherParent->publish('Stage', 'Live'); $otherParent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $this->get('level1/otherparent'); $response = $this->get('level1/otherparent');
$this->assertEquals($response->getStatusCode(), 301); $this->assertEquals($response->getStatusCode(), 301);
@ -235,7 +235,7 @@ class ModelAsControllerTest extends FunctionalTest {
'URLSegment' => 'level1' 'URLSegment' => 'level1'
)); ));
$otherLevel1->write(); $otherLevel1->write();
$otherLevel1->publish('Stage', 'Live'); $otherLevel1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $this->get('level1'); $response = $this->get('level1');
$this->assertEquals( $this->assertEquals(
@ -261,11 +261,11 @@ class ModelAsControllerTest extends FunctionalTest {
$page->Title = 'First Level'; $page->Title = 'First Level';
$page->URLSegment = 'oldurl'; $page->URLSegment = 'oldurl';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page->URLSegment = 'newurl'; $page->URLSegment = 'newurl';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$url = OldPageRedirector::find_old_page('oldurl'); $url = OldPageRedirector::find_old_page('oldurl');
$matchedPage = SiteTree::get_by_link($url); $matchedPage = SiteTree::get_by_link($url);
@ -276,11 +276,11 @@ class ModelAsControllerTest extends FunctionalTest {
$page2->URLSegment = 'oldpage2'; $page2->URLSegment = 'oldpage2';
$page2->ParentID = $page->ID; $page2->ParentID = $page->ID;
$page2->write(); $page2->write();
$page2->publish('Stage', 'Live'); $page2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page2->URLSegment = 'newpage2'; $page2->URLSegment = 'newpage2';
$page2->write(); $page2->write();
$page2->publish('Stage', 'Live'); $page2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$url = OldPageRedirector::find_old_page('oldpage2',$page2->ParentID); $url = OldPageRedirector::find_old_page('oldpage2',$page2->ParentID);
$matchedPage = SiteTree::get_by_link($url); $matchedPage = SiteTree::get_by_link($url);
@ -309,7 +309,7 @@ class ModelAsControllerTest extends FunctionalTest {
$published->Title = 'Published Page Under Draft Page'; $published->Title = 'Published Page Under Draft Page';
$published->URLSegment = 'sub-root'; $published->URLSegment = 'sub-root';
$published->write(); $published->write();
$published->publish('Stage', 'Live'); $published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $this->get('root/sub-root'); $response = $this->get('root/sub-root');
$this->assertEquals( $this->assertEquals(

View File

@ -25,11 +25,11 @@ class ErrorPageFileExtensionTest extends SapphireTest {
public function testErrorPage() { public function testErrorPage() {
// Get and publish records // Get and publish records
$notFoundPage = $this->objFromFixture('ErrorPage', '404'); $notFoundPage = $this->objFromFixture('ErrorPage', '404');
$notFoundPage->publish('Stage', 'Live'); $notFoundPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$notFoundLink = $notFoundPage->Link(); $notFoundLink = $notFoundPage->Link();
$disallowedPage = $this->objFromFixture('ErrorPage', '403'); $disallowedPage = $this->objFromFixture('ErrorPage', '403');
$disallowedPage->publish('Stage', 'Live'); $disallowedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$disallowedLink = $disallowedPage->Link(); $disallowedLink = $disallowedPage->Link();
// Get stage version of file // Get stage version of file

View File

@ -31,7 +31,7 @@ class ErrorPageTest extends FunctionalTest {
public function test404ErrorPage() { public function test404ErrorPage() {
$page = $this->objFromFixture('ErrorPage', '404'); $page = $this->objFromFixture('ErrorPage', '404');
// ensure that the errorpage exists as a physical file // ensure that the errorpage exists as a physical file
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $this->get('nonexistent-page'); $response = $this->get('nonexistent-page');
@ -57,7 +57,7 @@ class ErrorPageTest extends FunctionalTest {
public function testBehaviourOf403() { public function testBehaviourOf403() {
$page = $this->objFromFixture('ErrorPage', '403'); $page = $this->objFromFixture('ErrorPage', '403');
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$response = $this->get($page->RelativeLink()); $response = $this->get($page->RelativeLink());
@ -68,7 +68,7 @@ class ErrorPageTest extends FunctionalTest {
public function testSecurityError() { public function testSecurityError() {
// Generate 404 page // Generate 404 page
$page = $this->objFromFixture('ErrorPage', '404'); $page = $this->objFromFixture('ErrorPage', '404');
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
// Test invalid action // Test invalid action
$response = $this->get('Security/nosuchaction'); $response = $this->get('Security/nosuchaction');
@ -88,8 +88,8 @@ class ErrorPageTest extends FunctionalTest {
$page->ErrorCode = 401; $page->ErrorCode = 401;
$page->Title = 'Unauthorised'; $page->Title = 'Unauthorised';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage('Stage', 'Live');
$page->doPublish(); $page->publishRecursive();
// Static cache should now exist // Static cache should now exist
$this->assertNotEmpty(ErrorPage::get_content_for_errorcode('401')); $this->assertNotEmpty(ErrorPage::get_content_for_errorcode('401'));
@ -108,7 +108,7 @@ class ErrorPageTest extends FunctionalTest {
$page->ErrorCode = 405; $page->ErrorCode = 405;
$page->Title = 'Method Not Allowed'; $page->Title = 'Method Not Allowed';
$page->write(); $page->write();
$page->doPublish(); $page->publishRecursive();
// Dynamic content is available // Dynamic content is available
$response = ErrorPage::response_for('405'); $response = ErrorPage::response_for('405');

View File

@ -21,7 +21,7 @@ class FileLinkTrackingTest extends SapphireTest {
Filesystem::makeFolder(dirname($destPath)); Filesystem::makeFolder(dirname($destPath));
file_put_contents($destPath, str_repeat('x', 1000000)); file_put_contents($destPath, str_repeat('x', 1000000));
// Ensure files are published, thus have public urls // Ensure files are published, thus have public urls
$file->doPublish(); $file->publishRecursive();
} }
// Since we can't hard-code IDs, manually inject image tracking shortcode // Since we can't hard-code IDs, manually inject image tracking shortcode
@ -46,7 +46,7 @@ class FileLinkTrackingTest extends SapphireTest {
*/ */
public function testFileRenameUpdatesDraftAndPublishedPages() { public function testFileRenameUpdatesDraftAndPublishedPages() {
$page = $this->objFromFixture('Page', 'page1'); $page = $this->objFromFixture('Page', 'page1');
$page->doPublish(); $page->publishRecursive();
// Live and stage pages both have link to public file // Live and stage pages both have link to public file
Versioned::set_stage(Versioned::DRAFT); Versioned::set_stage(Versioned::DRAFT);
@ -82,7 +82,7 @@ class FileLinkTrackingTest extends SapphireTest {
// Publishing the file should result in a direct public link (indicated by "FileLinkTrackingTest") // Publishing the file should result in a direct public link (indicated by "FileLinkTrackingTest")
// Although the old live page will still point to the old record. // Although the old live page will still point to the old record.
// @todo - Ensure shortcodes are used with all images to prevent live records having broken links // @todo - Ensure shortcodes are used with all images to prevent live records having broken links
$file->doPublish(); $file->publishRecursive();
Versioned::set_stage(Versioned::DRAFT); Versioned::set_stage(Versioned::DRAFT);
$this->assertContains( $this->assertContains(
'<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file.jpg"', '<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file.jpg"',
@ -95,7 +95,7 @@ class FileLinkTrackingTest extends SapphireTest {
); );
// Publishing the page after publishing the asset should retain linking // Publishing the page after publishing the asset should retain linking
$page->doPublish(); $page->publishRecursive();
Versioned::set_stage(Versioned::DRAFT); Versioned::set_stage(Versioned::DRAFT);
$this->assertContains( $this->assertContains(
'<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file.jpg"', '<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file.jpg"',
@ -111,13 +111,13 @@ class FileLinkTrackingTest extends SapphireTest {
public function testFileLinkRewritingOnVirtualPages() { public function testFileLinkRewritingOnVirtualPages() {
// Publish the source page // Publish the source page
$page = $this->objFromFixture('Page', 'page1'); $page = $this->objFromFixture('Page', 'page1');
$this->assertTrue($page->doPublish()); $this->assertTrue($page->publishRecursive());
// Create a virtual page from it, and publish that // Create a virtual page from it, and publish that
$svp = new VirtualPage(); $svp = new VirtualPage();
$svp->CopyContentFromID = $page->ID; $svp->CopyContentFromID = $page->ID;
$svp->write(); $svp->write();
$svp->doPublish(); $svp->publishRecursive();
// Rename the file // Rename the file
$file = $this->objFromFixture('Image', 'file1'); $file = $this->objFromFixture('Image', 'file1');
@ -132,8 +132,8 @@ class FileLinkTrackingTest extends SapphireTest {
); );
// Publishing both file and page will update the live record // Publishing both file and page will update the live record
$file->doPublish(); $file->publishRecursive();
$page->doPublish(); $page->publishRecursive();
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
$this->assertContains( $this->assertContains(
@ -145,7 +145,7 @@ class FileLinkTrackingTest extends SapphireTest {
public function testLinkRewritingOnAPublishedPageDoesntMakeItEditedOnDraft() { public function testLinkRewritingOnAPublishedPageDoesntMakeItEditedOnDraft() {
// Publish the source page // Publish the source page
$page = $this->objFromFixture('Page', 'page1'); $page = $this->objFromFixture('Page', 'page1');
$this->assertTrue($page->doPublish()); $this->assertTrue($page->publishRecursive());
$this->assertFalse($page->getIsModifiedOnStage()); $this->assertFalse($page->getIsModifiedOnStage());
// Rename the file // Rename the file
@ -163,7 +163,7 @@ class FileLinkTrackingTest extends SapphireTest {
public function testTwoFileRenamesInARowWork() { public function testTwoFileRenamesInARowWork() {
$page = $this->objFromFixture('Page', 'page1'); $page = $this->objFromFixture('Page', 'page1');
$this->assertTrue($page->doPublish()); $this->assertTrue($page->publishRecursive());
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
$this->assertContains( $this->assertContains(
@ -182,7 +182,7 @@ class FileLinkTrackingTest extends SapphireTest {
$file = DataObject::get_by_id('File', $file->ID); $file = DataObject::get_by_id('File', $file->ID);
$file->Name = 'renamed-test-file-second-time.jpg'; $file->Name = 'renamed-test-file-second-time.jpg';
$file->write(); $file->write();
$file->doPublish(); $file->publishRecursive();
// Confirm that the correct image is shown in both the draft and live site // Confirm that the correct image is shown in both the draft and live site
Versioned::set_stage(Versioned::DRAFT); Versioned::set_stage(Versioned::DRAFT);
@ -192,7 +192,7 @@ class FileLinkTrackingTest extends SapphireTest {
); );
// Publishing this record also updates live record // Publishing this record also updates live record
$page->doPublish(); $page->publishRecursive();
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
$this->assertContains( $this->assertContains(
'<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file-second-time.jpg"', '<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file-second-time.jpg"',

View File

@ -25,7 +25,7 @@ class SiteTreeActionsTest extends FunctionalTest {
$page = new SiteTreeActionsTest_Page(); $page = new SiteTreeActionsTest_Page();
$page->CanEditType = 'LoggedInUsers'; $page->CanEditType = 'LoggedInUsers';
$page->write(); $page->write();
$page->doPublish(); $page->publishRecursive();
$actions = $page->getCMSActions(); $actions = $page->getCMSActions();
@ -47,7 +47,7 @@ class SiteTreeActionsTest extends FunctionalTest {
$page->CanEditType = 'LoggedInUsers'; $page->CanEditType = 'LoggedInUsers';
$page->write(); $page->write();
$pageID = $page->ID; $pageID = $page->ID;
$page->doPublish(); $page->publishRecursive();
$page->deleteFromStage('Stage'); $page->deleteFromStage('Stage');
// Get the live version of the page // Get the live version of the page
@ -76,7 +76,7 @@ class SiteTreeActionsTest extends FunctionalTest {
$page = new Page(); $page = new Page();
$page->CanEditType = 'LoggedInUsers'; $page->CanEditType = 'LoggedInUsers';
$page->write(); $page->write();
$page->doPublish(); $page->publishRecursive();
$actions = $page->getCMSActions(); $actions = $page->getCMSActions();
@ -99,7 +99,7 @@ class SiteTreeActionsTest extends FunctionalTest {
$page->CanEditType = 'LoggedInUsers'; $page->CanEditType = 'LoggedInUsers';
$page->write(); $page->write();
$pageID = $page->ID; $pageID = $page->ID;
$page->doPublish(); $page->publishRecursive();
$page->deleteFromStage('Stage'); $page->deleteFromStage('Stage');
// Get the live version of the page // Get the live version of the page
@ -126,7 +126,7 @@ class SiteTreeActionsTest extends FunctionalTest {
$page = new Page(); $page = new Page();
$page->CanEditType = 'LoggedInUsers'; $page->CanEditType = 'LoggedInUsers';
$page->write(); $page->write();
$page->doPublish(); $page->publishRecursive();
$page->Content = 'Changed on Stage'; $page->Content = 'Changed on Stage';
$page->write(); $page->write();
$page->flushCache(); $page->flushCache();

View File

@ -86,8 +86,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
// publish page 1 & 3 // publish page 1 & 3
$page1 = $this->objFromFixture('Page', 'page1'); $page1 = $this->objFromFixture('Page', 'page1');
$page3 = $this->objFromFixture('Page', 'page3'); $page3 = $this->objFromFixture('Page', 'page3');
$this->assertTrue($page1->doPublish()); $this->assertTrue($page1->publishRecursive());
$this->assertTrue($page3->doPublish()); $this->assertTrue($page3->publishRecursive());
// load pages from live // load pages from live
$page1live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page1->ID); $page1live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page1->ID);
@ -120,8 +120,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
$page1 = $this->objFromFixture('Page', 'page1'); $page1 = $this->objFromFixture('Page', 'page1');
$page3 = $this->objFromFixture('Page', 'page3'); $page3 = $this->objFromFixture('Page', 'page3');
$this->assertTrue($page1->doPublish()); $this->assertTrue($page1->publishRecursive());
$this->assertTrue($page3->doPublish()); $this->assertTrue($page3->publishRecursive());
// load page 3 from live // load page 3 from live
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID); $page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
@ -142,7 +142,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
// publish page 1 // publish page 1
$this->assertTrue($page1->doPublish()); $this->assertTrue($page1->publishRecursive());
// assert hyperlink to page 1's new published url exists // assert hyperlink to page 1's new published url exists
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID); $page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
@ -156,8 +156,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
// publish page 1 & 3 // publish page 1 & 3
$page1 = $this->objFromFixture('Page', 'page1'); $page1 = $this->objFromFixture('Page', 'page1');
$page3 = $this->objFromFixture('Page', 'page3'); $page3 = $this->objFromFixture('Page', 'page3');
$this->assertTrue($page1->doPublish()); $this->assertTrue($page1->publishRecursive());
$this->assertTrue($page3->doPublish()); $this->assertTrue($page3->publishRecursive());
// assert hyperlink to page 1's current url exists // assert hyperlink to page 1's current url exists
$links = HTTP::getLinksIn($page3->obj('Content')->forTemplate()); $links = HTTP::getLinksIn($page3->obj('Content')->forTemplate());
@ -175,7 +175,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
$this->assertContains(Director::baseURL().'new-url-segment/', $links, 'Assert hyperlink to page 1\'s current draft url exists on page 3'); $this->assertContains(Director::baseURL().'new-url-segment/', $links, 'Assert hyperlink to page 1\'s current draft url exists on page 3');
// publish page 3 // publish page 3
$this->assertTrue($page3->doPublish()); $this->assertTrue($page3->publishRecursive());
// assert page 3 on published site contains old page 1 url // assert page 3 on published site contains old page 1 url
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID); $page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
@ -184,7 +184,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
$this->assertContains(Director::baseURL().'page1/', $links, 'Assert hyperlink to page 1\'s current published url exists on page 3'); $this->assertContains(Director::baseURL().'page1/', $links, 'Assert hyperlink to page 1\'s current published url exists on page 3');
// publish page 1 // publish page 1
$this->assertTrue($page1->doPublish()); $this->assertTrue($page1->publishRecursive());
// assert page 3 on published site contains new page 1 url // assert page 3 on published site contains new page 1 url
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID); $page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
@ -195,8 +195,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
public function testLinkTrackingOnExtraContentFields() { public function testLinkTrackingOnExtraContentFields() {
$page1 = $this->objFromFixture('Page', 'page1'); $page1 = $this->objFromFixture('Page', 'page1');
$page2 = $this->objFromFixture('Page', 'page2'); $page2 = $this->objFromFixture('Page', 'page2');
$page1->doPublish(); $page1->publishRecursive();
$page2->doPublish(); $page2->publishRecursive();
// assert backlink to page 2 doesn't exist // assert backlink to page 2 doesn't exist
$this->assertNotContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 doesn\'t exist'); $this->assertNotContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 doesn\'t exist');
@ -204,7 +204,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
// add hyperlink to page 1 on page 2 // add hyperlink to page 1 on page 2
$page2->ExtraContent .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>'; $page2->ExtraContent .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>';
$page2->write(); $page2->write();
$page2->doPublish(); $page2->publishRecursive();
// assert backlink to page 2 exists // assert backlink to page 2 exists
$this->assertContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 exists'); $this->assertContains($page2->ID, $page1->BackLinkTracking()->column('ID'), 'Assert backlink to page 2 exists');
@ -227,7 +227,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
$this->assertEquals('<p><a href="'.Director::baseURL().'page1/">Testing page 1 link</a></p>', $page2Live->obj('ExtraContent')->forTemplate()); $this->assertEquals('<p><a href="'.Director::baseURL().'page1/">Testing page 1 link</a></p>', $page2Live->obj('ExtraContent')->forTemplate());
// publish page1 and confirm that the link on the published page2 has now been updated // publish page1 and confirm that the link on the published page2 has now been updated
$page1->doPublish(); $page1->publishRecursive();
$page2Live = Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = $page2->ID"); $page2Live = Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = $page2->ID");
$this->assertEquals('<p><a href="'.Director::baseURL().'page1-new-url/">Testing page 1 link</a></p>', $page2Live->obj('ExtraContent')->forTemplate()); $this->assertEquals('<p><a href="'.Director::baseURL().'page1-new-url/">Testing page 1 link</a></p>', $page2Live->obj('ExtraContent')->forTemplate());

View File

@ -86,7 +86,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$file->ID $file->ID
); );
$obj->write(); $obj->write();
$this->assertTrue($obj->doPublish()); $this->assertTrue($obj->publishRecursive());
// Confirm that it isn't marked as broken to begin with // Confirm that it isn't marked as broken to begin with
$obj->flushCache(); $obj->flushCache();
$obj = DataObject::get_by_id("SiteTree", $obj->ID); $obj = DataObject::get_by_id("SiteTree", $obj->ID);
@ -104,7 +104,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$this->assertEquals(1, $obj->HasBrokenFile); $this->assertEquals(1, $obj->HasBrokenFile);
// Publishing this page marks it as broken on live too // Publishing this page marks it as broken on live too
$obj->doPublish(); $obj->publishRecursive();
$liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $obj->ID"); $liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $obj->ID");
$this->assertEquals(1, $liveObj->HasBrokenFile); $this->assertEquals(1, $liveObj->HasBrokenFile);
} }
@ -146,7 +146,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$linkSrc->write(); $linkSrc->write();
// Publish the source of the link, while the dest is still unpublished. // Publish the source of the link, while the dest is still unpublished.
$linkSrc->doPublish(); $linkSrc->publishRecursive();
// Verify that the link isn't broken on draft but is broken on published // Verify that the link isn't broken on draft but is broken on published
$this->assertEquals(0, (int)$linkSrc->HasBrokenLink); $this->assertEquals(0, (int)$linkSrc->HasBrokenLink);
@ -161,14 +161,14 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$p->Title = "source"; $p->Title = "source";
$p->write(); $p->write();
$pageID = $p->ID; $pageID = $p->ID;
$this->assertTrue($p->doPublish()); $this->assertTrue($p->publishRecursive());
// Content links are one kind of link to pages // Content links are one kind of link to pages
$p2 = new Page(); $p2 = new Page();
$p2->Title = "regular link"; $p2->Title = "regular link";
$p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>"; $p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
$p2->write(); $p2->write();
$this->assertTrue($p2->doPublish()); $this->assertTrue($p2->publishRecursive());
// Virtual pages are another // Virtual pages are another
$vp = new VirtualPage(); $vp = new VirtualPage();
@ -181,7 +181,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$rp->LinkType = 'Internal'; $rp->LinkType = 'Internal';
$rp->LinkToID = $p->ID; $rp->LinkToID = $p->ID;
$rp->write(); $rp->write();
$this->assertTrue($rp->doPublish()); $this->assertTrue($rp->publishRecursive());
// Confirm that there are no broken links to begin with // Confirm that there are no broken links to begin with
$this->assertFalse($p2->HasBrokenLink); $this->assertFalse($p2->HasBrokenLink);
@ -222,7 +222,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$this->assertFalse((bool)$rp->HasBrokenLink); $this->assertFalse((bool)$rp->HasBrokenLink);
// Publish and confirm that the p2 and RP broken links are fixed on published // Publish and confirm that the p2 and RP broken links are fixed on published
$this->assertTrue($p->doPublish()); $this->assertTrue($p->publishRecursive());
$p2Live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID); $p2Live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID);
$rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID); $rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID);
$this->assertFalse((bool)$p2Live->HasBrokenLink); $this->assertFalse((bool)$p2Live->HasBrokenLink);
@ -236,14 +236,14 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$p->Title = "source"; $p->Title = "source";
$p->write(); $p->write();
$pageID = $p->ID; $pageID = $p->ID;
$this->assertTrue($p->doPublish()); $this->assertTrue($p->publishRecursive());
// Content links are one kind of link to pages // Content links are one kind of link to pages
$p2 = new Page(); $p2 = new Page();
$p2->Title = "regular link"; $p2->Title = "regular link";
$p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>"; $p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
$p2->write(); $p2->write();
$this->assertTrue($p2->doPublish()); $this->assertTrue($p2->publishRecursive());
// Virtual pages are another // Virtual pages are another
$vp = new VirtualPage(); $vp = new VirtualPage();
@ -256,7 +256,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
$rp->LinkType = 'Internal'; $rp->LinkType = 'Internal';
$rp->LinkToID = $p->ID; $rp->LinkToID = $p->ID;
$rp->write(); $rp->write();
$this->assertTrue($rp->doPublish()); $this->assertTrue($rp->publishRecursive());
// Confirm that there are no broken links to begin with // Confirm that there are no broken links to begin with
$this->assertFalse($p2->HasBrokenLink); $this->assertFalse($p2->HasBrokenLink);

View File

@ -68,7 +68,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
$this->logInWithPermission("ADMIN"); $this->logInWithPermission("ADMIN");
$page = $this->objFromFixture('Page','restrictedEditOnlySubadminGroup'); $page = $this->objFromFixture('Page','restrictedEditOnlySubadminGroup');
$pageID = $page->ID; $pageID = $page->ID;
$this->assertTrue($page->doPublish()); $this->assertTrue($page->publishRecursive());
$page->delete(); $page->delete();
// Re-fetch the page from the live site // Re-fetch the page from the live site
@ -134,7 +134,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
// Get page & make sure it exists on Live // Get page & make sure it exists on Live
$page = $this->objFromFixture('Page', 'standardpage'); $page = $this->objFromFixture('Page', 'standardpage');
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
// Then make sure there's a new version on Stage // Then make sure there's a new version on Stage
$page->Title = 1; $page->Title = 1;
@ -382,7 +382,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
$this->logInWithPermission("ADMIN"); $this->logInWithPermission("ADMIN");
$page->doPublish(); $page->publishRecursive();
$page->deleteFromStage('Stage'); $page->deleteFromStage('Stage');
// Get the live version of the page // Get the live version of the page

View File

@ -82,7 +82,7 @@ class SiteTreeTest extends SapphireTest {
*/ */
public function testPublishCopiesToLiveTable() { public function testPublishCopiesToLiveTable() {
$obj = $this->objFromFixture('Page','about'); $obj = $this->objFromFixture('Page','about');
$obj->publish('Stage', 'Live'); $obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$createdID = DB::query("SELECT \"ID\" FROM \"SiteTree_Live\" WHERE \"URLSegment\" = '$obj->URLSegment'")->value(); $createdID = DB::query("SELECT \"ID\" FROM \"SiteTree_Live\" WHERE \"URLSegment\" = '$obj->URLSegment'")->value();
$this->assertEquals($obj->ID, $createdID); $this->assertEquals($obj->ID, $createdID);
@ -97,13 +97,13 @@ class SiteTreeTest extends SapphireTest {
$obj = $this->objFromFixture('Page', 'about'); $obj = $this->objFromFixture('Page', 'about');
$obj->Title = "asdfasdf"; $obj->Title = "asdfasdf";
$obj->write(); $obj->write();
$this->assertTrue($obj->doPublish()); $this->assertTrue($obj->publishRecursive());
$this->assertEquals('asdfasdf', DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = '$obj->ID'")->value()); $this->assertEquals('asdfasdf', DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = '$obj->ID'")->value());
$obj->Title = null; $obj->Title = null;
$obj->write(); $obj->write();
$this->assertTrue($obj->doPublish()); $this->assertTrue($obj->publishRecursive());
$this->assertNull(DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = '$obj->ID'")->value()); $this->assertNull(DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = '$obj->ID'")->value());
@ -136,7 +136,7 @@ class SiteTreeTest extends SapphireTest {
$s->Title = "V1"; $s->Title = "V1";
$s->URLSegment = "get-one-test-page"; $s->URLSegment = "get-one-test-page";
$s->write(); $s->write();
$s->publish("Stage", "Live"); $s->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$s->Title = "V2"; $s->Title = "V2";
$s->write(); $s->write();
@ -153,7 +153,7 @@ class SiteTreeTest extends SapphireTest {
public function testChidrenOfRootAreTopLevelPages() { public function testChidrenOfRootAreTopLevelPages() {
$pages = SiteTree::get(); $pages = SiteTree::get();
foreach($pages as $page) $page->publish('Stage', 'Live'); foreach($pages as $page) $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
unset($pages); unset($pages);
/* If we create a new SiteTree object with ID = 0 */ /* If we create a new SiteTree object with ID = 0 */
@ -201,7 +201,7 @@ class SiteTreeTest extends SapphireTest {
// published page // published page
$publishedPage = new SiteTree(); $publishedPage = new SiteTree();
$publishedPage->write(); $publishedPage->write();
$publishedPage->publish('Stage','Live'); $publishedPage->copyVersionToStage('Stage','Live');
$this->assertFalse($publishedPage->getIsDeletedFromStage()); $this->assertFalse($publishedPage->getIsDeletedFromStage());
$this->assertFalse($publishedPage->getIsAddedToStage()); $this->assertFalse($publishedPage->getIsAddedToStage());
$this->assertFalse($publishedPage->getIsModifiedOnStage()); $this->assertFalse($publishedPage->getIsModifiedOnStage());
@ -210,7 +210,7 @@ class SiteTreeTest extends SapphireTest {
$deletedFromDraftPage = new SiteTree(); $deletedFromDraftPage = new SiteTree();
$deletedFromDraftPage->write(); $deletedFromDraftPage->write();
$deletedFromDraftPageID = $deletedFromDraftPage->ID; $deletedFromDraftPageID = $deletedFromDraftPage->ID;
$deletedFromDraftPage->publish('Stage','Live'); $deletedFromDraftPage->copyVersionToStage('Stage','Live');
$deletedFromDraftPage->deleteFromStage('Stage'); $deletedFromDraftPage->deleteFromStage('Stage');
$this->assertTrue($deletedFromDraftPage->getIsDeletedFromStage()); $this->assertTrue($deletedFromDraftPage->getIsDeletedFromStage());
$this->assertFalse($deletedFromDraftPage->getIsAddedToStage()); $this->assertFalse($deletedFromDraftPage->getIsAddedToStage());
@ -219,7 +219,7 @@ class SiteTreeTest extends SapphireTest {
// published page, deleted from live // published page, deleted from live
$deletedFromLivePage = new SiteTree(); $deletedFromLivePage = new SiteTree();
$deletedFromLivePage->write(); $deletedFromLivePage->write();
$deletedFromLivePage->publish('Stage','Live'); $deletedFromLivePage->copyVersionToStage('Stage','Live');
$deletedFromLivePage->deleteFromStage('Stage'); $deletedFromLivePage->deleteFromStage('Stage');
$deletedFromLivePage->deleteFromStage('Live'); $deletedFromLivePage->deleteFromStage('Live');
$this->assertTrue($deletedFromLivePage->getIsDeletedFromStage()); $this->assertTrue($deletedFromLivePage->getIsDeletedFromStage());
@ -229,7 +229,7 @@ class SiteTreeTest extends SapphireTest {
// published page, modified // published page, modified
$modifiedOnDraftPage = new SiteTree(); $modifiedOnDraftPage = new SiteTree();
$modifiedOnDraftPage->write(); $modifiedOnDraftPage->write();
$modifiedOnDraftPage->publish('Stage','Live'); $modifiedOnDraftPage->copyVersionToStage('Stage','Live');
$modifiedOnDraftPage->Content = 'modified'; $modifiedOnDraftPage->Content = 'modified';
$modifiedOnDraftPage->write(); $modifiedOnDraftPage->write();
$this->assertFalse($modifiedOnDraftPage->getIsDeletedFromStage()); $this->assertFalse($modifiedOnDraftPage->getIsDeletedFromStage());
@ -331,10 +331,10 @@ class SiteTreeTest extends SapphireTest {
Config::inst()->update('SiteTree', 'nested_urls', true); Config::inst()->update('SiteTree', 'nested_urls', true);
$child->publish('Stage', 'Live'); $child->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$parent->URLSegment = 'changed-on-live'; $parent->URLSegment = 'changed-on-live';
$parent->write(); $parent->write();
$parent->publish('Stage', 'Live'); $parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$parent->URLSegment = 'changed-on-draft'; $parent->URLSegment = 'changed-on-draft';
$parent->write(); $parent->write();
@ -373,11 +373,11 @@ class SiteTreeTest extends SapphireTest {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about'); $pageAbout = $this->objFromFixture('Page', 'about');
$pageAbout->doPublish(); $pageAbout->publishRecursive();
$pageStaff = $this->objFromFixture('Page', 'staff'); $pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaff->doPublish(); $pageStaff->publishRecursive();
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate'); $pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
$pageStaffDuplicate->doPublish(); $pageStaffDuplicate->publishRecursive();
$parentPage = $this->objFromFixture('Page', 'about'); $parentPage = $this->objFromFixture('Page', 'about');
@ -397,11 +397,11 @@ class SiteTreeTest extends SapphireTest {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about'); $pageAbout = $this->objFromFixture('Page', 'about');
$pageAbout->doPublish(); $pageAbout->publishRecursive();
$pageStaff = $this->objFromFixture('Page', 'staff'); $pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaff->doPublish(); $pageStaff->publishRecursive();
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate'); $pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
$pageStaffDuplicate->doPublish(); $pageStaffDuplicate->publishRecursive();
$parentPage = $this->objFromFixture('Page', 'about'); $parentPage = $this->objFromFixture('Page', 'about');
$parentPage->doUnpublish(); $parentPage->doUnpublish();
@ -418,11 +418,11 @@ class SiteTreeTest extends SapphireTest {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about'); $pageAbout = $this->objFromFixture('Page', 'about');
$pageAbout->doPublish(); $pageAbout->publishRecursive();
$pageStaff = $this->objFromFixture('Page', 'staff'); $pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaff->doPublish(); $pageStaff->publishRecursive();
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate'); $pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
$pageStaffDuplicate->doPublish(); $pageStaffDuplicate->publishRecursive();
$parentPage = $this->objFromFixture('Page', 'about'); $parentPage = $this->objFromFixture('Page', 'about');
$parentPage->doUnpublish(); $parentPage->doUnpublish();
@ -519,7 +519,7 @@ class SiteTreeTest extends SapphireTest {
$page = new Page(); $page = new Page();
$page->write(); $page->write();
$page->CanEditType = "Inherit"; $page->CanEditType = "Inherit";
$page->doPublish(); $page->publishRecursive();
$pageID = $page->ID; $pageID = $page->ID;
// Lock down the site config // Lock down the site config
@ -546,7 +546,7 @@ class SiteTreeTest extends SapphireTest {
// Publish the changes to the page // Publish the changes to the page
$this->objFromFixture('Member','admin')->logIn(); $this->objFromFixture('Member','admin')->logIn();
$page->doPublish(); $page->publishRecursive();
// Confirm that Member.editor can still edit the page // Confirm that Member.editor can still edit the page
$this->objFromFixture('Member','editor')->logIn(); $this->objFromFixture('Member','editor')->logIn();
@ -601,7 +601,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertEquals(0, $savedVersion['PublisherID']); $this->assertEquals(0, $savedVersion['PublisherID']);
// Publish the page // Publish the page
$about->doPublish(); $about->publishRecursive();
$publishedVersion = DB::query("SELECT \"AuthorID\", \"PublisherID\" FROM \"SiteTree_versions\" $publishedVersion = DB::query("SELECT \"AuthorID\", \"PublisherID\" FROM \"SiteTree_versions\"
WHERE \"RecordID\" = $about->ID ORDER BY \"Version\" DESC")->first(); WHERE \"RecordID\" = $about->ID ORDER BY \"Version\" DESC")->first();
@ -834,7 +834,7 @@ class SiteTreeTest extends SapphireTest {
$sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false); $sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false);
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen')); $this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
$sitetree->publish('Stage', 'Live'); $sitetree->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false); $sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false);
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen')); $this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
$sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false); $sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
@ -1124,7 +1124,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertTrue($staff->canView($member)); $this->assertTrue($staff->canView($member));
// Publishing only the child page to live should orphan the live record, but not the staging one // Publishing only the child page to live should orphan the live record, but not the staging one
$staff->publish('Stage', 'Live'); $staff->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$this->assertFalse($staff->isOrphaned()); $this->assertFalse($staff->isOrphaned());
$this->assertTrue($staff->canView($member)); $this->assertTrue($staff->canView($member));
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
@ -1135,7 +1135,7 @@ class SiteTreeTest extends SapphireTest {
// Publishing the parent page should restore visibility // Publishing the parent page should restore visibility
Versioned::set_stage(Versioned::DRAFT); Versioned::set_stage(Versioned::DRAFT);
$about = $this->objFromFixture('Page', 'about'); $about = $this->objFromFixture('Page', 'about');
$about->publish('Stage', 'Live'); $about->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
$staff = $this->objFromFixture('Page', 'staff'); $staff = $this->objFromFixture('Page', 'staff');
$this->assertFalse($staff->isOrphaned()); $this->assertFalse($staff->isOrphaned());
@ -1165,7 +1165,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertFalse($page->isPublished()); $this->assertFalse($page->isPublished());
// Publish // Publish
$page->doPublish(); $page->publishRecursive();
$this->assertTrue($page->canAddChildren()); $this->assertTrue($page->canAddChildren());
$this->assertFalse($page->getIsDeletedFromStage()); $this->assertFalse($page->getIsDeletedFromStage());
$this->assertTrue($page->isPublished()); $this->assertTrue($page->isPublished());

View File

@ -67,7 +67,7 @@ class VirtualPageTest extends FunctionalTest {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$master = $this->objFromFixture('Page', 'master'); $master = $this->objFromFixture('Page', 'master');
$master->doPublish(); $master->publishRecursive();
$master->Title = "New title"; $master->Title = "New title";
$master->MenuTitle = "New menutitle"; $master->MenuTitle = "New menutitle";
@ -76,10 +76,10 @@ class VirtualPageTest extends FunctionalTest {
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1')); $vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2')); $vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2'));
$this->assertTrue($vp1->doPublish()); $this->assertTrue($vp1->publishRecursive());
$this->assertTrue($vp2->doPublish()); $this->assertTrue($vp2->publishRecursive());
$master->doPublish(); $master->publishRecursive();
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1')); $vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
@ -126,14 +126,14 @@ class VirtualPageTest extends FunctionalTest {
$p = new Page(); $p = new Page();
$p->Content = "published content"; $p->Content = "published content";
$p->write(); $p->write();
$p->doPublish(); $p->publishRecursive();
// Virtual page has this content // Virtual page has this content
$vp = new VirtualPage(); $vp = new VirtualPage();
$vp->CopyContentFromID = $p->ID; $vp->CopyContentFromID = $p->ID;
$vp->write(); $vp->write();
$vp->doPublish(); $vp->publishRecursive();
// Don't publish this change - published page will still say 'published content' // Don't publish this change - published page will still say 'published content'
$p->Content = "draft content"; $p->Content = "draft content";
@ -152,7 +152,7 @@ class VirtualPageTest extends FunctionalTest {
$this->assertEquals('published content', $vpLive->Content); $this->assertEquals('published content', $vpLive->Content);
// Publishing the virtualpage should, however, trigger publishing of the live page // Publishing the virtualpage should, however, trigger publishing of the live page
$vpDraft->doPublish(); $vpDraft->publishRecursive();
// Everything is published live // Everything is published live
$vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID); $vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID);
@ -177,7 +177,7 @@ class VirtualPageTest extends FunctionalTest {
$this->assertFalse($vp->canPublish()); $this->assertFalse($vp->canPublish());
// Once the source page gets published, then we can publish // Once the source page gets published, then we can publish
$p->doPublish(); $p->publishRecursive();
$this->assertTrue($vp->canPublish()); $this->assertTrue($vp->canPublish());
} }
@ -186,14 +186,14 @@ class VirtualPageTest extends FunctionalTest {
$p = new Page(); $p = new Page();
$p->Content = "test content"; $p->Content = "test content";
$p->write(); $p->write();
$p->doPublish(); $p->publishRecursive();
$pID = $p->ID; $pID = $p->ID;
$vp = new VirtualPage(); $vp = new VirtualPage();
$vp->CopyContentFromID = $p->ID; $vp->CopyContentFromID = $p->ID;
$vp->write(); $vp->write();
$this->assertTrue($vp->canPublish()); $this->assertTrue($vp->canPublish());
$this->assertTrue($vp->doPublish()); $this->assertTrue($vp->publishRecursive());
// Delete the source page semi-manually, without triggering // Delete the source page semi-manually, without triggering
// the cascade publish back to the virtual page. // the cascade publish back to the virtual page.
@ -238,9 +238,9 @@ class VirtualPageTest extends FunctionalTest {
public function testCanView() { public function testCanView() {
$parentPage = $this->objFromFixture('Page', 'master3'); $parentPage = $this->objFromFixture('Page', 'master3');
$parentPage->publish('Stage', 'Live'); $parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3'); $virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
$virtualPage->publish('Stage', 'Live'); $virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$cindy = $this->objFromFixture('Member', 'cindy'); $cindy = $this->objFromFixture('Member', 'cindy');
$alice = $this->objFromFixture('Member', 'alice'); $alice = $this->objFromFixture('Member', 'alice');
@ -268,7 +268,7 @@ class VirtualPageTest extends FunctionalTest {
$this->assertTrue($vp->getIsAddedToStage()); $this->assertTrue($vp->getIsAddedToStage());
// VP is still orange after we publish // VP is still orange after we publish
$p->doPublish(); $p->publishRecursive();
$this->assertTrue($vp->getIsAddedToStage()); $this->assertTrue($vp->getIsAddedToStage());
// A new VP created after P's initial construction // A new VP created after P's initial construction
@ -280,11 +280,11 @@ class VirtualPageTest extends FunctionalTest {
// Also remains orange after a republish // Also remains orange after a republish
$p->Content = "new content"; $p->Content = "new content";
$p->write(); $p->write();
$p->doPublish(); $p->publishRecursive();
$this->assertTrue($vp2->getIsAddedToStage()); $this->assertTrue($vp2->getIsAddedToStage());
// VP is now published // VP is now published
$vp->doPublish(); $vp->publishRecursive();
$this->assertTrue($vp->getExistsOnLive()); $this->assertTrue($vp->getExistsOnLive());
$this->assertFalse($vp->getIsModifiedOnStage()); $this->assertFalse($vp->getIsModifiedOnStage());
@ -298,7 +298,7 @@ class VirtualPageTest extends FunctionalTest {
$this->assertFalse($vp->getIsModifiedOnStage()); $this->assertFalse($vp->getIsModifiedOnStage());
// Publish, VP goes black // Publish, VP goes black
$p->doPublish(); $p->publishRecursive();
$this->assertTrue($vp->getExistsOnLive()); $this->assertTrue($vp->getExistsOnLive());
$this->assertFalse($vp->getIsModifiedOnStage()); $this->assertFalse($vp->getIsModifiedOnStage());
} }
@ -308,11 +308,11 @@ class VirtualPageTest extends FunctionalTest {
$p = new Page(); $p = new Page();
$p->Title = "source"; $p->Title = "source";
$p->write(); $p->write();
$this->assertTrue($p->doPublish()); $this->assertTrue($p->publishRecursive());
$vp = new VirtualPage(); $vp = new VirtualPage();
$vp->CopyContentFromID = $p->ID; $vp->CopyContentFromID = $p->ID;
$vp->write(); $vp->write();
$this->assertTrue($vp->doPublish()); $this->assertTrue($vp->publishRecursive());
// All is fine, the virtual page doesn't have a broken link // All is fine, the virtual page doesn't have a broken link
$this->assertFalse($vp->HasBrokenLink); $this->assertFalse($vp->HasBrokenLink);
@ -340,11 +340,11 @@ class VirtualPageTest extends FunctionalTest {
$p = new Page(); $p = new Page();
$p->Title = "source"; $p->Title = "source";
$p->write(); $p->write();
$this->assertTrue($p->doPublish()); $this->assertTrue($p->publishRecursive());
$vp = new VirtualPage(); $vp = new VirtualPage();
$vp->CopyContentFromID = $p->ID; $vp->CopyContentFromID = $p->ID;
$vp->write(); $vp->write();
$this->assertTrue($vp->doPublish()); $this->assertTrue($vp->publishRecursive());
// All is fine, the virtual page doesn't have a broken link // All is fine, the virtual page doesn't have a broken link
$this->assertFalse($vp->HasBrokenLink); $this->assertFalse($vp->HasBrokenLink);
@ -478,13 +478,13 @@ class VirtualPageTest extends FunctionalTest {
$page->Title = 'published title'; $page->Title = 'published title';
$page->MySharedNonVirtualField = 'original'; $page->MySharedNonVirtualField = 'original';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$virtual = new VirtualPageTest_VirtualPageSub(); $virtual = new VirtualPageTest_VirtualPageSub();
$virtual->CopyContentFromID = $page->ID; $virtual->CopyContentFromID = $page->ID;
$virtual->MySharedNonVirtualField = 'virtual published field'; $virtual->MySharedNonVirtualField = 'virtual published field';
$virtual->write(); $virtual->write();
$virtual->publish('Stage', 'Live'); $virtual->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page->Title = 'original'; // 'Title' is a virtual field $page->Title = 'original'; // 'Title' is a virtual field
// Publication would causes the virtual field to copy through onBeforeWrite(), // Publication would causes the virtual field to copy through onBeforeWrite(),
@ -517,7 +517,7 @@ class VirtualPageTest extends FunctionalTest {
$page->Title = 'title changed on original'; $page->Title = 'title changed on original';
$page->MySharedNonVirtualField = 'changed only on original'; $page->MySharedNonVirtualField = 'changed only on original';
$page->write(); $page->write();
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
// Virtual page only notices changes to virtualised fields (Title) // Virtual page only notices changes to virtualised fields (Title)
$virtualLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false); $virtualLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
@ -584,11 +584,11 @@ class VirtualPageTest extends FunctionalTest {
$rp = new RedirectorPage(array('ExternalURL' => 'http://google.com', 'RedirectionType' => 'External')); $rp = new RedirectorPage(array('ExternalURL' => 'http://google.com', 'RedirectionType' => 'External'));
$rp->write(); $rp->write();
$rp->doPublish(); $rp->publishRecursive();
$vp = new VirtualPage(array('URLSegment' => 'vptest', 'CopyContentFromID' => $rp->ID)); $vp = new VirtualPage(array('URLSegment' => 'vptest', 'CopyContentFromID' => $rp->ID));
$vp->write(); $vp->write();
$vp->doPublish(); $vp->publishRecursive();
$response = $this->get($vp->Link()); $response = $this->get($vp->Link());
$this->assertEquals(301, $response->getStatusCode()); $this->assertEquals(301, $response->getStatusCode());

View File

@ -75,7 +75,7 @@ class ZZZSearchFormTest extends FunctionalTest {
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
$publishedPage->publish('Stage', 'Live'); $publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$this->waitUntilIndexingFinished(); $this->waitUntilIndexingFinished();
$results = $sf->getResults(null, array('Search'=>'publicPublishedPage')); $results = $sf->getResults(null, array('Search'=>'publicPublishedPage'));
@ -94,7 +94,7 @@ class ZZZSearchFormTest extends FunctionalTest {
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
$publishedPage->Title = "finding butterflies"; $publishedPage->Title = "finding butterflies";
$publishedPage->write(); $publishedPage->write();
$publishedPage->publish('Stage', 'Live'); $publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$this->waitUntilIndexingFinished(); $this->waitUntilIndexingFinished();
$results = $sf->getResults(null, array('Search'=>'"finding butterflies"')); $results = $sf->getResults(null, array('Search'=>'"finding butterflies"'));
@ -125,7 +125,7 @@ class ZZZSearchFormTest extends FunctionalTest {
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers'); $page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers')); $results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
$this->assertNotContains( $this->assertNotContains(
$page->ID, $page->ID,
@ -150,7 +150,7 @@ class ZZZSearchFormTest extends FunctionalTest {
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers'); $page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers')); $results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
$this->assertNotContains( $this->assertNotContains(
$page->ID, $page->ID,
@ -183,10 +183,10 @@ class ZZZSearchFormTest extends FunctionalTest {
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers'); $parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
$parent->publish('Stage', 'Live'); $parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView'); $page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
$page->publish('Stage', 'Live'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView')); $results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
$this->assertNotContains( $this->assertNotContains(
$page->ID, $page->ID,
@ -225,9 +225,9 @@ class ZZZSearchFormTest extends FunctionalTest {
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile'); $dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
$dontShowInSearchFile->publish('Stage', 'Live'); $dontShowInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$showInSearchFile = $this->objFromFixture('File', 'showInSearchFile'); $showInSearchFile = $this->objFromFixture('File', 'showInSearchFile');
$showInSearchFile->publish('Stage', 'Live'); $showInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$results = $sf->getResults(null, array('Search'=>'dontShowInSearchFile')); $results = $sf->getResults(null, array('Search'=>'dontShowInSearchFile'));
$this->assertNotContains( $this->assertNotContains(
@ -254,7 +254,7 @@ class ZZZSearchFormTest extends FunctionalTest {
$sf = new SearchForm($this->mockController, 'SearchForm'); $sf = new SearchForm($this->mockController, 'SearchForm');
$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars'); $pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');
$pageWithSpecialChars->publish('Stage', 'Live'); $pageWithSpecialChars->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$results = $sf->getResults(null, array('Search'=>'Brötchen')); $results = $sf->getResults(null, array('Search'=>'Brötchen'));
$this->assertContains( $this->assertContains(

View File

@ -40,13 +40,13 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest {
parent::setUp(); parent::setUp();
$parent1_published = $this->objFromFixture('Page', 'parent1_published'); $parent1_published = $this->objFromFixture('Page', 'parent1_published');
$parent1_published->publish('Stage', 'Live'); $parent1_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$child1_1_published = $this->objFromFixture('Page', 'child1_1_published'); $child1_1_published = $this->objFromFixture('Page', 'child1_1_published');
$child1_1_published->publish('Stage', 'Live'); $child1_1_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$child1_2_published = $this->objFromFixture('Page', 'child1_2_published'); $child1_2_published = $this->objFromFixture('Page', 'child1_2_published');
$child1_2_published->publish('Stage', 'Live'); $child1_2_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$child1_3_orphaned = $this->objFromFixture('Page', 'child1_3_orphaned'); $child1_3_orphaned = $this->objFromFixture('Page', 'child1_3_orphaned');
$child1_3_orphaned->ParentID = 9999; $child1_3_orphaned->ParentID = 9999;
@ -55,10 +55,10 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest {
$child1_4_orphaned_published = $this->objFromFixture('Page', 'child1_4_orphaned_published'); $child1_4_orphaned_published = $this->objFromFixture('Page', 'child1_4_orphaned_published');
$child1_4_orphaned_published->ParentID = 9999; $child1_4_orphaned_published->ParentID = 9999;
$child1_4_orphaned_published->write(); $child1_4_orphaned_published->write();
$child1_4_orphaned_published->publish('Stage', 'Live'); $child1_4_orphaned_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$grandchild1_1_2_published = $this->objFromFixture('Page', 'grandchild1_1_2_published'); $grandchild1_1_2_published = $this->objFromFixture('Page', 'grandchild1_1_2_published');
$grandchild1_1_2_published->publish('Stage', 'Live'); $grandchild1_1_2_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$grandchild1_1_3_orphaned = $this->objFromFixture('Page', 'grandchild1_1_3_orphaned'); $grandchild1_1_3_orphaned = $this->objFromFixture('Page', 'grandchild1_1_3_orphaned');
$grandchild1_1_3_orphaned->ParentID = 9999; $grandchild1_1_3_orphaned->ParentID = 9999;
@ -69,10 +69,10 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest {
); );
$grandchild1_1_4_orphaned_published->ParentID = 9999; $grandchild1_1_4_orphaned_published->ParentID = 9999;
$grandchild1_1_4_orphaned_published->write(); $grandchild1_1_4_orphaned_published->write();
$grandchild1_1_4_orphaned_published->publish('Stage', 'Live'); $grandchild1_1_4_orphaned_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$child2_1_published_orphaned = $this->objFromFixture('Page', 'child2_1_published_orphaned'); $child2_1_published_orphaned = $this->objFromFixture('Page', 'child2_1_published_orphaned');
$child2_1_published_orphaned->publish('Stage', 'Live'); $child2_1_published_orphaned->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
} }
public function testGetOrphansByStage() { public function testGetOrphansByStage() {