Skip to content

Commit

Permalink
FIX CMSPageHistoryControllerTest now uses a stub controller to avoid …
Browse files Browse the repository at this point in the history
…URL conflicts with versioned-admin
  • Loading branch information
robbieaverill authored and Aaron Carlino committed Dec 11, 2018
1 parent 32c0b57 commit c28f5ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/php/Controllers/CMSPageHistoryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Page;
use SilverStripe\CMS\Controllers\CMSPageHistoryController;
use SilverStripe\CMS\Tests\Controllers\CMSPageHistoryControllerTest\HistoryController;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FunctionalTest;
Expand All @@ -23,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();

Expand Down Expand Up @@ -103,7 +108,7 @@ public function testGetEditForm()
*/
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));
Expand All @@ -121,7 +126,7 @@ public function testVersionsForm()

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");

Expand All @@ -147,7 +152,7 @@ public function testVersionsFormTableContainsInformation()

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()));
Expand All @@ -156,7 +161,7 @@ public function testVersionsFormSelectsUnpublishedCheckbox()
$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()));
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
}

0 comments on commit c28f5ad

Please sign in to comment.