FIX CMSPageHistoryControllerTest now uses a stub controller to avoid URL conflicts with versioned-admin

This commit is contained in:
Robbie Averill 2018-12-02 18:06:39 +00:00
parent 29a22bcb52
commit 602597b900
2 changed files with 25 additions and 9 deletions

View File

@ -4,8 +4,8 @@ namespace SilverStripe\CMS\Tests\Controllers;
use Page;
use SilverStripe\CMS\Controllers\CMSPageHistoryController;
use SilverStripe\CMS\Tests\Controllers\CMSPageHistoryControllerTest\HistoryController;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Forms\FieldGroup;
@ -24,7 +24,11 @@ class CMSPageHistoryControllerTest extends FunctionalTest
protected $versionPublishCheck2;
protected $page;
public function setUp()
protected static $extra_controllers = [
CMSPageHistoryControllerTest\HistoryController::class,
];
protected function setUp()
{
parent::setUp();
@ -33,9 +37,6 @@ class CMSPageHistoryControllerTest extends FunctionalTest
CMSPageHistoryController::class
);
// Bump to avoid loading any customised controllers
Config::modify()->set(CMSPageHistoryController::class, 'url_priority', 50);
$this->loginWithPermission('ADMIN');
// creates a series of published, unpublished versions of a page
@ -107,7 +108,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest
*/
public function testVersionsForm()
{
$this->get('admin/pages/history/show/'. $this->page->ID);
$this->get('admin/pages/legacyhistory/show/'. $this->page->ID . '?flush');
$form = $this->cssParser()->getBySelector('#Form_VersionsForm');
$this->assertEquals(1, count($form));
@ -125,7 +126,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest
public function testVersionsFormTableContainsInformation()
{
$this->get('admin/pages/history/show/'. $this->page->ID);
$this->get('admin/pages/legacyhistory/show/'. $this->page->ID);
$form = $this->cssParser()->getBySelector('#Form_VersionsForm');
$rows = $form[0]->xpath("fieldset/table/tbody/tr");
@ -151,7 +152,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest
public function testVersionsFormSelectsUnpublishedCheckbox()
{
$this->get('admin/pages/history/show/'. $this->page->ID);
$this->get('admin/pages/legacyhistory/show/'. $this->page->ID);
$checkbox = $this->cssParser()->getBySelector('#Form_VersionsForm_ShowUnpublished');
$this->assertThat($checkbox[0], $this->logicalNot($this->isNull()));
@ -160,7 +161,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest
$this->assertThat($checked, $this->logicalNot($this->stringContains('checked')));
// viewing an unpublished
$this->get('admin/pages/history/show/'.$this->page->ID .'/'.$this->versionUnpublishedCheck);
$this->get('admin/pages/legacyhistory/show/'.$this->page->ID .'/'.$this->versionUnpublishedCheck);
$checkbox = $this->cssParser()->getBySelector('#Form_VersionsForm_ShowUnpublished');
$this->assertThat($checkbox[0], $this->logicalNot($this->isNull()));

View File

@ -0,0 +1,15 @@
<?php
namespace SilverStripe\CMS\Tests\Controllers\CMSPageHistoryControllerTest;
use SilverStripe\CMS\Controllers\CMSPageHistoryController;
use SilverStripe\Dev\TestOnly;
/**
* Used to circumvent potential URL conflicts with the silverstripe/versioned-admin history viewer controller
* when running unit tests on the legacy CMSPageHistoryController.
*/
class HistoryController extends CMSPageHistoryController implements TestOnly
{
private static $url_segment = 'pages/legacyhistory';
}