mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Manual fixes to automatic namespacing
This commit is contained in:
parent
9f268a18b5
commit
4f6af36369
@ -61,7 +61,7 @@ before_script:
|
||||
- if [[ $BEHAT_TEST ]]; then (vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi
|
||||
|
||||
script:
|
||||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests flush=1; fi
|
||||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/php/ flush=1; fi
|
||||
- if [[ $BEHAT_TEST ]]; then vendor/bin/behat @cms; fi
|
||||
- if [[ $NPM_TEST ]]; then git diff-files --quiet -w --relative=client; fi
|
||||
- if [[ $NPM_TEST ]]; then git diff -w --no-color --relative=client; fi
|
||||
|
@ -40,14 +40,16 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "phpcs -s code/ tests/"
|
||||
"lint": "phpcs -s code/ tests/php/ tests/behat/src/",
|
||||
"lint-clean": "phpcbf code/ tests/php/ tests/behat/src/"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SilverStripe\\CMS\\": "code/",
|
||||
"SilverStripe\\CMS\\Tests\\": "code/php/",
|
||||
"SilverStripe\\CMS\\Tests\\Behaviour\\": "tests/behat/src/"
|
||||
}
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,6 @@
|
||||
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
|
||||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
|
||||
<exclude name="Generic.Files.LineLength.TooLong" />
|
||||
|
||||
<!-- CMS specific exclusions (high priority to fix) -->
|
||||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
|
||||
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\BatchActions\CMSBatchAction_Archive;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
@ -11,8 +10,6 @@ use SilverStripe\CMS\BatchActions\CMSBatchAction_Restore;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests CMS Specific subclasses of {@see CMSBatchAction}
|
||||
*/
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use Page;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use SilverStripe\Admin\CMSBatchActionHandler;
|
||||
use SilverStripe\CMS\Controllers\CMSMain;
|
||||
@ -19,21 +19,13 @@ use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\HiddenClass;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class CMSMainTest extends FunctionalTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'CMSMainTest.yml';
|
||||
|
||||
static protected $orig = array();
|
||||
@ -55,11 +47,11 @@ class CMSMainTest extends FunctionalTest
|
||||
{
|
||||
$cache = Injector::inst()->get(CacheInterface::class . '.CMSMain_SiteTreeHints');
|
||||
// Login as user with root creation privileges
|
||||
$user = $this->objFromFixture('SilverStripe\\Security\\Member', 'rootedituser');
|
||||
$user = $this->objFromFixture(Member::class, 'rootedituser');
|
||||
Security::setCurrentUser($user);
|
||||
$cache->clear();
|
||||
|
||||
$rawHints = singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->SiteTreeHints();
|
||||
$rawHints = singleton(CMSMain::class)->SiteTreeHints();
|
||||
$this->assertNotNull($rawHints);
|
||||
|
||||
$rawHints = preg_replace('/^"(.*)"$/', '$1', Convert::xml2raw($rawHints));
|
||||
@ -70,25 +62,25 @@ class CMSMainTest extends FunctionalTest
|
||||
$this->assertArrayHasKey('All', $hints);
|
||||
|
||||
$this->assertArrayHasKey(
|
||||
'CMSMainTest_ClassA',
|
||||
CMSMainTest_ClassA::class,
|
||||
$hints['All'],
|
||||
'Global list shows allowed classes'
|
||||
);
|
||||
|
||||
$this->assertArrayNotHasKey(
|
||||
'CMSMainTest_HiddenClass',
|
||||
CMSMainTest_HiddenClass::class,
|
||||
$hints['All'],
|
||||
'Global list does not list hidden classes'
|
||||
);
|
||||
|
||||
$this->assertNotContains(
|
||||
'CMSMainTest_ClassA',
|
||||
CMSMainTest_ClassA::class,
|
||||
$hints['Root']['disallowedChildren'],
|
||||
'Limits root classes'
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
'CMSMainTest_NotRoot',
|
||||
CMSMainTest_NotRoot::class,
|
||||
$hints['Root']['disallowedChildren'],
|
||||
'Limits root classes'
|
||||
);
|
||||
@ -118,7 +110,7 @@ class CMSMainTest extends FunctionalTest
|
||||
|
||||
// But it can create a ClassB
|
||||
$this->assertNotContains(
|
||||
'CMSMainTest_ClassB',
|
||||
CMSMainTest_ClassB::class,
|
||||
$children,
|
||||
'Limited parent omits explicitly allowed classes in disallowedChildren'
|
||||
);
|
||||
@ -131,7 +123,7 @@ class CMSMainTest extends FunctionalTest
|
||||
{
|
||||
$page1 = $this->objFromFixture(Page::class, "page1");
|
||||
$page2 = $this->objFromFixture(Page::class, "page2");
|
||||
$this->session()->set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
||||
$this->session()->set('loggedInAs', $this->idFromFixture(Member::class, 'admin'));
|
||||
|
||||
$response = $this->get('admin/pages/publishall?confirm=1');
|
||||
$this->assertContains(
|
||||
@ -283,8 +275,8 @@ class CMSMainTest extends FunctionalTest
|
||||
$origFollow = $this->autoFollowRedirection;
|
||||
$this->autoFollowRedirection = false;
|
||||
|
||||
$cmsUser = $this->objFromFixture('SilverStripe\\Security\\Member', 'allcmssectionsuser');
|
||||
$rootEditUser = $this->objFromFixture('SilverStripe\\Security\\Member', 'rootedituser');
|
||||
$cmsUser = $this->objFromFixture(Member::class, 'allcmssectionsuser');
|
||||
$rootEditUser = $this->objFromFixture(Member::class, 'rootedituser');
|
||||
|
||||
// with insufficient permissions
|
||||
Security::setCurrentUser($cmsUser);
|
||||
@ -337,7 +329,7 @@ class CMSMainTest extends FunctionalTest
|
||||
$origFollow = $this->autoFollowRedirection;
|
||||
$this->autoFollowRedirection = false;
|
||||
|
||||
$adminUser = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
$adminUser = $this->objFromFixture(Member::class, 'admin');
|
||||
Security::setCurrentUser($adminUser);
|
||||
|
||||
// Create toplevel page
|
||||
@ -346,7 +338,7 @@ class CMSMainTest extends FunctionalTest
|
||||
'admin/pages/add/AddForm',
|
||||
array(
|
||||
'ParentID' => '0',
|
||||
'PageType' => 'CMSMainTest_ClassA',
|
||||
'PageType' => CMSMainTest_ClassA::class,
|
||||
'Locale' => 'en_US',
|
||||
'action_doAdd' => 1,
|
||||
'ajax' => 1
|
||||
@ -366,7 +358,7 @@ class CMSMainTest extends FunctionalTest
|
||||
'admin/pages/add/AddForm',
|
||||
array(
|
||||
'ParentID' => $newPageId,
|
||||
'PageType' => 'CMSMainTest_ClassB',
|
||||
'PageType' => CMSMainTest_ClassB::class,
|
||||
'Locale' => 'en_US',
|
||||
'action_doAdd' => 1,
|
||||
'ajax' => 1
|
||||
@ -412,7 +404,7 @@ class CMSMainTest extends FunctionalTest
|
||||
{
|
||||
$page3 = $this->objFromFixture(Page::class, 'page3');
|
||||
$page31 = $this->objFromFixture(Page::class, 'page31');
|
||||
$adminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
$adminuser = $this->objFromFixture(Member::class, 'admin');
|
||||
Security::setCurrentUser($adminuser);
|
||||
|
||||
$response = $this->get('admin/pages/edit/show/' . $page31->ID);
|
||||
@ -572,17 +564,17 @@ class CMSMainTest extends FunctionalTest
|
||||
$page->write();
|
||||
|
||||
$form = $cms->getEditForm($page->ID);
|
||||
$form->loadDataFrom(['ClassName' => 'CMSMainTest_ClassB']);
|
||||
$form->loadDataFrom(['ClassName' => CMSMainTest_ClassB::class]);
|
||||
$result = $cms->save([
|
||||
'ID' => $page->ID,
|
||||
'ClassName' => 'CMSMainTest_ClassB'
|
||||
'ClassName' => CMSMainTest_ClassB::class
|
||||
], $form);
|
||||
$this->assertEquals(200, $result->getStatusCode());
|
||||
|
||||
$newPage = SiteTree::get()->byID($page->ID);
|
||||
|
||||
$this->assertInstanceOf('CMSMainTest_ClassB', $newPage);
|
||||
$this->assertEquals('CMSMainTest_ClassB', $newPage->ClassName);
|
||||
$this->assertInstanceOf(CMSMainTest_ClassB::class, $newPage);
|
||||
$this->assertEquals(CMSMainTest_ClassB::class, $newPage->ClassName);
|
||||
$this->assertEquals('Class A', $newPage->Title);
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use Page;
|
||||
|
||||
|
||||
class CMSMainTest_ClassA extends Page implements TestOnly
|
||||
{
|
||||
private static $allowed_children = array('CMSMainTest_ClassB');
|
||||
private static $table_name = 'CMSMainTest_ClassA';
|
||||
|
||||
private static $allowed_children = array(CMSMainTest_ClassB::class);
|
||||
|
||||
protected function onBeforeWrite()
|
||||
{
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use Page;
|
||||
|
||||
|
||||
class CMSMainTest_ClassB extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'CMSMainTest_ClassB';
|
||||
|
||||
protected function onBeforeWrite()
|
||||
{
|
||||
parent::onBeforeWrite();
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\HiddenClass;
|
||||
use Page;
|
||||
|
||||
|
||||
class CMSMainTest_HiddenClass extends Page implements TestOnly, HiddenClass
|
||||
{
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class CMSMainTest_NotRoot extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'CMSMainTest_NotRoot';
|
||||
|
||||
private static $can_be_root = false;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Forms\FieldGroup;
|
||||
@ -14,11 +13,6 @@ use SilverStripe\CMS\Controllers\CMSPageHistoryController;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class CMSPageHistoryControllerTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'CMSPageHistoryControllerTest.yml';
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
@ -13,8 +12,6 @@ use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusRemovedFromDraftPages;
|
||||
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDeletedPages;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
|
||||
class CMSSiteTreeFilterTest extends SapphireTest
|
||||
{
|
||||
|
||||
@ -113,7 +110,7 @@ class CMSSiteTreeFilterTest extends SapphireTest
|
||||
$deletedPageID = $deletedPage->ID;
|
||||
$deletedPage->delete();
|
||||
$deletedPage = Versioned::get_one_by_stage(
|
||||
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||
SiteTree::class,
|
||||
'Live',
|
||||
array('"SiteTree_Live"."ID"' => $deletedPageID)
|
||||
);
|
||||
@ -130,7 +127,7 @@ class CMSSiteTreeFilterTest extends SapphireTest
|
||||
{
|
||||
$draftPage = $this->objFromFixture('Page', 'page4');
|
||||
$draftPage = Versioned::get_one_by_stage(
|
||||
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||
SiteTree::class,
|
||||
'Stage',
|
||||
sprintf('"SiteTree"."ID" = %d', $draftPage->ID)
|
||||
);
|
||||
@ -168,7 +165,7 @@ class CMSSiteTreeFilterTest extends SapphireTest
|
||||
$removedDraftPage->publishRecursive();
|
||||
$removedDraftPage->deleteFromStage('Stage');
|
||||
$removedDraftPage = Versioned::get_one_by_stage(
|
||||
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||
SiteTree::class,
|
||||
'Live',
|
||||
sprintf('"SiteTree"."ID" = %d', $removedDraftPage->ID)
|
||||
);
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tests for tree-operations refactored out of LeftAndMain
|
||||
*/
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
@ -9,14 +8,8 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class ContentControllerPermissionsTest extends FunctionalTest
|
||||
{
|
||||
|
||||
protected $usesDatabase = true;
|
||||
|
||||
protected $autoFollowRedirection = false;
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
@ -11,7 +10,6 @@ use SilverStripe\ORM\Search\FulltextSearchable;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use Page;
|
||||
|
||||
|
||||
class ContentControllerSearchExtensionTest extends SapphireTest
|
||||
{
|
||||
protected static $required_extensions = array(
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
use SilverStripe\CMS\Controllers\RootURLController;
|
||||
@ -13,14 +12,8 @@ use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class ContentControllerTest extends FunctionalTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'ContentControllerTest.yml';
|
||||
|
||||
protected static $use_draft_site = true;
|
||||
@ -105,7 +98,7 @@ class ContentControllerTest extends FunctionalTest
|
||||
|
||||
$page = new ContentControllerTest_Page();
|
||||
$page->ParentID = $parentID;
|
||||
$page->Title = "Page Level $i";
|
||||
$page->Title = "Page Level $i";
|
||||
$page->URLSegment = "level-$i";
|
||||
$page->write();
|
||||
|
||||
@ -159,13 +152,11 @@ class ContentControllerTest extends FunctionalTest
|
||||
/**
|
||||
* Tests that {@link ContentController::getViewer()} chooses the correct templates.
|
||||
*
|
||||
* @covers SilverStripe\CMS\Controllers\ContentController::getViewer()
|
||||
**/
|
||||
* @covers \SilverStripe\CMS\Controllers\ContentController::getViewer()
|
||||
**/
|
||||
public function testGetViewer()
|
||||
{
|
||||
|
||||
$self = $this;
|
||||
$this->useTestTheme(dirname(__FILE__), 'controllertest', function () use ($self) {
|
||||
$this->useTestTheme(__DIR__, 'controllertest', function () {
|
||||
|
||||
// Test a page without a controller (ContentControllerTest_PageWithoutController.ss)
|
||||
$page = new ContentControllerTestPageWithoutController();
|
||||
@ -173,8 +164,8 @@ class ContentControllerTest extends FunctionalTest
|
||||
$page->write();
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $self->get($page->RelativeLink());
|
||||
$self->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody()));
|
||||
$response = $this->get($page->RelativeLink());
|
||||
$this->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody()));
|
||||
|
||||
// // This should fall over to user Page.ss
|
||||
$page = new ContentControllerTestPage();
|
||||
@ -182,8 +173,8 @@ class ContentControllerTest extends FunctionalTest
|
||||
$page->write();
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $self->get($page->RelativeLink());
|
||||
$self->assertEquals("Page", trim($response->getBody()));
|
||||
$response = $this->get($page->RelativeLink());
|
||||
$this->assertEquals("Page", trim($response->getBody()));
|
||||
|
||||
|
||||
// Test that the action template is rendered.
|
||||
@ -192,20 +183,24 @@ class ContentControllerTest extends FunctionalTest
|
||||
$page->write();
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
$response = $self->get($page->RelativeLink("test"));
|
||||
$self->assertEquals("ContentControllerTestPage_test", trim($response->getBody()));
|
||||
$response = $this->get($page->RelativeLink("test"));
|
||||
$this->assertEquals("ContentControllerTestPage_test", trim($response->getBody()));
|
||||
|
||||
// Test that an action without a template will default to the index template, which is
|
||||
// to say the default Page.ss template
|
||||
$response = $self->get($page->RelativeLink("testwithouttemplate"));
|
||||
$self->assertEquals("Page", trim($response->getBody()));
|
||||
$response = $this->get($page->RelativeLink("testwithouttemplate"));
|
||||
$this->assertEquals("Page", trim($response->getBody()));
|
||||
|
||||
// Test that an action with a template will render the both action template *and* the
|
||||
// correct parent template
|
||||
$controller = new ContentController($page);
|
||||
$viewer = $controller->getViewer('test');
|
||||
$templateList = array('ContentControllerTestPage_test', 'Page');
|
||||
$self->assertEquals(dirname(__FILE__).'/themes/controllertest/templates/ContentControllerTestPage_test.ss', $viewer->templates()['main']);
|
||||
$this->assertEquals(
|
||||
__DIR__
|
||||
. '/themes/controllertest/templates/SilverStripe/CMS/Tests/Controllers/'
|
||||
. 'ContentControllerTestPage_test.ss',
|
||||
$viewer->templates()['main']
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -21,22 +21,22 @@ SilverStripe\Security\Member:
|
||||
Surname: Administrator
|
||||
Groups: =>SilverStripe\Security\Group.admins
|
||||
|
||||
ContentControllerTest_Page:
|
||||
SilverStripe\CMS\Tests\Controllers\ContentControllerTest_Page:
|
||||
root_page:
|
||||
Title: Home Page
|
||||
URLSegment: home
|
||||
second_level_page:
|
||||
Title: Second Level Page
|
||||
URLSegment: second-level
|
||||
Parent: =>ContentControllerTest_Page.root_page
|
||||
Parent: =>SilverStripe\CMS\Tests\Controllers\ContentControllerTest_Page.root_page
|
||||
third_level_page:
|
||||
Title: Third Level Page
|
||||
URLSegment: third-level
|
||||
Parent: =>ContentControllerTest_Page.second_level_page
|
||||
Parent: =>SilverStripe\CMS\Tests\Controllers\ContentControllerTest_Page.second_level_page
|
||||
third_level_page_2:
|
||||
Title: Third Level Page Two
|
||||
URLSegment: third-level-2
|
||||
Parent: =>ContentControllerTest_Page.second_level_page
|
||||
Parent: =>SilverStripe\CMS\Tests\Controllers\ContentControllerTest_Page.second_level_page
|
||||
contact_page:
|
||||
Title: Contact Page
|
||||
URLSegment: contact
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class ContentControllerTestPage extends Page implements TestOnly
|
||||
{
|
||||
|
||||
private static $table_name = 'ContentControllerTestPage';
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use PageController;
|
||||
|
||||
|
||||
class ContentControllerTestPageController extends PageController implements TestOnly
|
||||
{
|
||||
private static $allowed_actions = array(
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class ContentControllerTestPageWithoutController extends Page implements TestOnly
|
||||
{
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class ContentControllerTest_Page extends Page implements TestOnly
|
||||
{
|
||||
|
||||
private static $table_name = 'ContentControllerTest_Page';
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use PageController;
|
||||
|
||||
|
||||
class ContentControllerTest_PageController extends PageController implements TestOnly
|
||||
{
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
@ -13,14 +12,8 @@ use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class ModelAsControllerTest extends FunctionalTest
|
||||
{
|
||||
|
||||
protected $usesDatabase = true;
|
||||
|
||||
protected $autoFollowRedirection = false;
|
||||
|
@ -1,19 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Controllers\RootURLController;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class RootURLControllerTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'RootURLControllerTest.yml';
|
||||
|
@ -1,27 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem;
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Security\Security;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
class SilverStripeNavigatorTest extends SapphireTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'CMSMainTest.yml';
|
||||
|
||||
public function testGetItems()
|
||||
@ -38,7 +25,7 @@ class SilverStripeNavigatorTest extends SapphireTest
|
||||
);
|
||||
|
||||
$this->assertContains(
|
||||
'SilverStripeNavigatorTest_TestItem',
|
||||
SilverStripeNavigatorTest_TestItem::class,
|
||||
$classes,
|
||||
'Autodiscovers new classes'
|
||||
);
|
||||
@ -54,11 +41,11 @@ class SilverStripeNavigatorTest extends SapphireTest
|
||||
$this->logInWithPermission('CMS_ACCESS_CMSMain');
|
||||
$items = $navigator->getItems();
|
||||
$classes = array_map('get_class', $items->toArray());
|
||||
$this->assertNotContains('SilverStripeNavigatorTest_ProtectedTestItem', $classes);
|
||||
$this->assertNotContains(SilverStripeNavigatorTest_ProtectedTestItem::class, $classes);
|
||||
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$items = $navigator->getItems();
|
||||
$classes = array_map('get_class', $items->toArray());
|
||||
$this->assertContains('SilverStripeNavigatorTest_ProtectedTestItem', $classes);
|
||||
$this->assertContains(SilverStripeNavigatorTest_ProtectedTestItem::class, $classes);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\Security;
|
||||
|
||||
|
||||
|
||||
class SilverStripeNavigatorTest_ProtectedTestItem extends SilverStripeNavigatorItem implements TestOnly
|
||||
{
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Controllers;
|
||||
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class SilverStripeNavigatorTest_TestItem extends SilverStripeNavigatorItem implements TestOnly
|
||||
{
|
||||
public function getTitle()
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Assets\Image;
|
||||
@ -14,10 +13,6 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* Tests link tracking to files and images.
|
||||
*/
|
||||
class FileLinkTrackingTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = "FileLinkTrackingTest.yml";
|
||||
|
@ -1,16 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\RedirectorPage;
|
||||
use SilverStripe\CMS\Model\RedirectorPageController;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class RedirectorPageTest extends FunctionalTest
|
||||
{
|
||||
@ -96,13 +91,13 @@ class RedirectorPageTest extends FunctionalTest
|
||||
public function testRedirectRespectsFinishedResponse()
|
||||
{
|
||||
$page = $this->objFromFixture(RedirectorPage::class, 'goodinternal');
|
||||
RedirectorPageController::add_extension('RedirectorPageTest_RedirectExtension');
|
||||
RedirectorPageController::add_extension(RedirectorPageTest_RedirectExtension::class);
|
||||
|
||||
$response = $this->get($page->regularLink());
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertEquals('http://www.mysite.com/foo', $response->getHeader('Location'));
|
||||
|
||||
RedirectorPageController::remove_extension('RedirectorPageTest_RedirectExtension');
|
||||
RedirectorPageController::remove_extension(RedirectorPageTest_RedirectExtension::class);
|
||||
}
|
||||
|
||||
public function testNoJSLinksAllowed()
|
||||
|
@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class RedirectorPageTest_RedirectExtension extends Extension implements TestOnly
|
||||
{
|
||||
|
||||
public function onBeforeInit()
|
||||
{
|
||||
$this->owner->redirect('/foo');
|
||||
|
@ -1,18 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use Page;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
/**
|
||||
* Possible actions:
|
||||
@ -22,9 +18,6 @@ use Page;
|
||||
* - action_archive
|
||||
* - action_rollback
|
||||
* - action_revert
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class SiteTreeActionsTest extends FunctionalTest
|
||||
{
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Security\Permission;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeActionsTest_Page extends Page implements TestOnly
|
||||
{
|
||||
public function canEdit($member = null)
|
||||
|
@ -1,19 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Control\HTTP;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTP;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
/**
|
||||
* Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking
|
||||
|
@ -1,15 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
|
||||
|
||||
class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly
|
||||
{
|
||||
private static $db = array(
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
@ -14,12 +13,8 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class SiteTreeBrokenLinksTest extends SapphireTest
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Assets\File;
|
||||
@ -11,8 +10,6 @@ use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore;
|
||||
|
||||
|
||||
|
||||
class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
{
|
||||
protected static $fixture_file = 'SiteTreeHTMLEditorFieldTest.yml';
|
||||
@ -42,11 +39,11 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
|
||||
public function testLinkTracking()
|
||||
{
|
||||
$sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||
$sitetree = $this->objFromFixture(SiteTree::class, 'home');
|
||||
$editor = new HTMLEditorField('Content');
|
||||
|
||||
$aboutID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'about');
|
||||
$contactID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'contact');
|
||||
$aboutID = $this->idFromFixture(SiteTree::class, 'about');
|
||||
$contactID = $this->idFromFixture(SiteTree::class, 'contact');
|
||||
|
||||
$editor->setValue("<a href=\"[sitetree_link,id=$aboutID]\">Example Link</a>");
|
||||
$editor->saveInto($sitetree);
|
||||
@ -82,7 +79,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
|
||||
public function testFileLinkTracking()
|
||||
{
|
||||
$sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||
$sitetree = $this->objFromFixture(SiteTree::class, 'home');
|
||||
$editor = new HTMLEditorField('Content');
|
||||
$fileID = $this->idFromFixture('SilverStripe\\Assets\\File', 'example_file');
|
||||
|
||||
@ -143,7 +140,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
|
||||
public function testImageTracking()
|
||||
{
|
||||
$sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||
$sitetree = $this->objFromFixture(SiteTree::class, 'home');
|
||||
$editor = new HTMLEditorField('Content');
|
||||
$file = $this->objFromFixture('SilverStripe\\Assets\\Image', 'example_image');
|
||||
|
||||
@ -180,7 +177,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest
|
||||
|
||||
$editor->setValue(sprintf(
|
||||
'<p><a href="[sitetree_link,id=%d]">Working Link</a></p>',
|
||||
$this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home')
|
||||
$this->idFromFixture(SiteTree::class, 'home')
|
||||
));
|
||||
$sitetree->HasBrokenLink = false;
|
||||
$editor->saveInto($sitetree);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser;
|
||||
use SilverStripe\Assets\File;
|
||||
@ -9,7 +8,6 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\Parsers\HTMLValue;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeLinkTrackingTest extends SapphireTest
|
||||
{
|
||||
|
||||
|
@ -1,24 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*
|
||||
* @todo Test canAddChildren()
|
||||
* @todo Test canCreate()
|
||||
*/
|
||||
|
@ -1,47 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use Page;
|
||||
use ReflectionMethod;
|
||||
use SilverStripe\CMS\Model\RedirectorPage;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Model\VirtualPage;
|
||||
use SilverStripe\Control\ContentNegotiator;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Security\InheritedPermissions;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\ORM\HiddenClass;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\InheritedPermissions;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Model\SiteTreeExtension;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\Parsers\HTMLCleaner;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\View\Parsers\Diff;
|
||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||
use Page;
|
||||
use ReflectionMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class SiteTreeTest extends SapphireTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'SiteTreeTest.yml';
|
||||
|
||||
protected static $illegal_extensions = array(
|
||||
@ -165,7 +152,7 @@ class SiteTreeTest extends SapphireTest
|
||||
$child = new SiteTreeTest_PageNode();
|
||||
|
||||
$child->setParent($parent);
|
||||
$this->assertInstanceOf('SiteTreeTest_PageNode', $child->Parent);
|
||||
$this->assertInstanceOf(SiteTreeTest_PageNode::class, $child->Parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -641,7 +628,7 @@ class SiteTreeTest extends SapphireTest
|
||||
$this->assertTrue(singleton(SiteTree::class)->canCreate(null, array('Parent' => singleton(SiteTree::class))));
|
||||
|
||||
//Test we don't check for allowedChildren on parent context if it's not SiteTree instance
|
||||
$this->assertTrue(singleton(SiteTree::class)->canCreate(null, ['Parent' => $this->objFromFixture('SiteTreeTest_DataObject', 'relations')]));
|
||||
$this->assertTrue(singleton(SiteTree::class)->canCreate(null, ['Parent' => $this->objFromFixture(SiteTreeTest_DataObject::class, 'relations')]));
|
||||
}
|
||||
|
||||
public function testEditPermissionsOnDraftVsLive()
|
||||
@ -696,7 +683,7 @@ class SiteTreeTest extends SapphireTest
|
||||
{
|
||||
// Necessary to avoid
|
||||
$oldCleanerClass = Diff::$html_cleaner_class;
|
||||
Diff::$html_cleaner_class = 'SiteTreeTest_NullHtmlCleaner';
|
||||
Diff::$html_cleaner_class = SiteTreeTest_NullHtmlCleaner::class;
|
||||
|
||||
$page = new Page();
|
||||
$page->write();
|
||||
@ -953,7 +940,7 @@ class SiteTreeTest extends SapphireTest
|
||||
Config::modify()->set(SiteTree::class, 'nested_urls', true);
|
||||
|
||||
$sitetree = new SiteTree();
|
||||
$sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent');
|
||||
$sitetree->ParentID = $this->idFromFixture(SiteTreeTest_Conflicted::class, 'parent');
|
||||
|
||||
$sitetree->URLSegment = 'index';
|
||||
$this->assertFalse($sitetree->validURLSegment(), 'index is not a valid URLSegment');
|
||||
@ -974,11 +961,11 @@ class SiteTreeTest extends SapphireTest
|
||||
$sitetree->URLSegment = 'unique-segment';
|
||||
$this->assertTrue($sitetree->validURLSegment());
|
||||
|
||||
SiteTree::add_extension('SiteTreeTest_Extension');
|
||||
SiteTree::add_extension(SiteTreeTest_Extension::class);
|
||||
$sitetree = new SiteTree();
|
||||
$sitetree->URLSegment = 'unique-segment';
|
||||
$this->assertFalse($sitetree->validURLSegment());
|
||||
SiteTree::remove_extension('SiteTreeTest_Extension');
|
||||
SiteTree::remove_extension(SiteTreeTest_Extension::class);
|
||||
}
|
||||
|
||||
public function testURLSegmentMultiByte()
|
||||
@ -1430,6 +1417,6 @@ class SiteTreeTest extends SapphireTest
|
||||
public function testGetControllerNameWithUnderscoresIsSupported()
|
||||
{
|
||||
$class = new SiteTreeTest_LegacyControllerName;
|
||||
$this->assertSame('SiteTreeTest_LegacyControllerName_Controller', $class->getControllerName());
|
||||
$this->assertEquals(SiteTreeTest_LegacyControllerName_Controller::class, $class->getControllerName());
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ Page:
|
||||
Title: 'Breadcrumbs 5'
|
||||
Parent: =>Page.breadcrumbs4
|
||||
|
||||
SiteTreeTest_Conflicted:
|
||||
SilverStripe\CMS\Tests\Model\SiteTreeTest_Conflicted:
|
||||
parent:
|
||||
Title: Parent
|
||||
|
||||
@ -124,7 +124,7 @@ SilverStripe\CMS\Model\RedirectorPage:
|
||||
RedirectionType: External
|
||||
ExternalURL: "http://www.google.com?a&b"
|
||||
|
||||
SiteTreeTest_DataObject:
|
||||
SilverStripe\CMS\Tests\Model\SiteTreeTest_DataObject:
|
||||
relations:
|
||||
Title: 'Linked DataObject'
|
||||
Pages: =>Page.home,=>Page.about,=>Page.staff
|
||||
Pages: =>Page.home,=>Page.about,=>Page.staff
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_AdminDenied extends Page implements TestOnly
|
||||
{
|
||||
private static $extensions = array(
|
||||
'SiteTreeTest_AdminDeniedExtension'
|
||||
);
|
||||
private static $table_name = 'SiteTreeTest_AdminDenied';
|
||||
|
||||
private static $extensions = [
|
||||
SiteTreeTest_AdminDeniedExtension::class,
|
||||
];
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An extension that can even deny actions to admins
|
||||
*/
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_ClassA extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_ClassA';
|
||||
|
||||
private static $need_permission = [
|
||||
'ADMIN',
|
||||
'CMS_ACCESS_CMSMain'
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_ClassB extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_ClassB';
|
||||
|
||||
// Also allowed subclasses
|
||||
private static $allowed_children = array(SiteTreeTest_ClassC::class);
|
||||
private static $allowed_children = [
|
||||
SiteTreeTest_ClassC::class
|
||||
];
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_ClassC extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_ClassC';
|
||||
|
||||
private static $allowed_children = array();
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class SiteTreeTest_ClassCext extends SiteTreeTest_ClassC implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_ClassCext';
|
||||
|
||||
// Override SiteTreeTest_ClassC definitions
|
||||
private static $allowed_children = array(SiteTreeTest_ClassB::class);
|
||||
private static $allowed_children = [
|
||||
SiteTreeTest_ClassB::class
|
||||
];
|
||||
}
|
||||
|
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_ClassD extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_ClassD';
|
||||
|
||||
// Only allows this class, no children classes
|
||||
private static $allowed_children = array('*SiteTreeTest_ClassC');
|
||||
private static $allowed_children = [
|
||||
'*' . SiteTreeTest_ClassC::class,
|
||||
];
|
||||
|
||||
private static $extensions = [
|
||||
'SiteTreeTest_ExtensionA',
|
||||
'SiteTreeTest_ExtensionB',
|
||||
SiteTreeTest_ExtensionA::class,
|
||||
SiteTreeTest_ExtensionB::class,
|
||||
];
|
||||
|
||||
public $canEditValue = null;
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\HiddenClass;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_ClassE extends Page implements TestOnly, HiddenClass
|
||||
{
|
||||
|
||||
private static $table_name = 'SiteTreeTest_ClassE';
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_Conflicted extends Page implements TestOnly
|
||||
{
|
||||
|
||||
private static $table_name = 'SiteTreeTest_Conflicted';
|
||||
}
|
||||
|
@ -1,15 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use PageController;
|
||||
|
||||
|
||||
class SiteTreeTest_ConflictedController extends PageController implements TestOnly
|
||||
{
|
||||
|
||||
private static $allowed_actions = array(
|
||||
'conflicted-action'
|
||||
);
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class SiteTreeTest_DataObject
|
||||
*
|
||||
@ -17,6 +14,8 @@ use SilverStripe\ORM\DataObject;
|
||||
*/
|
||||
class SiteTreeTest_DataObject extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_DataObject';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
|
||||
|
||||
class SiteTreeTest_Extension extends DataExtension implements TestOnly
|
||||
{
|
||||
public function augmentValidURLSegment()
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTreeExtension;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class SiteTreeTest_ExtensionA extends SiteTreeExtension implements TestOnly
|
||||
{
|
||||
public static $can_publish = true;
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTreeExtension;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class SiteTreeTest_ExtensionB extends SiteTreeExtension implements TestOnly
|
||||
{
|
||||
public static $can_publish = true;
|
||||
|
@ -1,16 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* An empty SiteTree instance with a controller to test that legacy controller names can still be loaded
|
||||
*/
|
||||
class SiteTreeTest_LegacyControllerName extends Page implements TestOnly
|
||||
{
|
||||
|
||||
private static $table_name = 'SiteTreeTest_LegacyControllerName';
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use PageController;
|
||||
|
||||
|
||||
class SiteTreeTest_LegacyControllerName_Controller extends PageController implements TestOnly
|
||||
{
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_NotRoot extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_NotRoot';
|
||||
|
||||
private static $can_be_root = false;
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\Parsers\HTMLCleaner;
|
||||
|
||||
|
||||
|
||||
class SiteTreeTest_NullHtmlCleaner extends HTMLCleaner implements TestOnly
|
||||
{
|
||||
public function cleanHTML($html)
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class SiteTreeTest_PageNode extends Page implements TestOnly
|
||||
{
|
||||
|
||||
private static $table_name = 'SiteTreeTest_PageNode';
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use PageController;
|
||||
|
||||
|
||||
class SiteTreeTest_PageNodeController extends PageController implements TestOnly
|
||||
{
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly
|
||||
{
|
||||
private static $table_name = 'SiteTreeTest_StageStatusInherit';
|
||||
|
||||
public function getStatusFlags($cached = true)
|
||||
{
|
||||
$flags = parent::getStatusFlags($cached);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use Page;
|
||||
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||
@ -11,6 +11,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
class VirtualPageTest extends FunctionalTest
|
||||
@ -19,23 +20,28 @@ class VirtualPageTest extends FunctionalTest
|
||||
protected static $use_draft_site = false;
|
||||
protected $autoFollowRedirection = false;
|
||||
|
||||
protected static $extra_dataobjects = array(
|
||||
'VirtualPageTest_ClassA',
|
||||
'VirtualPageTest_ClassB',
|
||||
'VirtualPageTest_ClassC',
|
||||
'VirtualPageTest_NotRoot',
|
||||
'VirtualPageTest_PageExtension',
|
||||
'VirtualPageTest_PageWithAllowedChildren',
|
||||
'VirtualPageTest_TestDBField',
|
||||
'VirtualPageTest_VirtualPageSub',
|
||||
);
|
||||
protected static $extra_dataobjects = [
|
||||
VirtualPageTest_ClassA::class,
|
||||
VirtualPageTest_ClassB::class,
|
||||
VirtualPageTest_ClassC::class,
|
||||
VirtualPageTest_NotRoot::class,
|
||||
VirtualPageTest_PageExtension::class,
|
||||
VirtualPageTest_PageWithAllowedChildren::class,
|
||||
VirtualPageTest_TestDBField::class,
|
||||
VirtualPageTest_VirtualPageSub::class,
|
||||
];
|
||||
|
||||
protected static $illegal_extensions = array(
|
||||
SiteTree::class => array('SiteTreeSubsites', 'Translatable'),
|
||||
SiteTree::class => [
|
||||
'SiteTreeSubsites',
|
||||
'Translatable'
|
||||
],
|
||||
);
|
||||
|
||||
protected static $required_extensions = array(
|
||||
SiteTree::class => array('VirtualPageTest_PageExtension')
|
||||
SiteTree::class => [
|
||||
VirtualPageTest_PageExtension::class
|
||||
]
|
||||
);
|
||||
|
||||
public function setUp()
|
||||
@ -47,7 +53,11 @@ class VirtualPageTest extends FunctionalTest
|
||||
|
||||
// Add extra fields
|
||||
Config::modify()->merge(VirtualPage::class, 'initially_copied_fields', array('MyInitiallyCopiedField'));
|
||||
Config::modify()->merge(VirtualPage::class, 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField'));
|
||||
Config::modify()->merge(
|
||||
VirtualPage::class,
|
||||
'non_virtual_fields',
|
||||
array('MyNonVirtualField', 'MySharedNonVirtualField')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,6 +91,7 @@ class VirtualPageTest extends FunctionalTest
|
||||
{
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
/** @var Page $master */
|
||||
$master = $this->objFromFixture('Page', 'master');
|
||||
$master->publishRecursive();
|
||||
|
||||
@ -89,7 +100,9 @@ class VirtualPageTest extends FunctionalTest
|
||||
$master->Content = "<p>New content</p>";
|
||||
$master->write();
|
||||
|
||||
/** @var VirtualPage $vp1 */
|
||||
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture(VirtualPage::class, 'vp1'));
|
||||
/** @var VirtualPage $vp2 */
|
||||
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture(VirtualPage::class, 'vp2'));
|
||||
$this->assertTrue($vp1->publishRecursive());
|
||||
$this->assertTrue($vp2->publishRecursive());
|
||||
@ -222,6 +235,7 @@ class VirtualPageTest extends FunctionalTest
|
||||
/** @var Page $parentPage */
|
||||
$parentPage = $this->objFromFixture('Page', 'master3');
|
||||
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
/** @var VirtualPage $virtualPage */
|
||||
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp3');
|
||||
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
$cindy = $this->objFromFixture(Member::class, 'cindy');
|
||||
@ -310,10 +324,8 @@ class VirtualPageTest extends FunctionalTest
|
||||
$vp->flushCache();
|
||||
$vp = DataObject::get_by_id(SiteTree::class, $vpID);
|
||||
$this->assertEquals($p->ID, $vp->CopyContentFromID);
|
||||
|
||||
$vpLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree"."ID" = ' . $vpID);
|
||||
$vpLive = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE)->byID($vpID);
|
||||
$this->assertNull($vpLive);
|
||||
|
||||
// Delete from draft, ensure virtual page deletion cascades
|
||||
$p->delete();
|
||||
$vp->flushCache();
|
||||
@ -336,7 +348,6 @@ class VirtualPageTest extends FunctionalTest
|
||||
|
||||
// All is fine, the virtual page doesn't have a broken link
|
||||
$this->assertFalse($vp->HasBrokenLink);
|
||||
|
||||
// Delete the source page from draft, cascades to virtual page
|
||||
$pID = $p->ID;
|
||||
$p->delete();
|
||||
@ -344,8 +355,8 @@ class VirtualPageTest extends FunctionalTest
|
||||
$vpDraft = Versioned::get_by_stage(SiteTree::class, Versioned::DRAFT)
|
||||
->byID($pID);
|
||||
$this->assertNull($vpDraft);
|
||||
|
||||
// Delete the source page form live, confirm that the virtual page has also been unpublished
|
||||
/** @var Page $pLive */
|
||||
$pLive = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE)
|
||||
->byID($pID);
|
||||
$this->assertTrue($pLive->doUnpublish());
|
||||
@ -485,14 +496,19 @@ class VirtualPageTest extends FunctionalTest
|
||||
|
||||
|
||||
$nonVirtual = $virtual;
|
||||
$nonVirtual->ClassName = 'VirtualPageTest_ClassA';
|
||||
$nonVirtual->ClassName = VirtualPageTest_ClassA::class;
|
||||
$nonVirtual->MySharedNonVirtualField = 'changed on new type';
|
||||
$nonVirtual->write(); // not publishing the page type change here
|
||||
|
||||
// Stage record is changed to the new type and no longer acts as a virtual page
|
||||
$nonVirtualStage = Versioned::get_one_by_stage(SiteTree::class, 'Stage', '"SiteTree"."ID" = ' . $nonVirtual->ID, false);
|
||||
$nonVirtualStage = Versioned::get_one_by_stage(
|
||||
SiteTree::class,
|
||||
'Stage',
|
||||
'"SiteTree"."ID" = ' . $nonVirtual->ID,
|
||||
false
|
||||
);
|
||||
$this->assertNotNull($nonVirtualStage);
|
||||
$this->assertEquals('VirtualPageTest_ClassA', $nonVirtualStage->ClassName);
|
||||
$this->assertEquals(VirtualPageTest_ClassA::class, $nonVirtualStage->ClassName);
|
||||
$this->assertEquals('changed on new type', $nonVirtualStage->MySharedNonVirtualField);
|
||||
$this->assertEquals(
|
||||
'original',
|
||||
@ -501,9 +517,14 @@ class VirtualPageTest extends FunctionalTest
|
||||
);
|
||||
|
||||
// Virtual page on live keeps working as it should
|
||||
$virtualLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
|
||||
$virtualLive = Versioned::get_one_by_stage(
|
||||
SiteTree::class,
|
||||
Versioned::LIVE,
|
||||
'"SiteTree_Live"."ID" = ' . $virtual->ID,
|
||||
false
|
||||
);
|
||||
$this->assertNotNull($virtualLive);
|
||||
$this->assertEquals('VirtualPageTest_VirtualPageSub', $virtualLive->ClassName);
|
||||
$this->assertEquals(VirtualPageTest_VirtualPageSub::class, $virtualLive->ClassName);
|
||||
$this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField);
|
||||
$this->assertEquals('published title', $virtualLive->Title);
|
||||
|
||||
@ -514,7 +535,12 @@ class VirtualPageTest extends FunctionalTest
|
||||
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||
|
||||
// Virtual page only notices changes to virtualised fields (Title)
|
||||
$virtualLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree_Live"."ID" = ' . $virtual->ID, false);
|
||||
$virtualLive = Versioned::get_one_by_stage(
|
||||
SiteTree::class,
|
||||
Versioned::LIVE,
|
||||
'"SiteTree_Live"."ID" = ' . $virtual->ID,
|
||||
false
|
||||
);
|
||||
$this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField);
|
||||
$this->assertEquals('title changed on original', $virtualLive->Title);
|
||||
}
|
||||
@ -528,7 +554,7 @@ class VirtualPageTest extends FunctionalTest
|
||||
$virtual->CopyContentFromID = $page->ID;
|
||||
$virtual->write();
|
||||
|
||||
$this->assertEquals('VirtualPageTest_TestDBField', $virtual->castingHelper('CastingTest'));
|
||||
$this->assertEquals(VirtualPageTest_TestDBField::class, $virtual->castingHelper('CastingTest'));
|
||||
$this->assertEquals('SOME CONTENT', $virtual->obj('CastingTest')->forTemplate());
|
||||
}
|
||||
|
||||
@ -611,10 +637,11 @@ class VirtualPageTest extends FunctionalTest
|
||||
|
||||
public function testMethod()
|
||||
{
|
||||
/** @var VirtualPage $virtualPage */
|
||||
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp4');
|
||||
/** @var VirtualPageTest_ClassAController $controller */
|
||||
$controller = ModelAsController::controller_for($virtualPage);
|
||||
|
||||
$this->assertInstanceOf('VirtualPageTest_ClassAController', $controller);
|
||||
$this->assertInstanceOf(VirtualPageTest_ClassAController::class, $controller);
|
||||
$this->assertTrue($controller->hasMethod('testMethod'));
|
||||
$this->assertEquals('hello', $controller->testMethod());
|
||||
$this->assertTrue($controller->hasMethod('modelMethod'));
|
||||
@ -623,6 +650,7 @@ class VirtualPageTest extends FunctionalTest
|
||||
|
||||
public function testAllowedActions()
|
||||
{
|
||||
/** @var VirtualPage $virtualPage */
|
||||
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp4');
|
||||
$controller = ModelAsController::controller_for($virtualPage);
|
||||
$this->assertContains('testaction', $controller->allowedActions());
|
||||
|
@ -45,7 +45,7 @@ Page:
|
||||
CanEditType: OnlyTheseUsers
|
||||
CanViewType: Inherit
|
||||
EditorGroups: =>SilverStripe\Security\Group.bobgroup
|
||||
VirtualPageTest_ClassA:
|
||||
SilverStripe\CMS\Tests\Model\VirtualPageTest_ClassA:
|
||||
pagea:
|
||||
Title: 'Page A'
|
||||
Content: '<p>Content</p>'
|
||||
@ -66,5 +66,5 @@ SilverStripe\CMS\Model\VirtualPage:
|
||||
EditorGroups: =>SilverStripe\Security\Group.andrewgroup
|
||||
ViewerGroups: =>SilverStripe\Security\Group.cindygroup
|
||||
vp4:
|
||||
CopyContentFrom: =>VirtualPageTest_ClassA.pagea
|
||||
CopyContentFrom: =>SilverStripe\CMS\Tests\Model\VirtualPageTest_ClassA.pagea
|
||||
Title: 'vp4'
|
||||
|
@ -1,22 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class VirtualPageTest_ClassA extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'VirtualPageTest_ClassA';
|
||||
|
||||
private static $db = array(
|
||||
'MyInitiallyCopiedField' => 'Text',
|
||||
'MyVirtualField' => 'Text',
|
||||
'MyNonVirtualField' => 'Text',
|
||||
'CastingTest' => 'VirtualPageTest_TestDBField'
|
||||
'CastingTest' => VirtualPageTest_TestDBField::class,
|
||||
);
|
||||
|
||||
private static $allowed_children = array('VirtualPageTest_ClassB');
|
||||
private static $allowed_children = [
|
||||
VirtualPageTest_ClassB::class,
|
||||
];
|
||||
|
||||
public function modelMethod()
|
||||
{
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use PageController;
|
||||
|
||||
|
||||
class VirtualPageTest_ClassAController extends PageController implements TestOnly
|
||||
{
|
||||
private static $allowed_actions = [
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class VirtualPageTest_ClassB extends Page implements TestOnly
|
||||
{
|
||||
private static $allowed_children = array('VirtualPageTest_ClassC');
|
||||
private static $table_name = 'VirtualPageTest_ClassB';
|
||||
|
||||
private static $allowed_children = [
|
||||
VirtualPageTest_ClassC::class,
|
||||
];
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class VirtualPageTest_ClassC extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'VirtualPageTest_ClassC';
|
||||
|
||||
private static $allowed_children = array();
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class VirtualPageTest_NotRoot extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'VirtualPageTest_NotRoot';
|
||||
|
||||
private static $can_be_root = false;
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
|
||||
|
||||
class VirtualPageTest_PageExtension extends DataExtension implements TestOnly
|
||||
{
|
||||
private static $db = array(
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\VirtualPage;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use Page;
|
||||
|
||||
|
||||
class VirtualPageTest_PageWithAllowedChildren extends Page implements TestOnly
|
||||
{
|
||||
private static $table_name = 'VirtualPageTest_PageWithAllowedChildren';
|
||||
|
||||
private static $allowed_children = array(
|
||||
VirtualPageTest_ClassA::class,
|
||||
VirtualPage::class,
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||
|
||||
|
||||
|
||||
class VirtualPageTest_TestDBField extends DBVarchar implements TestOnly
|
||||
{
|
||||
public function forTemplate()
|
||||
|
@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Model;
|
||||
|
||||
use SilverStripe\CMS\Model\VirtualPage;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
|
||||
|
||||
class VirtualPageTest_VirtualPageSub extends VirtualPage implements TestOnly
|
||||
{
|
||||
private static $table_name = 'VirtualPageTest_VirtualPageSub';
|
||||
|
||||
private static $db = array(
|
||||
'MyProperty' => 'Varchar',
|
||||
);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Reports;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\ORM\DB;
|
||||
@ -18,11 +17,6 @@ use SilverStripe\Assets\File;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use Page;
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class CmsReportsTest extends SapphireTest
|
||||
{
|
||||
|
||||
@ -48,14 +42,12 @@ class CmsReportsTest extends SapphireTest
|
||||
/**
|
||||
* ASSERT whether a report is returning the correct results, based on a broken "draft" and/or "published" page.
|
||||
*
|
||||
* @parameter ss_report
|
||||
* @parameter boolean
|
||||
* @parameter boolean
|
||||
* @param Report $report
|
||||
* @param bool $isDraftBroken
|
||||
* @param bool $isPublishedBroken
|
||||
*/
|
||||
|
||||
public function isReportBroken($report, $isDraftBroken, $isPublishedBroken)
|
||||
{
|
||||
|
||||
$class = get_class($report);
|
||||
|
||||
// ASSERT that the "draft" report is returning the correct results.
|
||||
|
@ -1,20 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Search;
|
||||
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
|
||||
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
class CMSMainSearchFormTest extends FunctionalTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = '../controller/CMSMainTest.yml';
|
||||
protected static $fixture_file = '../Controllers/CMSMainTest.yml';
|
||||
|
||||
public function testTitleFilter()
|
||||
{
|
||||
$this->session()->set('loggedInAs', $this->idFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
||||
$this->session()->set('loggedInAs', $this->idFromFixture(Member::class, 'admin'));
|
||||
|
||||
$response = $this->get(
|
||||
'admin/pages/SearchForm/?' .
|
||||
|
@ -1,30 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Search;
|
||||
|
||||
use Page;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Search\SearchForm;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\MSSQL\MSSQLDatabase;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\Search\FulltextSearchable;
|
||||
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\MSSQL\MSSQLDatabase;
|
||||
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
use SilverStripe\CMS\Search\SearchForm;
|
||||
use SilverStripe\ORM\Search\FulltextSearchable;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage testing
|
||||
*
|
||||
* @todo Fix unpublished pages check in testPublishedPagesMatchedByTitle()
|
||||
* @todo All tests run on unpublished pages at the moment, due to the searchform not distinguishing between them
|
||||
*
|
||||
|
@ -1,21 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
namespace SilverStripe\CMS\Tests\Tasks;
|
||||
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Tasks\MigrateSiteTreeLinkingTask;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class MigrateSiteTreeLinkingTaskTest extends SapphireTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'MigrateSiteTreeLinkingTaskTest.yml';
|
||||
|
||||
protected static $use_draft_site = true;
|
||||
@ -34,11 +27,11 @@ class MigrateSiteTreeLinkingTaskTest extends SapphireTest
|
||||
);
|
||||
ob_end_clean();
|
||||
|
||||
$homeID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home');
|
||||
$aboutID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'about');
|
||||
$staffID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'staff');
|
||||
$actionID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'action');
|
||||
$hashID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'hash_link');
|
||||
$homeID = $this->idFromFixture(SiteTree::class, 'home');
|
||||
$aboutID = $this->idFromFixture(SiteTree::class, 'about');
|
||||
$staffID = $this->idFromFixture(SiteTree::class, 'staff');
|
||||
$actionID = $this->idFromFixture(SiteTree::class, 'action');
|
||||
$hashID = $this->idFromFixture(SiteTree::class, 'hash_link');
|
||||
|
||||
$homeContent = sprintf(
|
||||
'<a href="[sitetree_link,id=%d]">About</a><a href="[sitetree_link,id=%d]">Staff</a><a href="http://silverstripe.org/">External Link</a><a name="anchor"></a>',
|
||||
@ -67,25 +60,25 @@ class MigrateSiteTreeLinkingTaskTest extends SapphireTest
|
||||
|
||||
$this->assertEquals(
|
||||
$homeContent,
|
||||
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $homeID)->Content,
|
||||
DataObject::get_by_id(SiteTree::class, $homeID)->Content,
|
||||
'HTML URLSegment links are rewritten.'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$aboutContent,
|
||||
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $aboutID)->Content
|
||||
DataObject::get_by_id(SiteTree::class, $aboutID)->Content
|
||||
);
|
||||
$this->assertEquals(
|
||||
$staffContent,
|
||||
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $staffID)->Content
|
||||
DataObject::get_by_id(SiteTree::class, $staffID)->Content
|
||||
);
|
||||
$this->assertEquals(
|
||||
$actionContent,
|
||||
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $actionID)->Content,
|
||||
DataObject::get_by_id(SiteTree::class, $actionID)->Content,
|
||||
'Links to actions on pages are rewritten correctly.'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$hashLinkContent,
|
||||
DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $hashID)->Content,
|
||||
DataObject::get_by_id(SiteTree::class, $hashID)->Content,
|
||||
'Hash/anchor links are correctly handled.'
|
||||
);
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\CMS\Tests;
|
||||
|
||||
namespace SilverStripe\CMS\Tests\Tasks;
|
||||
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <h2>Fixture tree</h2>
|
||||
* <code>
|
||||
@ -35,13 +32,9 @@ use SilverStripe\Dev\FunctionalTest;
|
||||
* </code>
|
||||
*
|
||||
* @author Ingo Schommer (<firstname>@silverstripe.com), SilverStripe Ltd.
|
||||
*
|
||||
* @package cms
|
||||
* @subpackage tests
|
||||
*/
|
||||
class RemoveOrphanedPagesTaskTest extends FunctionalTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'RemoveOrphanedPagesTaskTest.yml';
|
||||
|
||||
protected static $use_draft_site = false;
|
||||
|
Loading…
Reference in New Issue
Block a user