API Upgrade to rely on silverstripe/versioned module

This commit is contained in:
Damian Mooyman 2017-03-21 17:26:46 +13:00 committed by Sam Minnée
parent 672a31e56e
commit 5ce98aced2
50 changed files with 126 additions and 118 deletions

View File

@ -14,6 +14,7 @@ env:
global:
- TRAVIS_NODE_VERSION="4"
- CORE_RELEASE=4
- COMPOSER_ROOT_VERSION="4.0.x-dev"
matrix:
include:
@ -38,12 +39,12 @@ before_script:
- phpenv config-rm xdebug.ini
- echo 'memory_limit = 2G' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- composer install --prefer-dist
- composer require silverstripe/framework:4.0.x-dev silverstripe/config:1.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/assets:1.0.x-dev silverstripe/versioned:1.0.x-dev --prefer-dist
- "if [ \"$DB\" = \"PGSQL\" ]; then composer require silverstripe/postgresql:2.0.x-dev --prefer-dist; fi"
- "if [ \"$DB\" = \"SQLITE\" ]; then composer require silverstripe/sqlite3:2.0.x-dev --prefer-dist; fi"
- "php ./tests/bootstrap/mysite.php"
- "export DISPLAY=\":99\""
- "export XVFBARGS=\":99 -ac -screen 0 1024x768x16\""
- "export COMPOSER_ROOT_VERSION=4.0.x-dev"
- "if [ \"$NPM_TEST\" = \"1\" ]; then (nvm install $TRAVIS_NODE_VERSION && npm install --silent && npm run build); fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then sh -e /etc/init.d/xvfb start; sleep 3; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/selenium-server-standalone > selenium.log 2>&1 &); fi"

View File

@ -6,7 +6,7 @@ use SilverStripe\Admin\CMSBatchAction;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Permission;
/**

View File

@ -50,7 +50,7 @@ use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\PermissionProvider;

View File

@ -16,7 +16,7 @@ use SilverStripe\Forms\HTMLReadonlyField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Security;
use SilverStripe\View\ArrayData;
use SilverStripe\View\ViewableData;

View File

@ -9,7 +9,7 @@ use SilverStripe\Forms\DateField;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Base class for filtering the subtree for certain node statuses.

View File

@ -2,7 +2,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Gets all pages which have changed on stage.

View File

@ -2,7 +2,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Works a bit different than the other filters:

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* This filter will display the SiteTree as a site visitor might see the site, i.e only the

View File

@ -2,7 +2,7 @@
namespace SilverStripe\CMS\Controllers;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter
{

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Filters pages which have a status "Deleted".

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Filters pages which have a status "Draft".

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Filters pages which have a status "Removed from Draft".

View File

@ -19,7 +19,7 @@ use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Member;
use SilverStripe\Security\MemberAuthenticator;
use SilverStripe\Security\Permission;

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Member;
use SilverStripe\View\ViewableData;
@ -121,7 +121,7 @@ abstract class SilverStripeNavigatorItem extends ViewableData
*/
public function isArchived()
{
if (!$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')) {
if (!$this->record->hasExtension(Versioned::class)) {
return false;
}

View File

@ -6,7 +6,7 @@ use SilverStripe\Control\Controller;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem
{
@ -54,7 +54,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem
public function canView($member = null)
{
return (
$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')
$this->record->hasExtension(Versioned::class)
&& $this->isArchived()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)

View File

@ -4,7 +4,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
{
@ -52,7 +52,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
public function canView($member = null)
{
return (
$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')
$this->record->hasExtension(Versioned::class)
&& $this->getLivePage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)

View File

@ -5,7 +5,7 @@ use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\Control\Controller;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SiteTreeFutureState;
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
@ -58,7 +58,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
public function canView($member = null)
{
return (
$this->record->hasExtension('SilverStripe\ORM\Versioning\Versioned')
$this->record->hasExtension(Versioned::class)
&& $this->getDraftPage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)

View File

@ -5,7 +5,7 @@ namespace SilverStripe\CMS\Model;
use SilverStripe\Assets\Storage\GeneratedAssetHandler;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataModel;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DB;
use SilverStripe\CMS\Controllers\ModelAsController;
use SilverStripe\View\Requirements;

View File

@ -48,7 +48,7 @@ use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
@ -1057,7 +1057,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// check for specific groups
if ($member && is_numeric($member)) {
$member = DataObject::get_by_id('SilverStripe\\Security\\Member', $member);
$member = DataObject::get_by_id(Member::class, $member);
}
if ($this->CanViewType == 'OnlyTheseUsers'
&& $member
@ -1352,7 +1352,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// Get the groups that the given member belongs to
/** @var Member $member */
$member = DataObject::get_by_id('SilverStripe\\Security\\Member', $memberID);
$member = DataObject::get_by_id(Member::class, $memberID);
$groupIDs = $member->Groups()->column("ID");
$SQL_groupList = implode(", ", $groupIDs);
if (!$SQL_groupList) {

View File

@ -9,7 +9,7 @@ use SilverStripe\Forms\ReadonlyField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\View\SSViewer;
use Subsite;

View File

@ -8,7 +8,7 @@ use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use DOMElement;
/**

View File

@ -8,7 +8,7 @@ use SilverStripe\Forms\ReadonlyTransformation;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Member;
use Page;

View File

@ -7,7 +7,7 @@ use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Reports\Report;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
class BrokenFilesReport extends Report
{

View File

@ -8,7 +8,7 @@ use SilverStripe\Control\Controller;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Reports\Report;

View File

@ -6,7 +6,7 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Reports\Report;
class BrokenRedirectorPagesReport extends Report

View File

@ -6,7 +6,7 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Reports\Report;
class BrokenVirtualPagesReport extends Report

View File

@ -14,7 +14,7 @@ use SilverStripe\Forms\OptionsetField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\View\Requirements;

View File

@ -17,10 +17,11 @@
],
"require": {
"composer/installers": "*",
"silverstripe/framework": "^4.0@dev",
"silverstripe/admin": "^1.0@dev",
"silverstripe/framework": "^4.0@dev",
"silverstripe/reports": "^4.0@dev",
"silverstripe/siteconfig": "^4.0@dev"
"silverstripe/siteconfig": "^4.0@dev",
"silverstripe/versioned": "^1.0@dev"
},
"require-dev": {
"phpunit/PHPUnit": "~4.8",

View File

@ -9,7 +9,7 @@ use SilverStripe\BehatExtension\Context\FixtureContext;
use SilverStripe\Framework\Test\Behaviour\CmsFormsContext;
use SilverStripe\Framework\Test\Behaviour\CmsUiContext;
use SilverStripe\Cms\Test\Behaviour;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector;

View File

@ -11,7 +11,7 @@ use Behat\Behat\Exception\PendingException;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
/**
* Context used to create fixtures in the SilverStripe ORM.

View File

@ -1,7 +1,7 @@
<?php
use SilverStripe\CMS\BatchActions\CMSBatchAction_Archive;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\BatchActions\CMSBatchAction_Publish;
use SilverStripe\CMS\BatchActions\CMSBatchAction_Unpublish;
use SilverStripe\CMS\BatchActions\CMSBatchAction_Restore;

View File

@ -4,7 +4,7 @@ use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Model\SiteTree;
@ -250,7 +250,7 @@ class CMSMainTest extends FunctionalTest
$response = $this->get('admin/pages/edit/show/' . $pageID);
$livePage = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", array(
$livePage = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, array(
'"SiteTree"."ID"' => $pageID
));
$this->assertInstanceOf('SilverStripe\\CMS\\Model\\SiteTree', $livePage);

View File

@ -5,7 +5,7 @@ use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\HTMLReadonlyField;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Controllers\CMSPageHistoryController;
use SilverStripe\Dev\FunctionalTest;
@ -157,12 +157,12 @@ class CMSPageHistoryControllerTest extends FunctionalTest
$this->assertThat($checkbox[0], $this->logicalNot($this->isNull()));
$this->assertEquals('checked', (string) $checkbox[0]->attributes()->checked);
}
public function testTransformReadonly()
{
/** @var CMSPageHistoryController $history */
$history = singleton(CMSPageHistoryController::class);
$fieldList = FieldList::create([
FieldGroup::create('group', [
TextField::create('childField', 'child field'),
@ -170,9 +170,9 @@ class CMSPageHistoryControllerTest extends FunctionalTest
TextField::create('field', 'field', 'My <del>value</del><ins>change</ins>'),
HiddenField::create('hiddenField', 'hidden field'),
]);
$newList = $history->transformReadonly($fieldList);
$field = $newList->dataFieldByName('field');
$this->assertTrue($field instanceof HTMLReadonlyField);
$this->assertContains('<ins>', $field->forTemplate());

View File

@ -1,6 +1,7 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages;
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages;
@ -190,7 +191,7 @@ class CMSSiteTreeFilterTest extends SapphireTest
// Can't use straight $blah->delete() as that blows it away completely and test fails
$deletedPage->deleteFromStage(Versioned::LIVE);
$deletedPage->deleteFromStage(Versioned::DRAFT);
$checkParentExists = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $deletedPageID);
$checkParentExists = Versioned::get_latest_version(SiteTree::class, $deletedPageID);
// Check deleted page is included
$f = new CMSSiteTreeFilter_StatusDeletedPages(array('Title' => 'Page'));

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\FunctionalTest;

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\ORM\Search\FulltextSearchable;
use SilverStripe\Core\Config\Config;

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Controllers\RootURLController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Controllers\ContentController;

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Controllers\OldPageRedirector;
use SilverStripe\CMS\Controllers\RootURLController;

View File

@ -1,5 +1,6 @@
<?php
use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
@ -25,7 +26,7 @@ class SilverStripeNavigatorTest extends SapphireTest
$items = $navigator->getItems();
$classes = array_map('get_class', $items->toArray());
$this->assertContains(
'SilverStripe\\CMS\\Controllers\\SilverStripeNavigatorItem_StageLink',
SilverStripeNavigatorItem_StageLink::class,
$classes,
'Adds default classes'
);
@ -40,7 +41,7 @@ class SilverStripeNavigatorTest extends SapphireTest
public function testCanView()
{
$page = $this->objFromFixture('Page', 'page1');
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
$admin = $this->objFromFixture(Member::class, 'admin');
$navigator = new SilverStripeNavigator($page);
// TODO Shouldn't be necessary but SapphireTest logs in as ADMIN by default

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Assets\File;
use SilverStripe\Control\Session;
use SilverStripe\View\Parsers\ShortcodeParser;

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Model\ErrorPage;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Core\Config\Config;

View File

@ -1,6 +1,8 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Assets\Folder;
use SilverStripe\Assets\Image;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\CMS\Model\VirtualPage;
use SilverStripe\Assets\File;
@ -25,7 +27,7 @@ class FileLinkTrackingTest extends SapphireTest
$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));
@ -35,7 +37,7 @@ class FileLinkTrackingTest extends SapphireTest
}
// Since we can't hard-code IDs, manually inject image tracking shortcode
$imageID = $this->idFromFixture('SilverStripe\\Assets\\Image', 'file1');
$imageID = $this->idFromFixture(Image::class, 'file1');
$page = $this->objFromFixture('Page', 'page1');
$page->Content = sprintf(
'<p>[image src="/assets/FileLinkTrackingTest/55b443b601/testscript-test-file.jpg" id="%d"]</p>',
@ -73,7 +75,7 @@ class FileLinkTrackingTest extends SapphireTest
);
Versioned::set_stage(Versioned::DRAFT);
$file = $this->objFromFixture('SilverStripe\\Assets\\Image', 'file1');
$file = $this->objFromFixture(Image::class, 'file1');
$file->Name = 'renamed-test-file.jpg';
$file->write();
@ -133,7 +135,7 @@ class FileLinkTrackingTest extends SapphireTest
$svp->publishRecursive();
// Rename the file
$file = $this->objFromFixture('SilverStripe\\Assets\\Image', 'file1');
$file = $this->objFromFixture(Image::class, 'file1');
$file->Name = 'renamed-test-file.jpg';
$file->write();
@ -164,7 +166,7 @@ class FileLinkTrackingTest extends SapphireTest
$this->assertFalse($page->isModifiedOnDraft());
// Rename the file
$file = $this->objFromFixture('SilverStripe\\Assets\\Image', 'file1');
$file = $this->objFromFixture(Image::class, 'file1');
$file->Name = 'renamed-test-file.jpg';
$file->write();
@ -185,7 +187,7 @@ class FileLinkTrackingTest extends SapphireTest
// Rename the file twice
Versioned::set_stage(Versioned::DRAFT);
$file = $this->objFromFixture('SilverStripe\\Assets\\Image', 'file1');
$file = $this->objFromFixture(Image::class, 'file1');
$file->Name = 'renamed-test-file.jpg';
$file->write();

View File

@ -1,7 +1,7 @@
<?php
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Control\HTTP;
use SilverStripe\Control\Director;

View File

@ -1,7 +1,7 @@
<?php
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\CMS\Model\VirtualPage;

View File

@ -1,6 +1,8 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Security\Group;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Security\Member;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\HTTPResponse_Exception;
@ -19,7 +21,7 @@ class SiteTreePermissionsTest extends FunctionalTest
protected static $fixture_file = "SiteTreePermissionsTest.yml";
protected $illegalExtensions = array(
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeSubsites')
SiteTree::class => array('SiteTreeSubsites')
);
public function setUp()
@ -87,7 +89,7 @@ class SiteTreePermissionsTest extends FunctionalTest
$page = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID");
// subadmin has edit rights on that page
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$member = $this->objFromFixture(Member::class, 'subadmin');
$member->logIn();
// Test can_edit_multiple
@ -110,7 +112,7 @@ class SiteTreePermissionsTest extends FunctionalTest
$page->doUnpublish();
// subadmin has edit rights on that page
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$member = $this->objFromFixture(Member::class, 'subadmin');
$member->logIn();
// Test can_edit_multiple
@ -137,7 +139,7 @@ class SiteTreePermissionsTest extends FunctionalTest
$page = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID);
// subadmin had edit rights on that page, but now it's gone
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$member = $this->objFromFixture(Member::class, 'subadmin');
$member->logIn();
$this->assertFalse($page->canEdit());
@ -155,8 +157,8 @@ class SiteTreePermissionsTest extends FunctionalTest
$page->Title = 1;
$page->write();
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
$editor = $this->objFromFixture(Member::class, 'editor');
$websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
$this->assertTrue($page->canViewStage('Live', $websiteuser));
$this->assertFalse($page->canViewStage('Stage', $websiteuser));
@ -171,7 +173,7 @@ class SiteTreePermissionsTest extends FunctionalTest
{
$page = $this->objFromFixture('Page', 'standardpage');
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->session()->inst_set('loggedInAs', $subadminuser->ID);
$fields = $page->getSettingsFields();
$this->assertFalse(
@ -183,7 +185,7 @@ class SiteTreePermissionsTest extends FunctionalTest
'Users with SITETREE_GRANT_ACCESS permission can change "edit" permissions in cms fields'
);
$editoruser = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
$editoruser = $this->objFromFixture(Member::class, 'editor');
$this->session()->inst_set('loggedInAs', $editoruser->ID);
$fields = $page->getSettingsFields();
$this->assertTrue(
@ -216,7 +218,7 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// website users
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
$websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
$this->assertTrue(
$page->canView($websiteuser),
'Authenticated members can view a page marked as "Viewable for any logged in users" even if they dont have access to the CMS'
@ -249,7 +251,7 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// subadmin users
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->assertFalse(
$page->canView($subadminuser),
'Authenticated members cant view a page marked as "Viewable by these groups" if theyre not in the listed groups'
@ -264,7 +266,7 @@ class SiteTreePermissionsTest extends FunctionalTest
$this->session()->inst_set('loggedInAs', null);
// website users
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
$websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
$this->assertTrue(
$page->canView($websiteuser),
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups'
@ -290,7 +292,7 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// website users
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
$websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
$websiteuser->logIn();
$this->assertFalse(
$page->canEdit($websiteuser),
@ -298,7 +300,7 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// subadmin users
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->assertTrue(
$page->canEdit($subadminuser),
'Authenticated members can edit a page marked as "Editable by logged in users" if they have cms permissions and belong to any of these groups'
@ -316,14 +318,14 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// subadmin users
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->assertTrue(
$page->canEdit($subadminuser),
'Authenticated members can view a page marked as "Editable by these groups" if theyre in the listed groups'
);
// website users
$websiteuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
$websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
$this->assertFalse(
$page->canEdit($websiteuser),
'Authenticated members cant edit a page marked as "Editable by these groups" if theyre not in the listed groups'
@ -349,7 +351,7 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// subadmin users
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->assertTrue(
$childPage->canView($subadminuser),
'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups by inherited permission'
@ -376,7 +378,7 @@ class SiteTreePermissionsTest extends FunctionalTest
);
// subadmin users
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->assertTrue(
$childPage->canEdit($subadminuser),
'Authenticated members can edit a page marked as "Editable by these groups" if theyre in the listed groups by inherited permission'
@ -410,11 +412,11 @@ class SiteTreePermissionsTest extends FunctionalTest
$page->deleteFromStage('Stage');
// Get the live version of the page
$page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
$page = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, "\"SiteTree\".\"ID\" = $pageID");
$this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object');
// subadmin users
$subadminuser = $this->objFromFixture('SilverStripe\\Security\\Member', 'subadmin');
$subadminuser = $this->objFromFixture(Member::class, 'subadmin');
$this->assertTrue(
$page->canEdit($subadminuser),
'Authenticated members can edit a page that was deleted from stage and marked as "Editable by logged in users" if they have cms permissions and belong to any of these groups'
@ -424,9 +426,9 @@ class SiteTreePermissionsTest extends FunctionalTest
public function testInheritCanViewFromSiteConfig()
{
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
$siteconfig = $this->objFromFixture('SilverStripe\\SiteConfig\\SiteConfig', 'default');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
$editorGroup = $this->objFromFixture('SilverStripe\\Security\\Group', 'editorgroup');
$siteconfig = $this->objFromFixture(SiteConfig::class, 'default');
$editor = $this->objFromFixture(Member::class, 'editor');
$editorGroup = $this->objFromFixture(Group::class, 'editorgroup');
$siteconfig->CanViewType = 'Anyone';
$siteconfig->write();
@ -450,10 +452,10 @@ class SiteTreePermissionsTest extends FunctionalTest
public function testInheritCanEditFromSiteConfig()
{
$page = $this->objFromFixture('Page', 'inheritWithNoParent');
$siteconfig = $this->objFromFixture('SilverStripe\\SiteConfig\\SiteConfig', 'default');
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
$user = $this->objFromFixture('SilverStripe\\Security\\Member', 'websiteuser');
$editorGroup = $this->objFromFixture('SilverStripe\\Security\\Group', 'editorgroup');
$siteconfig = $this->objFromFixture(SiteConfig::class, 'default');
$editor = $this->objFromFixture(Member::class, 'editor');
$user = $this->objFromFixture(Member::class, 'websiteuser');
$editorGroup = $this->objFromFixture(Group::class, 'editorgroup');
$siteconfig->CanEditType = 'LoggedInUsers';
$siteconfig->write();

View File

@ -6,7 +6,7 @@ use SilverStripe\CMS\Model\VirtualPage;
use SilverStripe\Control\ContentNegotiator;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\DataExtension;
@ -339,7 +339,7 @@ class SiteTreeTest extends SapphireTest
Versioned::set_stage(Versioned::LIVE);
$deletedPage = Versioned::get_latest_version(SiteTree::class, $page2ID);
$deletedPage->doRestoreToStage();
$this->assertFalse((bool)Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = " . $page2ID));
$this->assertFalse((bool)Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, "\"SiteTree\".\"ID\" = " . $page2ID));
Versioned::set_stage(Versioned::DRAFT);
$requeriedPage = DataObject::get_by_id("Page", $page2ID);
@ -994,7 +994,7 @@ class SiteTreeTest extends SapphireTest
$sitetree->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$sitetree = DataObject::get_by_id(SiteTree::class, $sitetree->ID, false);
$this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen'));
$sitetreeLive = Versioned::get_one_by_stage(SiteTree::class, 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
$sitetreeLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree"."ID" = ' .$sitetree->ID, false);
$this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen'));
}

View File

@ -1,7 +1,7 @@
<?php
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\FieldType\DBVarchar;
@ -32,11 +32,11 @@ class VirtualPageTest extends FunctionalTest
);
protected $illegalExtensions = array(
'SilverStripe\\CMS\\Model\\SiteTree' => array('SiteTreeSubsites', 'Translatable')
SiteTree::class => array('SiteTreeSubsites', 'Translatable')
);
protected $requiredExtensions = array(
'SilverStripe\\CMS\\Model\\SiteTree' => array('VirtualPageTest_PageExtension')
SiteTree::class => array('VirtualPageTest_PageExtension')
);
public function setUp()
@ -90,16 +90,16 @@ class VirtualPageTest extends FunctionalTest
$master->Content = "<p>New content</p>";
$master->write();
$vp1 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
$this->assertTrue($vp1->publishRecursive());
$this->assertTrue($vp2->publishRecursive());
$master->publishRecursive();
Versioned::set_stage(Versioned::LIVE);
$vp1 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
$this->assertNotNull($vp1);
$this->assertNotNull($vp2);
@ -159,13 +159,13 @@ class VirtualPageTest extends FunctionalTest
// The draft content of the virtual page should say 'draft content'
/** @var VirtualPage $vpDraft */
$vpDraft = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::DRAFT)->byID($vp->ID);
$vpDraft = Versioned::get_by_stage(VirtualPage::class, Versioned::DRAFT)->byID($vp->ID);
$this->assertEquals('draft content', $vpDraft->CopyContentFrom()->Content);
$this->assertEquals('draft content', $vpDraft->Content);
// The published content of the virtual page should say 'published content'
/** @var VirtualPage $vpLive */
$vpLive = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::LIVE)->byID($vp->ID);
$vpLive = Versioned::get_by_stage(VirtualPage::class, Versioned::LIVE)->byID($vp->ID);
$this->assertEquals('published content', $vpLive->CopyContentFrom()->Content);
$this->assertEquals('published content', $vpLive->Content);
@ -173,7 +173,7 @@ class VirtualPageTest extends FunctionalTest
$vpDraft->publishRecursive();
// Everything is published live
$vpLive = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::LIVE)->byID($vp->ID);
$vpLive = Versioned::get_by_stage(VirtualPage::class, Versioned::LIVE)->byID($vp->ID);
$this->assertEquals('draft content', $vpLive->CopyContentFrom()->Content);
$this->assertEquals('draft content', $vpLive->Content);
}
@ -218,7 +218,7 @@ class VirtualPageTest extends FunctionalTest
// Delete the source page semi-manually, without triggering
// the cascade publish back to the virtual page.
Versioned::set_stage(Versioned::LIVE);
$livePage = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE)->byID($pID);
$livePage = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE)->byID($pID);
$livePage->delete();
Versioned::set_stage(Versioned::DRAFT);
@ -346,16 +346,16 @@ class VirtualPageTest extends FunctionalTest
// The draft VP still has the CopyContentFromID link
$vp->flushCache();
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
$vp = DataObject::get_by_id(SiteTree::class, $vp->ID);
$this->assertEquals($p->ID, $vp->CopyContentFromID);
$vpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
$vpLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree"."ID" = ' . $vp->ID);
$this->assertNull($vpLive);
// Delete from draft, confirm that the virtual page has a broken link on the draft site
$p->delete();
$vp->flushCache();
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
$vp = DataObject::get_by_id(SiteTree::class, $vp->ID);
$this->assertEquals(1, $vp->HasBrokenLink);
}
@ -378,19 +378,19 @@ class VirtualPageTest extends FunctionalTest
$pID = $p->ID;
$p->delete();
$vp->flushCache();
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
$vp = DataObject::get_by_id(SiteTree::class, $vp->ID);
$this->assertEquals(1, $vp->HasBrokenLink);
// Delete the source page form live, confirm that the virtual page has also been unpublished
$pLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
$pLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree"."ID" = ' . $pID);
$this->assertTrue($pLive->doUnpublish());
$vpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
$vpLive = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, '"SiteTree"."ID" = ' . $vp->ID);
$this->assertNull($vpLive);
// Delete from draft, confirm that the virtual page has a broken link on the draft site
$pLive->delete();
$vp->flushCache();
$vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID);
$vp = DataObject::get_by_id(SiteTree::class, $vp->ID);
$this->assertEquals(1, $vp->HasBrokenLink);
}
@ -530,7 +530,7 @@ class VirtualPageTest extends FunctionalTest
$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('SilverStripe\\CMS\\Model\\SiteTree', '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('changed on new type', $nonVirtualStage->MySharedNonVirtualField);
@ -541,7 +541,7 @@ class VirtualPageTest extends FunctionalTest
);
// Virtual page on live keeps working as it should
$virtualLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', '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('virtual published field', $virtualLive->MySharedNonVirtualField);
@ -554,7 +554,7 @@ 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('SilverStripe\\CMS\\Model\\SiteTree', '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);
}

View File

@ -6,7 +6,7 @@ use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\MSSQL\MSSQLDatabase;
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
use SilverStripe\CMS\Controllers\ContentController;

View File

@ -1,6 +1,6 @@
<?php
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Dev\FunctionalTest;
/**