mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1435 from open-sausages/pulls/4.0/changesets
API Support new DataObject::can() signature
This commit is contained in:
commit
9384aed9fc
@ -11,7 +11,7 @@ class CMSBatchAction_Publish extends CMSBatchAction {
|
||||
}
|
||||
|
||||
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')
|
||||
);
|
||||
}
|
||||
|
@ -909,7 +909,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
// If the 'Save & Publish' button was clicked, also publish the page
|
||||
if ($doPublish) {
|
||||
$record->doPublish();
|
||||
$record->publishRecursive();
|
||||
$message = _t(
|
||||
'CMSMain.PUBLISHED',
|
||||
"Published '{title}' successfully.",
|
||||
@ -989,7 +989,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
return Security::permissionFailure($this);
|
||||
}
|
||||
|
||||
$record->doPublish();
|
||||
$record->publishRecursive();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1278,9 +1278,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$count = 0;
|
||||
while($pages) {
|
||||
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();
|
||||
unset($page);
|
||||
$count++;
|
||||
|
@ -110,7 +110,7 @@ class ErrorPage extends Page {
|
||||
if(!$pageExists) {
|
||||
$page = new ErrorPage($defaultData);
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
}
|
||||
|
||||
// Check if static files are enabled
|
||||
@ -227,8 +227,10 @@ class ErrorPage extends Page {
|
||||
*
|
||||
* @return bool True if published
|
||||
*/
|
||||
public function doPublish() {
|
||||
if (!parent::doPublish()) return false;
|
||||
public function publishSingle() {
|
||||
if (!parent::publishSingle()) {
|
||||
return false;
|
||||
}
|
||||
return $this->writeStaticPage();
|
||||
}
|
||||
|
||||
|
@ -760,6 +760,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
*
|
||||
* @param string $perm The permission to be checked, such as 'View'
|
||||
* @param Member $member The member whose permissions need checking. Defaults to the currently logged in user.
|
||||
* @param array $context Context argument for canCreate()
|
||||
* @return bool True if the the member is allowed to do the given action
|
||||
*/
|
||||
public function can($perm, $member = null, $context = array()) {
|
||||
@ -1103,7 +1104,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
|
||||
$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
|
||||
$table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage";
|
||||
|
||||
@ -1354,7 +1355,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
$homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link');
|
||||
$homepage->Sort = 1;
|
||||
$homepage->write();
|
||||
$homepage->publish('Stage', 'Live');
|
||||
$homepage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$homepage->flushCache();
|
||||
DB::alteration_message('Home page created', 'created');
|
||||
}
|
||||
@ -1365,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->Sort = 2;
|
||||
$aboutus->write();
|
||||
$aboutus->publish('Stage', 'Live');
|
||||
$aboutus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$aboutus->flushCache();
|
||||
DB::alteration_message('About Us page created', 'created');
|
||||
|
||||
@ -1374,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->Sort = 3;
|
||||
$contactus->write();
|
||||
$contactus->publish('Stage', 'Live');
|
||||
$contactus->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$contactus->flushCache();
|
||||
DB::alteration_message('Contact Us page created', 'created');
|
||||
}
|
||||
@ -2047,7 +2048,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
* @return FieldList The available actions for this page.
|
||||
*/
|
||||
public function getCMSActions() {
|
||||
$existsOnLive = $this->getExistsOnLive();
|
||||
$existsOnLive = $this->isPublished();
|
||||
|
||||
// Major actions appear as buttons immediately visible as page actions.
|
||||
$majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset noborder');
|
||||
@ -2099,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()) {
|
||||
// "rollback"
|
||||
$moreOptions->push(
|
||||
@ -2180,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.
|
||||
if($this->stagesDiffer('Stage', 'Live')) {
|
||||
if($this->stagesDiffer(Versioned::DRAFT, Versioned::LIVE)) {
|
||||
$publish->addExtraClass('ss-ui-alternate');
|
||||
}
|
||||
}
|
||||
@ -2441,7 +2442,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
if(!$this->_cache_statusFlags || !$cached) {
|
||||
$flags = array();
|
||||
if($this->getIsDeletedFromStage()) {
|
||||
if($this->getExistsOnLive()) {
|
||||
if($this->isPublished()) {
|
||||
$flags['removedfromdraft'] = array(
|
||||
'text' => _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft'),
|
||||
'title' => _t('SiteTree.REMOVEDFROMDRAFTHELP', 'Page is published, but has been deleted from draft'),
|
||||
@ -2586,7 +2587,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
if(!$this->ID) return true;
|
||||
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 !($stageVersion);
|
||||
@ -2598,7 +2599,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
* @return bool
|
||||
*/
|
||||
public function getExistsOnLive() {
|
||||
return (bool)Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID);
|
||||
return $this->isPublished();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,7 +9,7 @@
|
||||
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
|
||||
*/
|
||||
@ -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
|
||||
*/
|
||||
@ -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() {
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ in the other stage:<br />
|
||||
$where[] = '"Parents"."ID" IS NULL';
|
||||
|
||||
$orphans = new ArrayList();
|
||||
foreach(array('Stage', 'Live') as $stage) {
|
||||
foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
|
||||
$joinByStage = $join;
|
||||
$table = $class;
|
||||
$table .= ($stage == 'Live') ? '_Live' : '';
|
||||
|
@ -40,7 +40,8 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte
|
||||
foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
|
||||
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
|
||||
$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);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
|
||||
if (!$targetObj) $targetObj = $this->fixtureFactory->get($targetClass, $targetId);
|
||||
|
||||
$fields = array('LinkToID' => $targetObj->ID);
|
||||
/** @var \RedirectorPage $obj */
|
||||
$obj = $this->fixtureFactory->get($class, $id);
|
||||
if ($obj) {
|
||||
$obj->update($fields);
|
||||
@ -38,7 +39,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext
|
||||
$obj = $this->fixtureFactory->createObject($class, $id, $fields);
|
||||
}
|
||||
$obj->write();
|
||||
$obj->publish('Stage', 'Live');
|
||||
$obj->copyVersionToStage(\Versioned::DRAFT, \Versioned::LIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ class AssetAdminTest extends SapphireTest {
|
||||
// Create a test folders for each of the fixture references
|
||||
foreach(File::get()->filter('ClassName', 'Folder') as $folder) {
|
||||
/** @var Folder $folder */
|
||||
$folder->doPublish();
|
||||
$folder->publishSingle();
|
||||
}
|
||||
|
||||
// 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) {
|
||||
/** @var File $file */
|
||||
$file->setFromString($content, $file->generateFilename());
|
||||
$file->doPublish();
|
||||
$file->publishSingle();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ class CMSBatchActionsTest extends SapphireTest {
|
||||
|
||||
// published page
|
||||
$published = $this->objFromFixture('SiteTree', 'published');
|
||||
$published->doPublish();
|
||||
$published->publishSingle();
|
||||
|
||||
// Deleted / archived page
|
||||
$archived = $this->objFromFixture('SiteTree', 'archived');
|
||||
@ -23,12 +23,12 @@ class CMSBatchActionsTest extends SapphireTest {
|
||||
|
||||
// Unpublished
|
||||
$unpublished = $this->objFromFixture('SiteTree', 'unpublished');
|
||||
$unpublished->doPublish();
|
||||
$unpublished->publishSingle();
|
||||
$unpublished->doUnpublish();
|
||||
|
||||
// Modified
|
||||
$modified = $this->objFromFixture('SiteTree', 'modified');
|
||||
$modified->doPublish();
|
||||
$modified->publishSingle();
|
||||
$modified->Title = 'modified2';
|
||||
$modified->write();
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class CMSMainTest extends FunctionalTest {
|
||||
// $page->write();
|
||||
// $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());
|
||||
|
||||
// // Check that you can visit the page
|
||||
@ -214,7 +214,7 @@ class CMSMainTest extends FunctionalTest {
|
||||
// Set up a page that is delete from live
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$pageID = $page->ID;
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$page->delete();
|
||||
|
||||
$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
|
||||
$page1 = $this->objFromFixture('Page', 'page1');
|
||||
$page1ID = $page1->ID;
|
||||
$page1->doPublish();
|
||||
$page1->publishRecursive();
|
||||
$page1->delete();
|
||||
|
||||
$cmsMain = new CMSMain();
|
||||
@ -448,9 +448,9 @@ class CMSMainTest extends FunctionalTest {
|
||||
$page1->doUnpublish();
|
||||
$page1->delete();
|
||||
// Live and draft
|
||||
$page11->publish('Stage', 'Live');
|
||||
$page11->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
// Live only
|
||||
$page12->publish('Stage', 'Live');
|
||||
$page12->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$page12->delete();
|
||||
|
||||
// Re-test all pages (stage)
|
||||
|
@ -26,7 +26,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest {
|
||||
|
||||
$this->page->Content = "some further content";
|
||||
$this->page->write();
|
||||
$this->page->publish('Stage', 'Live');
|
||||
$this->page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$this->versionPublishCheck = $this->page->Version;
|
||||
|
||||
$this->page->Content = "No, more changes please";
|
||||
@ -36,7 +36,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest {
|
||||
|
||||
$this->page->Title = "Final Change";
|
||||
$this->page->write();
|
||||
$this->page->publish('Stage', 'Live');
|
||||
$this->page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$this->versionPublishCheck2 = $this->page->Version;
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
||||
|
||||
public function testChangedPagesFilter() {
|
||||
$unchangedPage = $this->objFromFixture('Page', 'page1');
|
||||
$unchangedPage->doPublish();
|
||||
$unchangedPage->publishRecursive();
|
||||
|
||||
$changedPage = $this->objFromFixture('Page', 'page2');
|
||||
$changedPage->Title = 'Original';
|
||||
$changedPage->publish('Stage', 'Live');
|
||||
$changedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$changedPage->Title = 'Changed';
|
||||
$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
|
||||
$changedPage->Title = 'Changed 2';
|
||||
$changedPage->publish('Stage', 'Live');
|
||||
$changedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$changedPage->doRollbackTo(1);
|
||||
|
||||
$f = new CMSSiteTreeFilter_ChangedPages(array('Term' => 'Changed'));
|
||||
@ -87,7 +87,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
||||
|
||||
public function testDeletedPagesFilter() {
|
||||
$deletedPage = $this->objFromFixture('Page', 'page2');
|
||||
$deletedPage->publish('Stage', 'Live');
|
||||
$deletedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$deletedPageID = $deletedPage->ID;
|
||||
$deletedPage->delete();
|
||||
$deletedPage = Versioned::get_one_by_stage(
|
||||
@ -106,7 +106,6 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
||||
|
||||
public function testStatusDraftPagesFilter() {
|
||||
$draftPage = $this->objFromFixture('Page', 'page4');
|
||||
$draftPage->publish('Stage', 'Stage');
|
||||
$draftPage = Versioned::get_one_by_stage(
|
||||
'SiteTree',
|
||||
'Stage',
|
||||
@ -141,7 +140,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
||||
|
||||
public function testStatusRemovedFromDraftFilter() {
|
||||
$removedDraftPage = $this->objFromFixture('Page', 'page6');
|
||||
$removedDraftPage->doPublish();
|
||||
$removedDraftPage->publishRecursive();
|
||||
$removedDraftPage->deleteFromStage('Stage');
|
||||
$removedDraftPage = Versioned::get_one_by_stage(
|
||||
'SiteTree',
|
||||
@ -165,7 +164,7 @@ class CMSSiteTreeFilterTest extends SapphireTest {
|
||||
|
||||
public function testStatusDeletedFilter() {
|
||||
$deletedPage = $this->objFromFixture('Page', 'page7');
|
||||
$deletedPage->publish('Stage', 'Live');
|
||||
$deletedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$deletedPageID = $deletedPage->ID;
|
||||
|
||||
// Can't use straight $blah->delete() as that blows it away completely and test fails
|
||||
|
@ -14,7 +14,7 @@ class ContentControllerPermissionsTest extends FunctionalTest {
|
||||
$page = new Page();
|
||||
$page->URLSegment = 'testpage';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
// Add a stage-only version
|
||||
$page->Content = "Version2";
|
||||
|
@ -6,7 +6,7 @@ class ContentControllerSearchExtensionTest extends SapphireTest {
|
||||
$page->URLSegment = 'whatever';
|
||||
$page->Content = 'oh really?';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$controller = new ContentController($page);
|
||||
$form = $controller->SearchForm();
|
||||
|
||||
|
@ -116,13 +116,13 @@ class ContentControllerTest extends FunctionalTest {
|
||||
$linkedPage = new SiteTree();
|
||||
$linkedPage->URLSegment = 'linked-page';
|
||||
$linkedPage->write();
|
||||
$linkedPage->publish('Stage', 'Live');
|
||||
$linkedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page = new SiteTree();
|
||||
$page->URLSegment = 'linking-page';
|
||||
$page->Content = sprintf('<a href="[sitetree_link,id=%s]">Testlink</a>', $linkedPage->ID);
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$this->assertContains(
|
||||
sprintf('<a href="%s">Testlink</a>', $linkedPage->Link()),
|
||||
@ -146,7 +146,7 @@ class ContentControllerTest extends FunctionalTest {
|
||||
$page = new ContentControllerTestPageWithoutController();
|
||||
$page->URLSegment = "test";
|
||||
$page->write();
|
||||
$page->publish("Stage", "Live");
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $self->get($page->RelativeLink());
|
||||
$self->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody()));
|
||||
@ -155,7 +155,7 @@ class ContentControllerTest extends FunctionalTest {
|
||||
$page = new ContentControllerTestPage();
|
||||
$page->URLSegment = "test";
|
||||
$page->write();
|
||||
$page->publish("Stage", "Live");
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $self->get($page->RelativeLink());
|
||||
$self->assertEquals("Page", trim($response->getBody()));
|
||||
@ -165,7 +165,7 @@ class ContentControllerTest extends FunctionalTest {
|
||||
$page = new ContentControllerTestPage();
|
||||
$page->URLSegment = "page-without-controller";
|
||||
$page->write();
|
||||
$page->publish("Stage", "Live");
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $self->get($page->RelativeLink("test"));
|
||||
$self->assertEquals("ContentControllerTestPage_test", trim($response->getBody()));
|
||||
|
@ -46,33 +46,33 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$level1->Title = 'First Level';
|
||||
$level1->URLSegment = 'level1';
|
||||
$level1->write();
|
||||
$level1->publish('Stage', 'Live');
|
||||
$level1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$level1->URLSegment = 'newlevel1';
|
||||
$level1->write();
|
||||
$level1->publish('Stage', 'Live');
|
||||
$level1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$level2 = new Page();
|
||||
$level2->Title = 'Second Level';
|
||||
$level2->URLSegment = 'level2';
|
||||
$level2->ParentID = $level1->ID;
|
||||
$level2->write();
|
||||
$level2->publish('Stage', 'Live');
|
||||
$level2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$level2->URLSegment = 'newlevel2';
|
||||
$level2->write();
|
||||
$level2->publish('Stage', 'Live');
|
||||
$level2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$level3 = New Page();
|
||||
$level3->Title = "Level 3";
|
||||
$level3->URLSegment = 'level3';
|
||||
$level3->ParentID = $level2->ID;
|
||||
$level3->write();
|
||||
$level3->publish('Stage','Live');
|
||||
$level3->copyVersionToStage('Stage','Live');
|
||||
|
||||
$level3->URLSegment = 'newlevel3';
|
||||
$level3->write();
|
||||
$level3->publish('Stage','Live');
|
||||
$level3->copyVersionToStage('Stage','Live');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,39 +125,39 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$page->Title = 'First Level';
|
||||
$page->URLSegment = 'oldurl';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page->URLSegment = 'newurl';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page2 = new Page();
|
||||
$page2->Title = 'Second Level Page';
|
||||
$page2->URLSegment = 'level2';
|
||||
$page2->ParentID = $page->ID;
|
||||
$page2->write();
|
||||
$page2->publish('Stage', 'Live');
|
||||
$page2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page3 = new Page();
|
||||
$page3->Title = 'Third Level Page';
|
||||
$page3->URLSegment = 'level3';
|
||||
$page3->ParentID = $page2->ID;
|
||||
$page3->write();
|
||||
$page3->publish('Stage', 'Live');
|
||||
$page3->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page4 = new Page();
|
||||
$page4->Title = 'Fourth Level Page';
|
||||
$page4->URLSegment = 'level4';
|
||||
$page4->ParentID = $page3->ID;
|
||||
$page4->write();
|
||||
$page4->publish('Stage', 'Live');
|
||||
$page4->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page5 = new Page();
|
||||
$page5->Title = 'Fifth Level Page';
|
||||
$page5->URLSegment = 'level5';
|
||||
$page5->ParentID = $page4->ID;
|
||||
$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
|
||||
$response = $this->get('oldurl/level2/level3/level4/level5/');
|
||||
@ -192,7 +192,7 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
'URLSegment' => 'otherparent'
|
||||
));
|
||||
$otherParent->write();
|
||||
$otherParent->publish('Stage', 'Live');
|
||||
$otherParent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $this->get('level1/otherparent');
|
||||
$this->assertEquals($response->getStatusCode(), 301);
|
||||
@ -235,7 +235,7 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
'URLSegment' => 'level1'
|
||||
));
|
||||
$otherLevel1->write();
|
||||
$otherLevel1->publish('Stage', 'Live');
|
||||
$otherLevel1->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $this->get('level1');
|
||||
$this->assertEquals(
|
||||
@ -261,11 +261,11 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$page->Title = 'First Level';
|
||||
$page->URLSegment = 'oldurl';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page->URLSegment = 'newurl';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$url = OldPageRedirector::find_old_page('oldurl');
|
||||
$matchedPage = SiteTree::get_by_link($url);
|
||||
@ -276,11 +276,11 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$page2->URLSegment = 'oldpage2';
|
||||
$page2->ParentID = $page->ID;
|
||||
$page2->write();
|
||||
$page2->publish('Stage', 'Live');
|
||||
$page2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page2->URLSegment = 'newpage2';
|
||||
$page2->write();
|
||||
$page2->publish('Stage', 'Live');
|
||||
$page2->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$url = OldPageRedirector::find_old_page('oldpage2',$page2->ParentID);
|
||||
$matchedPage = SiteTree::get_by_link($url);
|
||||
@ -309,7 +309,7 @@ class ModelAsControllerTest extends FunctionalTest {
|
||||
$published->Title = 'Published Page Under Draft Page';
|
||||
$published->URLSegment = 'sub-root';
|
||||
$published->write();
|
||||
$published->publish('Stage', 'Live');
|
||||
$published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$response = $this->get('root/sub-root');
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -25,11 +25,11 @@ class ErrorPageFileExtensionTest extends SapphireTest {
|
||||
public function testErrorPage() {
|
||||
// Get and publish records
|
||||
$notFoundPage = $this->objFromFixture('ErrorPage', '404');
|
||||
$notFoundPage->publish('Stage', 'Live');
|
||||
$notFoundPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$notFoundLink = $notFoundPage->Link();
|
||||
|
||||
$disallowedPage = $this->objFromFixture('ErrorPage', '403');
|
||||
$disallowedPage->publish('Stage', 'Live');
|
||||
$disallowedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$disallowedLink = $disallowedPage->Link();
|
||||
|
||||
// Get stage version of file
|
||||
|
@ -31,7 +31,7 @@ class ErrorPageTest extends FunctionalTest {
|
||||
public function test404ErrorPage() {
|
||||
$page = $this->objFromFixture('ErrorPage', '404');
|
||||
// ensure that the errorpage exists as a physical file
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $this->get('nonexistent-page');
|
||||
|
||||
@ -57,7 +57,7 @@ class ErrorPageTest extends FunctionalTest {
|
||||
|
||||
public function testBehaviourOf403() {
|
||||
$page = $this->objFromFixture('ErrorPage', '403');
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $this->get($page->RelativeLink());
|
||||
|
||||
@ -68,7 +68,7 @@ class ErrorPageTest extends FunctionalTest {
|
||||
public function testSecurityError() {
|
||||
// Generate 404 page
|
||||
$page = $this->objFromFixture('ErrorPage', '404');
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
// Test invalid action
|
||||
$response = $this->get('Security/nosuchaction');
|
||||
@ -88,8 +88,8 @@ class ErrorPageTest extends FunctionalTest {
|
||||
$page->ErrorCode = 401;
|
||||
$page->Title = 'Unauthorised';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->doPublish();
|
||||
$page->copyVersionToStage('Stage', 'Live');
|
||||
$page->publishRecursive();
|
||||
|
||||
// Static cache should now exist
|
||||
$this->assertNotEmpty(ErrorPage::get_content_for_errorcode('401'));
|
||||
@ -108,7 +108,7 @@ class ErrorPageTest extends FunctionalTest {
|
||||
$page->ErrorCode = 405;
|
||||
$page->Title = 'Method Not Allowed';
|
||||
$page->write();
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
|
||||
// Dynamic content is available
|
||||
$response = ErrorPage::response_for('405');
|
||||
|
@ -21,7 +21,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
Filesystem::makeFolder(dirname($destPath));
|
||||
file_put_contents($destPath, str_repeat('x', 1000000));
|
||||
// Ensure files are published, thus have public urls
|
||||
$file->doPublish();
|
||||
$file->publishRecursive();
|
||||
}
|
||||
|
||||
// Since we can't hard-code IDs, manually inject image tracking shortcode
|
||||
@ -46,7 +46,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
*/
|
||||
public function testFileRenameUpdatesDraftAndPublishedPages() {
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
|
||||
// Live and stage pages both have link to public file
|
||||
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")
|
||||
// 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
|
||||
$file->doPublish();
|
||||
$file->publishRecursive();
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
$this->assertContains(
|
||||
'<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
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
$this->assertContains(
|
||||
'<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file.jpg"',
|
||||
@ -111,13 +111,13 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
public function testFileLinkRewritingOnVirtualPages() {
|
||||
// Publish the source page
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$this->assertTrue($page->doPublish());
|
||||
$this->assertTrue($page->publishRecursive());
|
||||
|
||||
// Create a virtual page from it, and publish that
|
||||
$svp = new VirtualPage();
|
||||
$svp->CopyContentFromID = $page->ID;
|
||||
$svp->write();
|
||||
$svp->doPublish();
|
||||
$svp->publishRecursive();
|
||||
|
||||
// Rename the file
|
||||
$file = $this->objFromFixture('Image', 'file1');
|
||||
@ -132,8 +132,8 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
);
|
||||
|
||||
// Publishing both file and page will update the live record
|
||||
$file->doPublish();
|
||||
$page->doPublish();
|
||||
$file->publishRecursive();
|
||||
$page->publishRecursive();
|
||||
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$this->assertContains(
|
||||
@ -145,7 +145,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
public function testLinkRewritingOnAPublishedPageDoesntMakeItEditedOnDraft() {
|
||||
// Publish the source page
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$this->assertTrue($page->doPublish());
|
||||
$this->assertTrue($page->publishRecursive());
|
||||
$this->assertFalse($page->getIsModifiedOnStage());
|
||||
|
||||
// Rename the file
|
||||
@ -163,7 +163,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
|
||||
public function testTwoFileRenamesInARowWork() {
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$this->assertTrue($page->doPublish());
|
||||
$this->assertTrue($page->publishRecursive());
|
||||
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$this->assertContains(
|
||||
@ -182,7 +182,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
$file = DataObject::get_by_id('File', $file->ID);
|
||||
$file->Name = 'renamed-test-file-second-time.jpg';
|
||||
$file->write();
|
||||
$file->doPublish();
|
||||
$file->publishRecursive();
|
||||
|
||||
// Confirm that the correct image is shown in both the draft and live site
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
@ -192,7 +192,7 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
);
|
||||
|
||||
// Publishing this record also updates live record
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$this->assertContains(
|
||||
'<img src="/assets/FileLinkTrackingTest/55b443b601/renamed-test-file-second-time.jpg"',
|
||||
|
@ -25,7 +25,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
||||
$page = new SiteTreeActionsTest_Page();
|
||||
$page->CanEditType = 'LoggedInUsers';
|
||||
$page->write();
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
|
||||
$actions = $page->getCMSActions();
|
||||
|
||||
@ -47,7 +47,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
||||
$page->CanEditType = 'LoggedInUsers';
|
||||
$page->write();
|
||||
$pageID = $page->ID;
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$page->deleteFromStage('Stage');
|
||||
|
||||
// Get the live version of the page
|
||||
@ -76,7 +76,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
||||
$page = new Page();
|
||||
$page->CanEditType = 'LoggedInUsers';
|
||||
$page->write();
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
|
||||
$actions = $page->getCMSActions();
|
||||
|
||||
@ -99,7 +99,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
||||
$page->CanEditType = 'LoggedInUsers';
|
||||
$page->write();
|
||||
$pageID = $page->ID;
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$page->deleteFromStage('Stage');
|
||||
|
||||
// Get the live version of the page
|
||||
@ -126,7 +126,7 @@ class SiteTreeActionsTest extends FunctionalTest {
|
||||
$page = new Page();
|
||||
$page->CanEditType = 'LoggedInUsers';
|
||||
$page->write();
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$page->Content = 'Changed on Stage';
|
||||
$page->write();
|
||||
$page->flushCache();
|
||||
|
@ -86,8 +86,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
|
||||
// publish page 1 & 3
|
||||
$page1 = $this->objFromFixture('Page', 'page1');
|
||||
$page3 = $this->objFromFixture('Page', 'page3');
|
||||
$this->assertTrue($page1->doPublish());
|
||||
$this->assertTrue($page3->doPublish());
|
||||
$this->assertTrue($page1->publishRecursive());
|
||||
$this->assertTrue($page3->publishRecursive());
|
||||
|
||||
// load pages from live
|
||||
$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');
|
||||
$page3 = $this->objFromFixture('Page', 'page3');
|
||||
|
||||
$this->assertTrue($page1->doPublish());
|
||||
$this->assertTrue($page3->doPublish());
|
||||
$this->assertTrue($page1->publishRecursive());
|
||||
$this->assertTrue($page3->publishRecursive());
|
||||
|
||||
// load page 3 from live
|
||||
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
|
||||
@ -142,7 +142,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
|
||||
|
||||
|
||||
// publish page 1
|
||||
$this->assertTrue($page1->doPublish());
|
||||
$this->assertTrue($page1->publishRecursive());
|
||||
|
||||
// assert hyperlink to page 1's new published url exists
|
||||
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
|
||||
@ -156,8 +156,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
|
||||
// publish page 1 & 3
|
||||
$page1 = $this->objFromFixture('Page', 'page1');
|
||||
$page3 = $this->objFromFixture('Page', 'page3');
|
||||
$this->assertTrue($page1->doPublish());
|
||||
$this->assertTrue($page3->doPublish());
|
||||
$this->assertTrue($page1->publishRecursive());
|
||||
$this->assertTrue($page3->publishRecursive());
|
||||
|
||||
// assert hyperlink to page 1's current url exists
|
||||
$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');
|
||||
|
||||
// publish page 3
|
||||
$this->assertTrue($page3->doPublish());
|
||||
$this->assertTrue($page3->publishRecursive());
|
||||
|
||||
// assert page 3 on published site contains old page 1 url
|
||||
$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');
|
||||
|
||||
// publish page 1
|
||||
$this->assertTrue($page1->doPublish());
|
||||
$this->assertTrue($page1->publishRecursive());
|
||||
|
||||
// assert page 3 on published site contains new page 1 url
|
||||
$page3live = Versioned::get_one_by_stage('Page', 'Live', '"SiteTree"."ID" = ' . $page3->ID);
|
||||
@ -195,8 +195,8 @@ class SiteTreeBacklinksTest extends SapphireTest {
|
||||
public function testLinkTrackingOnExtraContentFields() {
|
||||
$page1 = $this->objFromFixture('Page', 'page1');
|
||||
$page2 = $this->objFromFixture('Page', 'page2');
|
||||
$page1->doPublish();
|
||||
$page2->doPublish();
|
||||
$page1->publishRecursive();
|
||||
$page2->publishRecursive();
|
||||
|
||||
// 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
|
||||
$page2->ExtraContent .= '<p><a href="[sitetree_link,id='.$page1->ID.']">Testing page 1 link</a></p>';
|
||||
$page2->write();
|
||||
$page2->doPublish();
|
||||
$page2->publishRecursive();
|
||||
|
||||
// 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());
|
||||
|
||||
// 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");
|
||||
$this->assertEquals('<p><a href="'.Director::baseURL().'page1-new-url/">Testing page 1 link</a></p>', $page2Live->obj('ExtraContent')->forTemplate());
|
||||
|
||||
|
@ -86,7 +86,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$file->ID
|
||||
);
|
||||
$obj->write();
|
||||
$this->assertTrue($obj->doPublish());
|
||||
$this->assertTrue($obj->publishRecursive());
|
||||
// Confirm that it isn't marked as broken to begin with
|
||||
$obj->flushCache();
|
||||
$obj = DataObject::get_by_id("SiteTree", $obj->ID);
|
||||
@ -104,7 +104,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$this->assertEquals(1, $obj->HasBrokenFile);
|
||||
|
||||
// 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");
|
||||
$this->assertEquals(1, $liveObj->HasBrokenFile);
|
||||
}
|
||||
@ -146,7 +146,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$linkSrc->write();
|
||||
|
||||
// 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
|
||||
$this->assertEquals(0, (int)$linkSrc->HasBrokenLink);
|
||||
@ -161,14 +161,14 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$p->Title = "source";
|
||||
$p->write();
|
||||
$pageID = $p->ID;
|
||||
$this->assertTrue($p->doPublish());
|
||||
$this->assertTrue($p->publishRecursive());
|
||||
|
||||
// Content links are one kind of link to pages
|
||||
$p2 = new Page();
|
||||
$p2->Title = "regular link";
|
||||
$p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
|
||||
$p2->write();
|
||||
$this->assertTrue($p2->doPublish());
|
||||
$this->assertTrue($p2->publishRecursive());
|
||||
|
||||
// Virtual pages are another
|
||||
$vp = new VirtualPage();
|
||||
@ -181,7 +181,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$rp->LinkType = 'Internal';
|
||||
$rp->LinkToID = $p->ID;
|
||||
$rp->write();
|
||||
$this->assertTrue($rp->doPublish());
|
||||
$this->assertTrue($rp->publishRecursive());
|
||||
|
||||
// Confirm that there are no broken links to begin with
|
||||
$this->assertFalse($p2->HasBrokenLink);
|
||||
@ -222,7 +222,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$this->assertFalse((bool)$rp->HasBrokenLink);
|
||||
|
||||
// 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);
|
||||
$rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID);
|
||||
$this->assertFalse((bool)$p2Live->HasBrokenLink);
|
||||
@ -236,14 +236,14 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$p->Title = "source";
|
||||
$p->write();
|
||||
$pageID = $p->ID;
|
||||
$this->assertTrue($p->doPublish());
|
||||
$this->assertTrue($p->publishRecursive());
|
||||
|
||||
// Content links are one kind of link to pages
|
||||
$p2 = new Page();
|
||||
$p2->Title = "regular link";
|
||||
$p2->Content = "<a href=\"[sitetree_link,id=$p->ID]\">test</a>";
|
||||
$p2->write();
|
||||
$this->assertTrue($p2->doPublish());
|
||||
$this->assertTrue($p2->publishRecursive());
|
||||
|
||||
// Virtual pages are another
|
||||
$vp = new VirtualPage();
|
||||
@ -256,7 +256,7 @@ class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||
$rp->LinkType = 'Internal';
|
||||
$rp->LinkToID = $p->ID;
|
||||
$rp->write();
|
||||
$this->assertTrue($rp->doPublish());
|
||||
$this->assertTrue($rp->publishRecursive());
|
||||
|
||||
// Confirm that there are no broken links to begin with
|
||||
$this->assertFalse($p2->HasBrokenLink);
|
||||
|
@ -68,7 +68,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
||||
$this->logInWithPermission("ADMIN");
|
||||
$page = $this->objFromFixture('Page','restrictedEditOnlySubadminGroup');
|
||||
$pageID = $page->ID;
|
||||
$this->assertTrue($page->doPublish());
|
||||
$this->assertTrue($page->publishRecursive());
|
||||
$page->delete();
|
||||
|
||||
// Re-fetch the page from the live site
|
||||
@ -134,7 +134,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
||||
|
||||
// Get page & make sure it exists on Live
|
||||
$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
|
||||
$page->Title = 1;
|
||||
@ -382,7 +382,7 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
||||
|
||||
$this->logInWithPermission("ADMIN");
|
||||
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$page->deleteFromStage('Stage');
|
||||
|
||||
// Get the live version of the page
|
||||
|
@ -82,7 +82,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
*/
|
||||
public function testPublishCopiesToLiveTable() {
|
||||
$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();
|
||||
$this->assertEquals($obj->ID, $createdID);
|
||||
@ -97,13 +97,13 @@ class SiteTreeTest extends SapphireTest {
|
||||
$obj = $this->objFromFixture('Page', 'about');
|
||||
$obj->Title = "asdfasdf";
|
||||
$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());
|
||||
|
||||
$obj->Title = null;
|
||||
$obj->write();
|
||||
$this->assertTrue($obj->doPublish());
|
||||
$this->assertTrue($obj->publishRecursive());
|
||||
|
||||
$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->URLSegment = "get-one-test-page";
|
||||
$s->write();
|
||||
$s->publish("Stage", "Live");
|
||||
$s->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$s->Title = "V2";
|
||||
$s->write();
|
||||
|
||||
@ -153,7 +153,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
|
||||
public function testChidrenOfRootAreTopLevelPages() {
|
||||
$pages = SiteTree::get();
|
||||
foreach($pages as $page) $page->publish('Stage', 'Live');
|
||||
foreach($pages as $page) $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
unset($pages);
|
||||
|
||||
/* If we create a new SiteTree object with ID = 0 */
|
||||
@ -201,7 +201,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
// published page
|
||||
$publishedPage = new SiteTree();
|
||||
$publishedPage->write();
|
||||
$publishedPage->publish('Stage','Live');
|
||||
$publishedPage->copyVersionToStage('Stage','Live');
|
||||
$this->assertFalse($publishedPage->getIsDeletedFromStage());
|
||||
$this->assertFalse($publishedPage->getIsAddedToStage());
|
||||
$this->assertFalse($publishedPage->getIsModifiedOnStage());
|
||||
@ -210,7 +210,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
$deletedFromDraftPage = new SiteTree();
|
||||
$deletedFromDraftPage->write();
|
||||
$deletedFromDraftPageID = $deletedFromDraftPage->ID;
|
||||
$deletedFromDraftPage->publish('Stage','Live');
|
||||
$deletedFromDraftPage->copyVersionToStage('Stage','Live');
|
||||
$deletedFromDraftPage->deleteFromStage('Stage');
|
||||
$this->assertTrue($deletedFromDraftPage->getIsDeletedFromStage());
|
||||
$this->assertFalse($deletedFromDraftPage->getIsAddedToStage());
|
||||
@ -219,7 +219,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
// published page, deleted from live
|
||||
$deletedFromLivePage = new SiteTree();
|
||||
$deletedFromLivePage->write();
|
||||
$deletedFromLivePage->publish('Stage','Live');
|
||||
$deletedFromLivePage->copyVersionToStage('Stage','Live');
|
||||
$deletedFromLivePage->deleteFromStage('Stage');
|
||||
$deletedFromLivePage->deleteFromStage('Live');
|
||||
$this->assertTrue($deletedFromLivePage->getIsDeletedFromStage());
|
||||
@ -229,7 +229,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
// published page, modified
|
||||
$modifiedOnDraftPage = new SiteTree();
|
||||
$modifiedOnDraftPage->write();
|
||||
$modifiedOnDraftPage->publish('Stage','Live');
|
||||
$modifiedOnDraftPage->copyVersionToStage('Stage','Live');
|
||||
$modifiedOnDraftPage->Content = 'modified';
|
||||
$modifiedOnDraftPage->write();
|
||||
$this->assertFalse($modifiedOnDraftPage->getIsDeletedFromStage());
|
||||
@ -331,10 +331,10 @@ class SiteTreeTest extends SapphireTest {
|
||||
|
||||
Config::inst()->update('SiteTree', 'nested_urls', true);
|
||||
|
||||
$child->publish('Stage', 'Live');
|
||||
$child->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$parent->URLSegment = 'changed-on-live';
|
||||
$parent->write();
|
||||
$parent->publish('Stage', 'Live');
|
||||
$parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$parent->URLSegment = 'changed-on-draft';
|
||||
$parent->write();
|
||||
|
||||
@ -373,11 +373,11 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||
$pageAbout->doPublish();
|
||||
$pageAbout->publishRecursive();
|
||||
$pageStaff = $this->objFromFixture('Page', 'staff');
|
||||
$pageStaff->doPublish();
|
||||
$pageStaff->publishRecursive();
|
||||
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
|
||||
$pageStaffDuplicate->doPublish();
|
||||
$pageStaffDuplicate->publishRecursive();
|
||||
|
||||
$parentPage = $this->objFromFixture('Page', 'about');
|
||||
|
||||
@ -397,11 +397,11 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||
$pageAbout->doPublish();
|
||||
$pageAbout->publishRecursive();
|
||||
$pageStaff = $this->objFromFixture('Page', 'staff');
|
||||
$pageStaff->doPublish();
|
||||
$pageStaff->publishRecursive();
|
||||
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
|
||||
$pageStaffDuplicate->doPublish();
|
||||
$pageStaffDuplicate->publishRecursive();
|
||||
|
||||
$parentPage = $this->objFromFixture('Page', 'about');
|
||||
$parentPage->doUnpublish();
|
||||
@ -418,11 +418,11 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||
$pageAbout->doPublish();
|
||||
$pageAbout->publishRecursive();
|
||||
$pageStaff = $this->objFromFixture('Page', 'staff');
|
||||
$pageStaff->doPublish();
|
||||
$pageStaff->publishRecursive();
|
||||
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
|
||||
$pageStaffDuplicate->doPublish();
|
||||
$pageStaffDuplicate->publishRecursive();
|
||||
|
||||
$parentPage = $this->objFromFixture('Page', 'about');
|
||||
$parentPage->doUnpublish();
|
||||
@ -519,7 +519,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
$page = new Page();
|
||||
$page->write();
|
||||
$page->CanEditType = "Inherit";
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$pageID = $page->ID;
|
||||
|
||||
// Lock down the site config
|
||||
@ -546,7 +546,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
|
||||
// Publish the changes to the page
|
||||
$this->objFromFixture('Member','admin')->logIn();
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
|
||||
// Confirm that Member.editor can still edit the page
|
||||
$this->objFromFixture('Member','editor')->logIn();
|
||||
@ -601,7 +601,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->assertEquals(0, $savedVersion['PublisherID']);
|
||||
|
||||
// Publish the page
|
||||
$about->doPublish();
|
||||
$about->publishRecursive();
|
||||
$publishedVersion = DB::query("SELECT \"AuthorID\", \"PublisherID\" FROM \"SiteTree_versions\"
|
||||
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);
|
||||
$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);
|
||||
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
|
||||
$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));
|
||||
|
||||
// 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->assertTrue($staff->canView($member));
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
@ -1135,7 +1135,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
// Publishing the parent page should restore visibility
|
||||
Versioned::set_stage(Versioned::DRAFT);
|
||||
$about = $this->objFromFixture('Page', 'about');
|
||||
$about->publish('Stage', 'Live');
|
||||
$about->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$staff = $this->objFromFixture('Page', 'staff');
|
||||
$this->assertFalse($staff->isOrphaned());
|
||||
@ -1165,7 +1165,7 @@ class SiteTreeTest extends SapphireTest {
|
||||
$this->assertFalse($page->isPublished());
|
||||
|
||||
// Publish
|
||||
$page->doPublish();
|
||||
$page->publishRecursive();
|
||||
$this->assertTrue($page->canAddChildren());
|
||||
$this->assertFalse($page->getIsDeletedFromStage());
|
||||
$this->assertTrue($page->isPublished());
|
||||
|
@ -67,7 +67,7 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
$master = $this->objFromFixture('Page', 'master');
|
||||
$master->doPublish();
|
||||
$master->publishRecursive();
|
||||
|
||||
$master->Title = "New title";
|
||||
$master->MenuTitle = "New menutitle";
|
||||
@ -76,10 +76,10 @@ class VirtualPageTest extends FunctionalTest {
|
||||
|
||||
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
|
||||
$vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2'));
|
||||
$this->assertTrue($vp1->doPublish());
|
||||
$this->assertTrue($vp2->doPublish());
|
||||
$this->assertTrue($vp1->publishRecursive());
|
||||
$this->assertTrue($vp2->publishRecursive());
|
||||
|
||||
$master->doPublish();
|
||||
$master->publishRecursive();
|
||||
|
||||
Versioned::set_stage(Versioned::LIVE);
|
||||
$vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1'));
|
||||
@ -126,14 +126,14 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$p = new Page();
|
||||
$p->Content = "published content";
|
||||
$p->write();
|
||||
$p->doPublish();
|
||||
$p->publishRecursive();
|
||||
|
||||
// Virtual page has this content
|
||||
$vp = new VirtualPage();
|
||||
$vp->CopyContentFromID = $p->ID;
|
||||
$vp->write();
|
||||
|
||||
$vp->doPublish();
|
||||
$vp->publishRecursive();
|
||||
|
||||
// Don't publish this change - published page will still say 'published content'
|
||||
$p->Content = "draft content";
|
||||
@ -152,7 +152,7 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$this->assertEquals('published content', $vpLive->Content);
|
||||
|
||||
// Publishing the virtualpage should, however, trigger publishing of the live page
|
||||
$vpDraft->doPublish();
|
||||
$vpDraft->publishRecursive();
|
||||
|
||||
// Everything is published live
|
||||
$vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID);
|
||||
@ -177,7 +177,7 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$this->assertFalse($vp->canPublish());
|
||||
|
||||
// Once the source page gets published, then we can publish
|
||||
$p->doPublish();
|
||||
$p->publishRecursive();
|
||||
$this->assertTrue($vp->canPublish());
|
||||
}
|
||||
|
||||
@ -186,14 +186,14 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$p = new Page();
|
||||
$p->Content = "test content";
|
||||
$p->write();
|
||||
$p->doPublish();
|
||||
$p->publishRecursive();
|
||||
$pID = $p->ID;
|
||||
|
||||
$vp = new VirtualPage();
|
||||
$vp->CopyContentFromID = $p->ID;
|
||||
$vp->write();
|
||||
$this->assertTrue($vp->canPublish());
|
||||
$this->assertTrue($vp->doPublish());
|
||||
$this->assertTrue($vp->publishRecursive());
|
||||
|
||||
// Delete the source page semi-manually, without triggering
|
||||
// the cascade publish back to the virtual page.
|
||||
@ -238,9 +238,9 @@ class VirtualPageTest extends FunctionalTest {
|
||||
|
||||
public function testCanView() {
|
||||
$parentPage = $this->objFromFixture('Page', 'master3');
|
||||
$parentPage->publish('Stage', 'Live');
|
||||
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$virtualPage = $this->objFromFixture('VirtualPage', 'vp3');
|
||||
$virtualPage->publish('Stage', 'Live');
|
||||
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$cindy = $this->objFromFixture('Member', 'cindy');
|
||||
$alice = $this->objFromFixture('Member', 'alice');
|
||||
|
||||
@ -268,7 +268,7 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$this->assertTrue($vp->getIsAddedToStage());
|
||||
|
||||
// VP is still orange after we publish
|
||||
$p->doPublish();
|
||||
$p->publishRecursive();
|
||||
$this->assertTrue($vp->getIsAddedToStage());
|
||||
|
||||
// A new VP created after P's initial construction
|
||||
@ -280,11 +280,11 @@ class VirtualPageTest extends FunctionalTest {
|
||||
// Also remains orange after a republish
|
||||
$p->Content = "new content";
|
||||
$p->write();
|
||||
$p->doPublish();
|
||||
$p->publishRecursive();
|
||||
$this->assertTrue($vp2->getIsAddedToStage());
|
||||
|
||||
// VP is now published
|
||||
$vp->doPublish();
|
||||
$vp->publishRecursive();
|
||||
|
||||
$this->assertTrue($vp->getExistsOnLive());
|
||||
$this->assertFalse($vp->getIsModifiedOnStage());
|
||||
@ -298,7 +298,7 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$this->assertFalse($vp->getIsModifiedOnStage());
|
||||
|
||||
// Publish, VP goes black
|
||||
$p->doPublish();
|
||||
$p->publishRecursive();
|
||||
$this->assertTrue($vp->getExistsOnLive());
|
||||
$this->assertFalse($vp->getIsModifiedOnStage());
|
||||
}
|
||||
@ -308,11 +308,11 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$p = new Page();
|
||||
$p->Title = "source";
|
||||
$p->write();
|
||||
$this->assertTrue($p->doPublish());
|
||||
$this->assertTrue($p->publishRecursive());
|
||||
$vp = new VirtualPage();
|
||||
$vp->CopyContentFromID = $p->ID;
|
||||
$vp->write();
|
||||
$this->assertTrue($vp->doPublish());
|
||||
$this->assertTrue($vp->publishRecursive());
|
||||
|
||||
// All is fine, the virtual page doesn't have a broken link
|
||||
$this->assertFalse($vp->HasBrokenLink);
|
||||
@ -340,11 +340,11 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$p = new Page();
|
||||
$p->Title = "source";
|
||||
$p->write();
|
||||
$this->assertTrue($p->doPublish());
|
||||
$this->assertTrue($p->publishRecursive());
|
||||
$vp = new VirtualPage();
|
||||
$vp->CopyContentFromID = $p->ID;
|
||||
$vp->write();
|
||||
$this->assertTrue($vp->doPublish());
|
||||
$this->assertTrue($vp->publishRecursive());
|
||||
|
||||
// All is fine, the virtual page doesn't have a broken link
|
||||
$this->assertFalse($vp->HasBrokenLink);
|
||||
@ -478,13 +478,13 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$page->Title = 'published title';
|
||||
$page->MySharedNonVirtualField = 'original';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$virtual = new VirtualPageTest_VirtualPageSub();
|
||||
$virtual->CopyContentFromID = $page->ID;
|
||||
$virtual->MySharedNonVirtualField = 'virtual published field';
|
||||
$virtual->write();
|
||||
$virtual->publish('Stage', 'Live');
|
||||
$virtual->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page->Title = 'original'; // 'Title' is a virtual field
|
||||
// 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->MySharedNonVirtualField = 'changed only on original';
|
||||
$page->write();
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
// Virtual page only notices changes to virtualised fields (Title)
|
||||
$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->write();
|
||||
$rp->doPublish();
|
||||
$rp->publishRecursive();
|
||||
|
||||
$vp = new VirtualPage(array('URLSegment' => 'vptest', 'CopyContentFromID' => $rp->ID));
|
||||
$vp->write();
|
||||
$vp->doPublish();
|
||||
$vp->publishRecursive();
|
||||
|
||||
$response = $this->get($vp->Link());
|
||||
$this->assertEquals(301, $response->getStatusCode());
|
||||
|
@ -75,7 +75,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||
|
||||
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
|
||||
$publishedPage->publish('Stage', 'Live');
|
||||
$publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$this->waitUntilIndexingFinished();
|
||||
$results = $sf->getResults(null, array('Search'=>'publicPublishedPage'));
|
||||
@ -94,7 +94,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
|
||||
$publishedPage->Title = "finding butterflies";
|
||||
$publishedPage->write();
|
||||
$publishedPage->publish('Stage', 'Live');
|
||||
$publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$this->waitUntilIndexingFinished();
|
||||
$results = $sf->getResults(null, array('Search'=>'"finding butterflies"'));
|
||||
@ -125,7 +125,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||
|
||||
$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
||||
$this->assertNotContains(
|
||||
$page->ID,
|
||||
@ -150,7 +150,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||
|
||||
$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
||||
$this->assertNotContains(
|
||||
$page->ID,
|
||||
@ -183,10 +183,10 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||
|
||||
$parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
||||
$parent->publish('Stage', 'Live');
|
||||
$parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
|
||||
$page->publish('Stage', 'Live');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
||||
$this->assertNotContains(
|
||||
$page->ID,
|
||||
@ -225,9 +225,9 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||
|
||||
$dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile');
|
||||
$dontShowInSearchFile->publish('Stage', 'Live');
|
||||
$dontShowInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$showInSearchFile = $this->objFromFixture('File', 'showInSearchFile');
|
||||
$showInSearchFile->publish('Stage', 'Live');
|
||||
$showInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$results = $sf->getResults(null, array('Search'=>'dontShowInSearchFile'));
|
||||
$this->assertNotContains(
|
||||
@ -254,7 +254,7 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||
|
||||
$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');
|
||||
$pageWithSpecialChars->publish('Stage', 'Live');
|
||||
$pageWithSpecialChars->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$results = $sf->getResults(null, array('Search'=>'Brötchen'));
|
||||
$this->assertContains(
|
||||
|
@ -40,13 +40,13 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest {
|
||||
parent::setUp();
|
||||
|
||||
$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->publish('Stage', 'Live');
|
||||
$child1_1_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$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->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->ParentID = 9999;
|
||||
$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->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->ParentID = 9999;
|
||||
@ -69,10 +69,10 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest {
|
||||
);
|
||||
$grandchild1_1_4_orphaned_published->ParentID = 9999;
|
||||
$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->publish('Stage', 'Live');
|
||||
$child2_1_published_orphaned->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
}
|
||||
|
||||
public function testGetOrphansByStage() {
|
||||
|
Loading…
Reference in New Issue
Block a user