From 5ce98aced2058670e303a16db899428ed5777df4 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 21 Mar 2017 17:26:46 +1300 Subject: [PATCH] API Upgrade to rely on silverstripe/versioned module --- .travis.yml | 3 +- code/BatchActions/CMSBatchAction_Restore.php | 2 +- code/Controllers/CMSMain.php | 2 +- code/Controllers/CMSPageHistoryController.php | 2 +- code/Controllers/CMSSiteTreeFilter.php | 2 +- .../CMSSiteTreeFilter_ChangedPages.php | 2 +- .../CMSSiteTreeFilter_DeletedPages.php | 2 +- .../CMSSiteTreeFilter_PublishedPages.php | 2 +- code/Controllers/CMSSiteTreeFilter_Search.php | 2 +- .../CMSSiteTreeFilter_StatusDeletedPages.php | 2 +- .../CMSSiteTreeFilter_StatusDraftPages.php | 2 +- ...TreeFilter_StatusRemovedFromDraftPages.php | 2 +- code/Controllers/ContentController.php | 2 +- .../Controllers/SilverStripeNavigatorItem.php | 4 +- .../SilverStripeNavigatorItem_ArchiveLink.php | 4 +- .../SilverStripeNavigatorItem_LiveLink.php | 4 +- .../SilverStripeNavigatorItem_StageLink.php | 4 +- code/Model/ErrorPage.php | 2 +- code/Model/SiteTree.php | 6 +- code/Model/SiteTreeFileExtension.php | 2 +- code/Model/SiteTreeLinkTracking.php | 2 +- code/Model/VirtualPage.php | 2 +- code/Reports/BrokenFilesReport.php | 2 +- code/Reports/BrokenLinksReport.php | 2 +- code/Reports/BrokenRedirectorPagesReport.php | 2 +- code/Reports/BrokenVirtualPagesReport.php | 2 +- code/Tasks/RemoveOrphanedPagesTask.php | 2 +- composer.json | 5 +- .../features/bootstrap/FeatureContext.php | 2 +- .../Cms/Test/Behaviour/FixtureContext.php | 2 +- tests/controller/CMSBatchActionsTest.php | 2 +- tests/controller/CMSMainTest.php | 4 +- .../CMSPageHistoryControllerTest.php | 10 ++-- tests/controller/CMSSiteTreeFilterTest.php | 5 +- .../ContentControllerPermissionsTest.php | 2 +- .../ContentControllerSearchExtensionTest.php | 2 +- tests/controller/ContentControllerTest.php | 2 +- tests/controller/ModelAsControllerTest.php | 2 +- .../controller/SilverStripeNavigatorTest.php | 5 +- tests/model/ErrorPageFileExtensionTest.php | 2 +- tests/model/ErrorPageTest.php | 2 +- tests/model/FileLinkTrackingTest.php | 16 +++--- tests/model/SiteTreeActionsTest.php | 2 +- tests/model/SiteTreeBacklinksTest.php | 2 +- tests/model/SiteTreeBrokenLinksTest.php | 2 +- tests/model/SiteTreePermissionsTest.php | 56 ++++++++++--------- tests/model/SiteTreeTest.php | 6 +- tests/model/VirtualPageTest.php | 42 +++++++------- tests/search/SearchFormTest.php | 2 +- tests/tasks/RemoveOrphanedPagesTaskTest.php | 2 +- 50 files changed, 126 insertions(+), 118 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71400764..69fd8d11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/code/BatchActions/CMSBatchAction_Restore.php b/code/BatchActions/CMSBatchAction_Restore.php index fa2994fa..7ff23f20 100644 --- a/code/BatchActions/CMSBatchAction_Restore.php +++ b/code/BatchActions/CMSBatchAction_Restore.php @@ -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; /** diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index c429c398..8ea0251b 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -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; diff --git a/code/Controllers/CMSPageHistoryController.php b/code/Controllers/CMSPageHistoryController.php index 7ac7c3f9..f5620ab3 100644 --- a/code/Controllers/CMSPageHistoryController.php +++ b/code/Controllers/CMSPageHistoryController.php @@ -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; diff --git a/code/Controllers/CMSSiteTreeFilter.php b/code/Controllers/CMSSiteTreeFilter.php index 5db4cac3..416fb6b8 100644 --- a/code/Controllers/CMSSiteTreeFilter.php +++ b/code/Controllers/CMSSiteTreeFilter.php @@ -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. diff --git a/code/Controllers/CMSSiteTreeFilter_ChangedPages.php b/code/Controllers/CMSSiteTreeFilter_ChangedPages.php index 7ceba9c4..0d3286f8 100644 --- a/code/Controllers/CMSSiteTreeFilter_ChangedPages.php +++ b/code/Controllers/CMSSiteTreeFilter_ChangedPages.php @@ -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. diff --git a/code/Controllers/CMSSiteTreeFilter_DeletedPages.php b/code/Controllers/CMSSiteTreeFilter_DeletedPages.php index 4d567ee3..0b418482 100644 --- a/code/Controllers/CMSSiteTreeFilter_DeletedPages.php +++ b/code/Controllers/CMSSiteTreeFilter_DeletedPages.php @@ -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: diff --git a/code/Controllers/CMSSiteTreeFilter_PublishedPages.php b/code/Controllers/CMSSiteTreeFilter_PublishedPages.php index ac5c9661..4ae90469 100644 --- a/code/Controllers/CMSSiteTreeFilter_PublishedPages.php +++ b/code/Controllers/CMSSiteTreeFilter_PublishedPages.php @@ -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 diff --git a/code/Controllers/CMSSiteTreeFilter_Search.php b/code/Controllers/CMSSiteTreeFilter_Search.php index ed11c2db..5769f7bf 100644 --- a/code/Controllers/CMSSiteTreeFilter_Search.php +++ b/code/Controllers/CMSSiteTreeFilter_Search.php @@ -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 { diff --git a/code/Controllers/CMSSiteTreeFilter_StatusDeletedPages.php b/code/Controllers/CMSSiteTreeFilter_StatusDeletedPages.php index bf1be729..45d8bd3e 100644 --- a/code/Controllers/CMSSiteTreeFilter_StatusDeletedPages.php +++ b/code/Controllers/CMSSiteTreeFilter_StatusDeletedPages.php @@ -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". diff --git a/code/Controllers/CMSSiteTreeFilter_StatusDraftPages.php b/code/Controllers/CMSSiteTreeFilter_StatusDraftPages.php index bea9525d..8360c00e 100644 --- a/code/Controllers/CMSSiteTreeFilter_StatusDraftPages.php +++ b/code/Controllers/CMSSiteTreeFilter_StatusDraftPages.php @@ -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". diff --git a/code/Controllers/CMSSiteTreeFilter_StatusRemovedFromDraftPages.php b/code/Controllers/CMSSiteTreeFilter_StatusRemovedFromDraftPages.php index 24a690ba..d42752e7 100644 --- a/code/Controllers/CMSSiteTreeFilter_StatusRemovedFromDraftPages.php +++ b/code/Controllers/CMSSiteTreeFilter_StatusRemovedFromDraftPages.php @@ -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". diff --git a/code/Controllers/ContentController.php b/code/Controllers/ContentController.php index 32797f0c..b4c4552e 100644 --- a/code/Controllers/ContentController.php +++ b/code/Controllers/ContentController.php @@ -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; diff --git a/code/Controllers/SilverStripeNavigatorItem.php b/code/Controllers/SilverStripeNavigatorItem.php index 2a120e93..51a51a22 100644 --- a/code/Controllers/SilverStripeNavigatorItem.php +++ b/code/Controllers/SilverStripeNavigatorItem.php @@ -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; } diff --git a/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php b/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php index 09c39ebf..62475c73 100644 --- a/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php @@ -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) diff --git a/code/Controllers/SilverStripeNavigatorItem_LiveLink.php b/code/Controllers/SilverStripeNavigatorItem_LiveLink.php index ec2d967f..d4040446 100644 --- a/code/Controllers/SilverStripeNavigatorItem_LiveLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_LiveLink.php @@ -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) diff --git a/code/Controllers/SilverStripeNavigatorItem_StageLink.php b/code/Controllers/SilverStripeNavigatorItem_StageLink.php index 13301028..d2bd22db 100644 --- a/code/Controllers/SilverStripeNavigatorItem_StageLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_StageLink.php @@ -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) diff --git a/code/Model/ErrorPage.php b/code/Model/ErrorPage.php index 1fb11f9c..d883ee26 100644 --- a/code/Model/ErrorPage.php +++ b/code/Model/ErrorPage.php @@ -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; diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index a272c092..78364728 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -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) { diff --git a/code/Model/SiteTreeFileExtension.php b/code/Model/SiteTreeFileExtension.php index b916591b..411d299c 100644 --- a/code/Model/SiteTreeFileExtension.php +++ b/code/Model/SiteTreeFileExtension.php @@ -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; diff --git a/code/Model/SiteTreeLinkTracking.php b/code/Model/SiteTreeLinkTracking.php index 6ddabd6d..a812a6c3 100644 --- a/code/Model/SiteTreeLinkTracking.php +++ b/code/Model/SiteTreeLinkTracking.php @@ -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; /** diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 6bd49441..c78945cb 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -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; diff --git a/code/Reports/BrokenFilesReport.php b/code/Reports/BrokenFilesReport.php index 14ebd32f..31b0fd56 100644 --- a/code/Reports/BrokenFilesReport.php +++ b/code/Reports/BrokenFilesReport.php @@ -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 { diff --git a/code/Reports/BrokenLinksReport.php b/code/Reports/BrokenLinksReport.php index b37361ba..4f04860a 100644 --- a/code/Reports/BrokenLinksReport.php +++ b/code/Reports/BrokenLinksReport.php @@ -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; diff --git a/code/Reports/BrokenRedirectorPagesReport.php b/code/Reports/BrokenRedirectorPagesReport.php index 0cb738af..97b61f09 100644 --- a/code/Reports/BrokenRedirectorPagesReport.php +++ b/code/Reports/BrokenRedirectorPagesReport.php @@ -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 diff --git a/code/Reports/BrokenVirtualPagesReport.php b/code/Reports/BrokenVirtualPagesReport.php index e38a8f02..b4709b8f 100644 --- a/code/Reports/BrokenVirtualPagesReport.php +++ b/code/Reports/BrokenVirtualPagesReport.php @@ -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 diff --git a/code/Tasks/RemoveOrphanedPagesTask.php b/code/Tasks/RemoveOrphanedPagesTask.php index 34e7a679..27411ec9 100644 --- a/code/Tasks/RemoveOrphanedPagesTask.php +++ b/code/Tasks/RemoveOrphanedPagesTask.php @@ -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; diff --git a/composer.json b/composer.json index 9efc5204..1fa53405 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 611fa43b..a8e8591b 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -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; diff --git a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php index 5dc53955..b8d97bdf 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php @@ -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. diff --git a/tests/controller/CMSBatchActionsTest.php b/tests/controller/CMSBatchActionsTest.php index 5049142a..8196f18b 100644 --- a/tests/controller/CMSBatchActionsTest.php +++ b/tests/controller/CMSBatchActionsTest.php @@ -1,7 +1,7 @@ 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); diff --git a/tests/controller/CMSPageHistoryControllerTest.php b/tests/controller/CMSPageHistoryControllerTest.php index cbfbe74d..292940d3 100755 --- a/tests/controller/CMSPageHistoryControllerTest.php +++ b/tests/controller/CMSPageHistoryControllerTest.php @@ -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 valuechange'), HiddenField::create('hiddenField', 'hidden field'), ]); - + $newList = $history->transformReadonly($fieldList); - + $field = $newList->dataFieldByName('field'); $this->assertTrue($field instanceof HTMLReadonlyField); $this->assertContains('', $field->forTemplate()); diff --git a/tests/controller/CMSSiteTreeFilterTest.php b/tests/controller/CMSSiteTreeFilterTest.php index d42d28c6..0459087e 100644 --- a/tests/controller/CMSSiteTreeFilterTest.php +++ b/tests/controller/CMSSiteTreeFilterTest.php @@ -1,6 +1,7 @@ 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')); diff --git a/tests/controller/ContentControllerPermissionsTest.php b/tests/controller/ContentControllerPermissionsTest.php index 53b6f48b..db70edf3 100644 --- a/tests/controller/ContentControllerPermissionsTest.php +++ b/tests/controller/ContentControllerPermissionsTest.php @@ -1,6 +1,6 @@ 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 diff --git a/tests/model/ErrorPageFileExtensionTest.php b/tests/model/ErrorPageFileExtensionTest.php index 7bcfeedf..9438a41a 100644 --- a/tests/model/ErrorPageFileExtensionTest.php +++ b/tests/model/ErrorPageFileExtensionTest.php @@ -1,6 +1,6 @@ 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( '

[image src="/assets/FileLinkTrackingTest/55b443b601/testscript-test-file.jpg" id="%d"]

', @@ -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(); diff --git a/tests/model/SiteTreeActionsTest.php b/tests/model/SiteTreeActionsTest.php index ae3c9795..354c311a 100644 --- a/tests/model/SiteTreeActionsTest.php +++ b/tests/model/SiteTreeActionsTest.php @@ -1,7 +1,7 @@ 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(); diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php index c9308083..36f3e9f0 100644 --- a/tests/model/SiteTreeTest.php +++ b/tests/model/SiteTreeTest.php @@ -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')); } diff --git a/tests/model/VirtualPageTest.php b/tests/model/VirtualPageTest.php index de2df212..41679ef2 100644 --- a/tests/model/VirtualPageTest.php +++ b/tests/model/VirtualPageTest.php @@ -1,7 +1,7 @@ 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 = "

New content

"; $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); } diff --git a/tests/search/SearchFormTest.php b/tests/search/SearchFormTest.php index 466ec874..4b775846 100644 --- a/tests/search/SearchFormTest.php +++ b/tests/search/SearchFormTest.php @@ -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; diff --git a/tests/tasks/RemoveOrphanedPagesTaskTest.php b/tests/tasks/RemoveOrphanedPagesTaskTest.php index aad4bab8..38046c4e 100644 --- a/tests/tasks/RemoveOrphanedPagesTaskTest.php +++ b/tests/tasks/RemoveOrphanedPagesTaskTest.php @@ -1,6 +1,6 @@