mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-06-29 07:59:37 +02:00
Merge pull request #1297 from patricknelson/issue-586-delete-validation-3.2
FIX for #586 and possible fix for #736 and relates to #2449: Don't perform validation upon deletion, since it isn't necessary.
This commit is contained in:
commit
bc669311dd
|
@ -593,7 +593,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||
/**
|
||||
* @param int $id
|
||||
* @param FieldList $fields
|
||||
* @return Form
|
||||
* @return CMSForm
|
||||
*/
|
||||
public function getEditForm($id = null, $fields = null) {
|
||||
|
||||
|
@ -676,7 +676,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||
// if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
||||
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
|
||||
// Set validation exemptions for specific actions
|
||||
$form->setValidationExemptActions(array('restore', 'revert', 'deletefromlive', 'rollback'));
|
||||
$form->setValidationExemptActions(array('restore', 'revert', 'deletefromlive', 'delete', 'unpublish', 'rollback'));
|
||||
|
||||
// Announce the capability so the frontend can decide whether to allow preview or not.
|
||||
if(in_array('CMSPreviewable', class_implements($record))) {
|
||||
|
|
|
@ -62,7 +62,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
$pageB->write();
|
||||
|
||||
// Check query
|
||||
$response = $this->get('CMSMain/childfilter?ParentID='.$pageA->ID);
|
||||
$response = $this->get('CMSMain/childfilter?ParentID=' . $pageA->ID);
|
||||
$children = json_decode($response->getBody());
|
||||
$this->assertFalse($response->isError());
|
||||
|
||||
|
@ -99,7 +99,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
|
||||
// Some modules (e.g., cmsworkflow) will remove this action
|
||||
$actions = CMSBatchActionHandler::config()->batch_actions;
|
||||
if(isset($actions['publish'])) {
|
||||
if (isset($actions['publish'])) {
|
||||
$response = $this->get('admin/pages/batchactions/publish?ajax=1&csvIDs=' . implode(',', array($page1->ID, $page2->ID)));
|
||||
$responseData = Convert::json2array($response->getBody());
|
||||
$this->assertArrayHasKey($page1->ID, $responseData['modified']);
|
||||
|
@ -160,10 +160,10 @@ class CMSMainTest extends FunctionalTest {
|
|||
$classes = ClassInfo::subclassesFor("SiteTree");
|
||||
array_shift($classes);
|
||||
|
||||
foreach($classes as $class) {
|
||||
foreach ($classes as $class) {
|
||||
$page = new $class();
|
||||
if($page instanceof TestOnly) continue;
|
||||
if(!$page->stat('can_be_root')) continue;
|
||||
if ($page instanceof TestOnly) continue;
|
||||
if (!$page->stat('can_be_root')) continue;
|
||||
|
||||
$page->Title = "Test $class page";
|
||||
$page->write();
|
||||
|
@ -178,8 +178,8 @@ class CMSMainTest extends FunctionalTest {
|
|||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
||||
$parentPage = $this->objFromFixture('Page','page3');
|
||||
$childPage = $this->objFromFixture('Page','page1');
|
||||
$parentPage = $this->objFromFixture('Page', 'page3');
|
||||
$childPage = $this->objFromFixture('Page', 'page1');
|
||||
|
||||
$parentPage->doUnpublish();
|
||||
$childPage->doUnpublish();
|
||||
|
@ -200,7 +200,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
||||
|
||||
// Set up a page that is delete from live
|
||||
$page = $this->objFromFixture('Page','page1');
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$pageID = $page->ID;
|
||||
$page->doPublish();
|
||||
$page->delete();
|
||||
|
@ -222,7 +222,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
*/
|
||||
public function testGetRecord() {
|
||||
// Set up a page that is delete from live
|
||||
$page1 = $this->objFromFixture('Page','page1');
|
||||
$page1 = $this->objFromFixture('Page', 'page1');
|
||||
$page1ID = $page1->ID;
|
||||
$page1->doPublish();
|
||||
$page1->delete();
|
||||
|
@ -235,7 +235,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
|
||||
// Pages that are on draft and aren't on draft should both work
|
||||
$this->assertInstanceOf('Page', $cmsMain->getRecord($page1ID));
|
||||
$this->assertInstanceOf('Page', $cmsMain->getRecord($this->idFromFixture('Page','page2')));
|
||||
$this->assertInstanceOf('Page', $cmsMain->getRecord($this->idFromFixture('Page', 'page2')));
|
||||
|
||||
// This functionality isn't actually used any more.
|
||||
$newPage = $cmsMain->getRecord('new-Page-5');
|
||||
|
@ -251,7 +251,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
$this->assertEquals(200, $result->getStatusCode());
|
||||
}
|
||||
|
||||
public function testCreationOfTopLevelPage(){
|
||||
public function testCreationOfTopLevelPage() {
|
||||
$origFollow = $this->autoFollowRedirection;
|
||||
$this->autoFollowRedirection = false;
|
||||
|
||||
|
@ -295,14 +295,14 @@ class CMSMainTest extends FunctionalTest {
|
|||
|
||||
$location = $response->getHeader('X-ControllerURL');
|
||||
$this->assertNotEmpty($location, 'Must be a redirect on success');
|
||||
$this->assertContains('/show/',$location, 'Must redirect to /show/ the new page');
|
||||
$this->assertContains('/show/', $location, 'Must redirect to /show/ the new page');
|
||||
// TODO Logout
|
||||
$this->session()->inst_set('loggedInAs', NULL);
|
||||
|
||||
$this->autoFollowRedirection = $origFollow;
|
||||
}
|
||||
|
||||
public function testCreationOfRestrictedPage(){
|
||||
public function testCreationOfRestrictedPage() {
|
||||
$origFollow = $this->autoFollowRedirection;
|
||||
$this->autoFollowRedirection = false;
|
||||
|
||||
|
@ -375,7 +375,7 @@ class CMSMainTest extends FunctionalTest {
|
|||
$id = 'new-Member-0';
|
||||
$member = $controller->getNewItem($id, false);
|
||||
$this->fail('Should not be able to create a Member object');
|
||||
} catch(SS_HTTPResponse_Exception $e) {
|
||||
} catch (SS_HTTPResponse_Exception $e) {
|
||||
$this->assertEquals($controller->getResponse()->getStatusCode(), 302);
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +465,25 @@ class CMSMainTest extends FunctionalTest {
|
|||
$pages->column('Title')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing retrieval and type of CMS edit form.
|
||||
*/
|
||||
public function testGetEditForm() {
|
||||
// Login is required prior to accessing a CMS form.
|
||||
$this->loginWithPermission('ADMIN');
|
||||
|
||||
// Get a associated with a fixture page.
|
||||
$page = $this->objFromFixture('Page', 'page1');
|
||||
$controller = new CMSMain();
|
||||
$form = $controller->getEditForm($page->ID);
|
||||
$this->assertInstanceOf("CMSForm", $form);
|
||||
|
||||
// Ensure that the form will not "validate" on delete or "unpublish" actions.
|
||||
$exemptActions = $form->getValidationExemptActions();
|
||||
$this->assertContains("delete", $exemptActions);
|
||||
$this->assertContains("unpublish", $exemptActions);
|
||||
}
|
||||
}
|
||||
|
||||
class CMSMainTest_ClassA extends Page implements TestOnly {
|
||||
|
|
Loading…
Reference in New Issue
Block a user