mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Update API to remove deprecated useDraftSite()
Update to support versioned enhancements
This commit is contained in:
parent
78e82dabe8
commit
8c6c429994
@ -6,6 +6,7 @@ use Page;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use SilverStripe\Admin\CMSBatchActionHandler;
|
||||
use SilverStripe\CMS\Controllers\CMSMain;
|
||||
use SilverStripe\CMS\Model\RedirectorPage;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
@ -141,7 +142,7 @@ class CMSMainTest extends FunctionalTest
|
||||
}
|
||||
|
||||
// Get the latest version of the redirector page
|
||||
$pageID = $this->idFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'page5');
|
||||
$pageID = $this->idFromFixture(RedirectorPage::class, 'page5');
|
||||
$latestID = DB::prepared_query('select max("Version") from "RedirectorPage_Versions" where "RecordID" = ?', array($pageID))->value();
|
||||
$dsCount = DB::prepared_query('select count("Version") from "RedirectorPage_Versions" where "RecordID" = ? and "Version"= ?', array($pageID, $latestID))->value();
|
||||
$this->assertEquals(1, $dsCount, "Published page has no duplicate version records: it has " . $dsCount . " for version " . $latestID);
|
||||
|
@ -16,8 +16,6 @@ class ContentControllerTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'ContentControllerTest.yml';
|
||||
|
||||
protected static $use_draft_site = true;
|
||||
|
||||
protected static $disable_themes = true;
|
||||
|
||||
protected static $extra_dataobjects = [
|
||||
@ -26,13 +24,25 @@ class ContentControllerTest extends FunctionalTest
|
||||
ContentControllerTestPageWithoutController::class,
|
||||
];
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Config::modify()->set(SiteTree::class, 'nested_urls', true);
|
||||
|
||||
// Ensure all pages are published
|
||||
/** @var Page $page */
|
||||
foreach (Page::get() as $page) {
|
||||
$page->publishSingle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that nested pages, basic actions, and nested/non-nested URL switching works properly
|
||||
*/
|
||||
|
||||
public function testNestedPages()
|
||||
{
|
||||
RootURLController::reset();
|
||||
Config::modify()->set(SiteTree::class, 'nested_urls', true);
|
||||
|
||||
$this->assertEquals('Home Page', $this->get('/')->getBody());
|
||||
@ -70,14 +80,12 @@ class ContentControllerTest extends FunctionalTest
|
||||
{
|
||||
$controller = new ContentController();
|
||||
|
||||
Config::modify()->set(SiteTree::class, 'nested_urls', true);
|
||||
|
||||
$this->assertEquals(1, $controller->ChildrenOf('/')->Count());
|
||||
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
|
||||
$this->assertEquals(2, $controller->ChildrenOf('/home/second-level/')->Count());
|
||||
$this->assertEquals(0, $controller->ChildrenOf('/home/second-level/third-level/')->Count());
|
||||
|
||||
SiteTree::config()->nested_urls = false;
|
||||
SiteTree::config()->set('nested_urls', false);
|
||||
|
||||
$this->assertEquals(1, $controller->ChildrenOf('/')->Count());
|
||||
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
|
||||
@ -87,11 +95,11 @@ class ContentControllerTest extends FunctionalTest
|
||||
|
||||
public function testDeepNestedURLs()
|
||||
{
|
||||
Config::modify()->set(SiteTree::class, 'nested_urls', true);
|
||||
|
||||
$page = new Page();
|
||||
$page->URLSegment = 'base-page';
|
||||
$page->write();
|
||||
$page->publishSingle();
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$parentID = $page->ID;
|
||||
@ -101,18 +109,15 @@ class ContentControllerTest extends FunctionalTest
|
||||
$page->Title = "Page Level $i";
|
||||
$page->URLSegment = "level-$i";
|
||||
$page->write();
|
||||
$page->publishSingle();
|
||||
|
||||
$relativeLink = Director::makeRelative($page->Link());
|
||||
$this->assertEquals($page->Title, $this->get($relativeLink)->getBody());
|
||||
}
|
||||
|
||||
|
||||
SiteTree::config()->nested_urls = false;
|
||||
}
|
||||
|
||||
public function testViewDraft()
|
||||
{
|
||||
|
||||
// test when user does not have permission, should get login form
|
||||
$this->logInWithPermission('EDITOR');
|
||||
try {
|
||||
@ -141,9 +146,11 @@ class ContentControllerTest extends FunctionalTest
|
||||
$page->write();
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$link = $page->RelativeLink();
|
||||
$response = $this->get($link);
|
||||
$this->assertContains(
|
||||
sprintf('<a href="%s">Testlink</a>', $linkedPage->Link()),
|
||||
$this->get($page->RelativeLink())->getBody(),
|
||||
$response->getBody(),
|
||||
'"sitetree_link" shortcodes get parsed properly'
|
||||
);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use Page;
|
||||
use SilverStripe\CMS\Model\RedirectorPage;
|
||||
use SilverStripe\CMS\Model\RedirectorPageController;
|
||||
use SilverStripe\Control\Director;
|
||||
@ -10,13 +11,19 @@ use SilverStripe\Dev\FunctionalTest;
|
||||
class RedirectorPageTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'RedirectorPageTest.yml';
|
||||
protected static $use_draft_site = true;
|
||||
|
||||
protected $autoFollowRedirection = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Director::config()->update('alternate_base_url', 'http://www.mysite.com/');
|
||||
|
||||
// Ensure all pages are published
|
||||
/** @var Page $page */
|
||||
foreach (Page::get() as $page) {
|
||||
$page->publishSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public function testGoodRedirectors()
|
||||
|
@ -2,20 +2,21 @@
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use Page;
|
||||
use Silverstripe\Assets\Dev\TestAssetStore;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Filesystem;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Assets\Image;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use Silverstripe\Assets\Dev\TestAssetStore;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
|
||||
class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'SiteTreeHTMLEditorFieldTest.yml';
|
||||
|
||||
protected static $use_draft_site = true;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@ -23,12 +24,18 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
// Write file contents
|
||||
$files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder');
|
||||
$files = File::get()->exclude('ClassName', Folder::class);
|
||||
foreach ($files as $file) {
|
||||
$destPath = TestAssetStore::getLocalPath($file);
|
||||
Filesystem::makeFolder(dirname($destPath));
|
||||
file_put_contents($destPath, str_repeat('x', 1000000));
|
||||
}
|
||||
|
||||
// Ensure all pages are published
|
||||
/** @var Page $page */
|
||||
foreach (Page::get() as $page) {
|
||||
$page->publishSingle();
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
@ -81,7 +88,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
{
|
||||
$sitetree = $this->objFromFixture(SiteTree::class, 'home');
|
||||
$editor = new HTMLEditorField('Content');
|
||||
$fileID = $this->idFromFixture('SilverStripe\\Assets\\File', 'example_file');
|
||||
$fileID = $this->idFromFixture(File::class, 'example_file');
|
||||
|
||||
$editor->setValue(sprintf(
|
||||
'<p><a href="[file_link,id=%d]">Example File</a></p>',
|
||||
@ -142,7 +149,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
{
|
||||
$sitetree = $this->objFromFixture(SiteTree::class, 'home');
|
||||
$editor = new HTMLEditorField('Content');
|
||||
$file = $this->objFromFixture('SilverStripe\\Assets\\Image', 'example_image');
|
||||
$file = $this->objFromFixture(Image::class, 'example_image');
|
||||
|
||||
$editor->setValue(sprintf('[image src="%s" id="%d"]', $file->getURL(), $file->ID));
|
||||
$editor->saveInto($sitetree);
|
||||
@ -201,7 +208,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
|
||||
$editor->setValue(sprintf(
|
||||
'<p><a href="[file_link,id=%d]">Working Link</a></p>',
|
||||
$this->idFromFixture('SilverStripe\\Assets\\File', 'example_file')
|
||||
$this->idFromFixture(File::class, 'example_file')
|
||||
));
|
||||
$sitetree->HasBrokenFile = false;
|
||||
$editor->saveInto($sitetree);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use Page;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
@ -27,20 +28,25 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useDraftSite();
|
||||
|
||||
// we're testing HTTP status codes before being redirected to login forms
|
||||
$this->autoFollowRedirection = false;
|
||||
|
||||
// Ensure all pages are published
|
||||
/** @var Page $page */
|
||||
foreach (Page::get() as $page) {
|
||||
if ($page->URLSegment !== 'draft-only') {
|
||||
$page->publishSingle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testAccessingStageWithBlankStage()
|
||||
{
|
||||
$this->useDraftSite(false);
|
||||
$this->autoFollowRedirection = false;
|
||||
|
||||
/** @var Page $draftOnlyPage */
|
||||
$draftOnlyPage = $this->objFromFixture('Page', 'draftOnlyPage');
|
||||
$draftOnlyPage = $this->objFromFixture(Page::class, 'draftOnlyPage');
|
||||
$this->logOut();
|
||||
|
||||
$response = $this->get($draftOnlyPage->URLSegment . '?stage=Live');
|
||||
@ -69,7 +75,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
$response = $this->get($draftOnlyPage->URLSegment . '?stage=Stage');
|
||||
$this->assertEquals('200', $response->getStatusCode());
|
||||
|
||||
// Stage is remembered from last request
|
||||
$draftOnlyPage->publishSingle();
|
||||
$response = $this->get($draftOnlyPage->URLSegment);
|
||||
$this->assertEquals('200', $response->getStatusCode());
|
||||
}
|
||||
@ -78,7 +84,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
{
|
||||
// Set up fixture - a published page deleted from draft
|
||||
$this->logInWithPermission("ADMIN");
|
||||
$page = $this->objFromFixture('Page', 'restrictedEditOnlySubadminGroup');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedEditOnlySubadminGroup');
|
||||
$pageID = $page->ID;
|
||||
$this->assertTrue($page->publishRecursive());
|
||||
$page->delete();
|
||||
@ -105,7 +111,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
{
|
||||
// Set up fixture - an unpublished page
|
||||
$this->logInWithPermission("ADMIN");
|
||||
$page = $this->objFromFixture('Page', 'restrictedEditOnlySubadminGroup');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedEditOnlySubadminGroup');
|
||||
$pageID = $page->ID;
|
||||
$page->doUnpublish();
|
||||
|
||||
@ -128,7 +134,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
{
|
||||
// Find a page that exists and delete it from both stage and published
|
||||
$this->logInWithPermission("ADMIN");
|
||||
$page = $this->objFromFixture('Page', 'restrictedEditOnlySubadminGroup');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedEditOnlySubadminGroup');
|
||||
$pageID = $page->ID;
|
||||
$page->doUnpublish();
|
||||
$page->delete();
|
||||
@ -145,11 +151,10 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testCanViewStage()
|
||||
{
|
||||
$this->useDraftSite(false); // useDraftSite deliberately disables checking the stage as part of canView
|
||||
|
||||
// Get page & make sure it exists on Live
|
||||
$page = $this->objFromFixture('Page', 'standardpage');
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
/** @var Page $page */
|
||||
$page = $this->objFromFixture(Page::class, 'standardpage');
|
||||
$page->publishSingle();
|
||||
|
||||
// Then make sure there's a new version on Stage
|
||||
$page->Title = 1;
|
||||
@ -163,13 +168,11 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
$this->assertTrue($page->canViewStage('Live', $editor));
|
||||
$this->assertTrue($page->canViewStage('Stage', $editor));
|
||||
|
||||
$this->useDraftSite();
|
||||
}
|
||||
|
||||
public function testAccessTabOnlyDisplaysWithGrantAccessPermissions()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'standardpage');
|
||||
$page = $this->objFromFixture(Page::class, 'standardpage');
|
||||
|
||||
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
|
||||
Security::setCurrentUser($subadminuser);
|
||||
@ -200,7 +203,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedViewLoggedInUsers()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'restrictedViewLoggedInUsers');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedViewLoggedInUsers');
|
||||
|
||||
// unauthenticated users
|
||||
$this->assertFalse(
|
||||
@ -233,7 +236,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedViewOnlyTheseUsers()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'restrictedViewOnlyWebsiteUsers');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedViewOnlyWebsiteUsers');
|
||||
|
||||
// unauthenticcated users
|
||||
$this->assertFalse(
|
||||
@ -281,7 +284,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedEditLoggedInUsers()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'restrictedEditLoggedInUsers');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedEditLoggedInUsers');
|
||||
|
||||
// unauthenticcated users
|
||||
$this->assertFalse(
|
||||
@ -307,7 +310,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedEditOnlySubadminGroup()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'restrictedEditOnlySubadminGroup');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedEditOnlySubadminGroup');
|
||||
|
||||
// unauthenticated users
|
||||
$this->assertFalse(
|
||||
@ -332,8 +335,8 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedViewInheritance()
|
||||
{
|
||||
$parentPage = $this->objFromFixture('Page', 'parent_restrictedViewOnlySubadminGroup');
|
||||
$childPage = $this->objFromFixture('Page', 'child_restrictedViewOnlySubadminGroup');
|
||||
$parentPage = $this->objFromFixture(Page::class, 'parent_restrictedViewOnlySubadminGroup');
|
||||
$childPage = $this->objFromFixture(Page::class, 'child_restrictedViewOnlySubadminGroup');
|
||||
|
||||
// unauthenticated users
|
||||
$this->assertFalse(
|
||||
@ -366,8 +369,8 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedEditInheritance()
|
||||
{
|
||||
$parentPage = $this->objFromFixture('Page', 'parent_restrictedEditOnlySubadminGroup');
|
||||
$childPage = $this->objFromFixture('Page', 'child_restrictedEditOnlySubadminGroup');
|
||||
$parentPage = $this->objFromFixture(Page::class, 'parent_restrictedEditOnlySubadminGroup');
|
||||
$childPage = $this->objFromFixture(Page::class, 'child_restrictedEditOnlySubadminGroup');
|
||||
|
||||
// unauthenticated users
|
||||
$this->assertFalse(
|
||||
@ -385,8 +388,8 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testDeleteRestrictedChild()
|
||||
{
|
||||
$parentPage = $this->objFromFixture('Page', 'deleteTestParentPage');
|
||||
$childPage = $this->objFromFixture('Page', 'deleteTestChildPage');
|
||||
$parentPage = $this->objFromFixture(Page::class, 'deleteTestParentPage');
|
||||
$childPage = $this->objFromFixture(Page::class, 'deleteTestChildPage');
|
||||
|
||||
// unauthenticated users
|
||||
$this->assertFalse(
|
||||
@ -401,7 +404,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testRestrictedEditLoggedInUsersDeletedFromStage()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'restrictedEditLoggedInUsers');
|
||||
$page = $this->objFromFixture(Page::class, 'restrictedEditLoggedInUsers');
|
||||
$pageID = $page->ID;
|
||||
|
||||
$this->logInWithPermission("ADMIN");
|
||||
@ -423,7 +426,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testInheritCanViewFromSiteConfig()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
|
||||
$page = $this->objFromFixture(Page::class, 'inheritWithNoParent');
|
||||
$siteconfig = $this->objFromFixture(SiteConfig::class, 'default');
|
||||
$editor = $this->objFromFixture(Member::class, 'editor');
|
||||
$editorGroup = $this->objFromFixture(Group::class, 'editorgroup');
|
||||
@ -449,7 +452,7 @@ class SiteTreePermissionsTest extends FunctionalTest
|
||||
|
||||
public function testInheritCanEditFromSiteConfig()
|
||||
{
|
||||
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
|
||||
$page = $this->objFromFixture(Page::class, 'inheritWithNoParent');
|
||||
$siteconfig = $this->objFromFixture(SiteConfig::class, 'default');
|
||||
$editor = $this->objFromFixture(Member::class, 'editor');
|
||||
$user = $this->objFromFixture(Member::class, 'websiteuser');
|
||||
|
@ -612,12 +612,8 @@ class SiteTreeTest extends SapphireTest
|
||||
Versioned::reading_archived_date($date);
|
||||
SiteTree::get()->where(array(
|
||||
'"SiteTree"."ParentID"' => 0
|
||||
));
|
||||
Versioned::reading_archived_date(null);
|
||||
$this->assertEquals(
|
||||
Versioned::get_reading_mode(),
|
||||
'Archive.'
|
||||
);
|
||||
))->sql($args);
|
||||
$this->assertContains($date, $args);
|
||||
}
|
||||
|
||||
public function testEditPermissions()
|
||||
|
@ -17,7 +17,7 @@ use SilverStripe\Versioned\Versioned;
|
||||
class VirtualPageTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'VirtualPageTest.yml';
|
||||
protected static $use_draft_site = false;
|
||||
|
||||
protected $autoFollowRedirection = false;
|
||||
|
||||
protected static $extra_dataobjects = [
|
||||
@ -58,6 +58,12 @@ class VirtualPageTest extends FunctionalTest
|
||||
'non_virtual_fields',
|
||||
array('MyNonVirtualField', 'MySharedNonVirtualField')
|
||||
);
|
||||
|
||||
// Ensure all pages are published
|
||||
/** @var Page $page */
|
||||
foreach (Page::get() as $page) {
|
||||
$page->publishSingle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,11 +72,13 @@ class VirtualPageTest extends FunctionalTest
|
||||
*/
|
||||
public function testEditingSourcePageUpdatesVirtualPages()
|
||||
{
|
||||
/** @var Page $master */
|
||||
$master = $this->objFromFixture('Page', 'master');
|
||||
$master->Title = "New title";
|
||||
$master->MenuTitle = "New menutitle";
|
||||
$master->Content = "<p>New content</p>";
|
||||
$master->write();
|
||||
$master->publishSingle();
|
||||
|
||||
$vp1 = $this->objFromFixture(VirtualPage::class, 'vp1');
|
||||
$vp2 = $this->objFromFixture(VirtualPage::class, 'vp2');
|
||||
@ -619,16 +627,19 @@ class VirtualPageTest extends FunctionalTest
|
||||
|
||||
public function testVirtualPageRendersCorrectTemplate()
|
||||
{
|
||||
$this->useDraftSite(true);
|
||||
$this->useTestTheme(dirname(__FILE__), 'virtualpagetest', function () {
|
||||
$page = new VirtualPageTest_ClassA();
|
||||
$page->Title = 'Test Page';
|
||||
$page->Content = 'NotThisContent';
|
||||
$page->MyInitiallyCopiedField = 'TestContent';
|
||||
$page->write();
|
||||
$page->publishSingle();
|
||||
|
||||
$vp = new VirtualPage();
|
||||
$vp->CopyContentFromID = $page->ID;
|
||||
$vp->write();
|
||||
$vp->publishSingle();
|
||||
|
||||
$response = $this->get($vp->Link());
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertContains('TestContent', $response->getBody());
|
||||
@ -639,9 +650,13 @@ class VirtualPageTest extends FunctionalTest
|
||||
$page = new VirtualPageTest_ClassB();
|
||||
$page->Title = 'Test Page B';
|
||||
$page->write();
|
||||
$page->publishSingle();
|
||||
|
||||
$vp = new VirtualPage();
|
||||
$vp->CopyContentFromID = $page->ID;
|
||||
$vp->write();
|
||||
$vp->publishSingle();
|
||||
|
||||
$response = $this->get($vp->Link());
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertContains('Test Page B', $response->getBody());
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Search;
|
||||
|
||||
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
@ -13,12 +14,12 @@ class CMSMainSearchFormTest extends FunctionalTest
|
||||
{
|
||||
$this->session()->set('loggedInAs', $this->idFromFixture(Member::class, 'admin'));
|
||||
|
||||
$response = $this->get(
|
||||
$this->get(
|
||||
'admin/pages/SearchForm/?' .
|
||||
http_build_query(array(
|
||||
'q' => array(
|
||||
'Title' => 'Page 10',
|
||||
'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search',
|
||||
'FilterClass' => CMSSiteTreeFilter_Search::class,
|
||||
),
|
||||
'action_doSearch' => true
|
||||
))
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Tasks;
|
||||
|
||||
use SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
|
||||
@ -37,20 +38,18 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'RemoveOrphanedPagesTaskTest.yml';
|
||||
|
||||
protected static $use_draft_site = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$parent1_published = $this->objFromFixture('Page', 'parent1_published');
|
||||
$parent1_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$parent1_published->publishSingle();
|
||||
|
||||
$child1_1_published = $this->objFromFixture('Page', 'child1_1_published');
|
||||
$child1_1_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$child1_1_published->publishSingle();
|
||||
|
||||
$child1_2_published = $this->objFromFixture('Page', 'child1_2_published');
|
||||
$child1_2_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$child1_2_published->publishSingle();
|
||||
|
||||
$child1_3_orphaned = $this->objFromFixture('Page', 'child1_3_orphaned');
|
||||
$child1_3_orphaned->ParentID = 9999;
|
||||
@ -59,10 +58,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->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$child1_4_orphaned_published->publishSingle();
|
||||
|
||||
$grandchild1_1_2_published = $this->objFromFixture('Page', 'grandchild1_1_2_published');
|
||||
$grandchild1_1_2_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$grandchild1_1_2_published->publishSingle();
|
||||
|
||||
$grandchild1_1_3_orphaned = $this->objFromFixture('Page', 'grandchild1_1_3_orphaned');
|
||||
$grandchild1_1_3_orphaned->ParentID = 9999;
|
||||
@ -74,10 +73,10 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest
|
||||
);
|
||||
$grandchild1_1_4_orphaned_published->ParentID = 9999;
|
||||
$grandchild1_1_4_orphaned_published->write();
|
||||
$grandchild1_1_4_orphaned_published->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$grandchild1_1_4_orphaned_published->publishSingle();
|
||||
|
||||
$child2_1_published_orphaned = $this->objFromFixture('Page', 'child2_1_published_orphaned');
|
||||
$child2_1_published_orphaned->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$child2_1_published_orphaned->publishSingle();
|
||||
}
|
||||
|
||||
public function testGetOrphansByStage()
|
||||
@ -92,7 +91,7 @@ class RemoveOrphanedPagesTaskTest extends FunctionalTest
|
||||
);
|
||||
$child2_1_published_orphaned = $this->objFromFixture('Page', 'child2_1_published_orphaned');
|
||||
|
||||
$task = singleton('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask');
|
||||
$task = singleton(RemoveOrphanedPagesTask::class);
|
||||
$orphans = $task->getOrphanedPages();
|
||||
$orphanIDs = $orphans->column('ID');
|
||||
sort($orphanIDs);
|
||||
|
Loading…
Reference in New Issue
Block a user