From 2295501587ca0e77a012df4ee360d04b9acc3b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Werner=20M=2E=20Krau=C3=9F?= Date: Wed, 24 May 2017 15:25:34 +0200 Subject: [PATCH] upgrade tests --- tests/BaseSubsiteTest.php | 2 ++ tests/FileSubsitesTest.php | 9 ++++--- tests/GroupSubsitesTest.php | 13 +++++++---- tests/LeftAndMainSubsitesTest.php | 11 +++++---- tests/SiteConfigSubsitesTest.php | 9 ++++--- tests/SiteTreeSubsitesTest.php | 30 +++++++++++++----------- tests/SubsiteAdminFunctionalTest.php | 19 ++++++++------- tests/SubsiteAdminTest.php | 10 ++++---- tests/SubsiteTest.php | 27 +++++++++++---------- tests/SubsiteTest.yml | 4 ++-- tests/SubsitesVirtualPageTest.php | 35 ++++++++++++++++------------ 11 files changed, 100 insertions(+), 69 deletions(-) diff --git a/tests/BaseSubsiteTest.php b/tests/BaseSubsiteTest.php index d67b537..77caac5 100644 --- a/tests/BaseSubsiteTest.php +++ b/tests/BaseSubsiteTest.php @@ -1,6 +1,8 @@ assertTrue(is_array(singleton('FileSubsites')->extraStatics())); + $this->assertTrue(is_array(singleton(FileSubsites::class)->extraStatics())); $file = new File(); $file->Name = 'FileTitle'; $file->Title = 'FileTitle'; $this->assertEquals(' * FileTitle', $file->alternateTreeTitle()); - $file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID; + $file->SubsiteID = $this->objFromFixture(Subsite::class, 'domaintest1')->ID; $this->assertEquals('FileTitle', $file->getTreeTitle()); $this->assertTrue(singleton('SilverStripe\\Assets\\Folder')->getCMSFields() instanceof FieldList); Subsite::changeSubsite(1); @@ -23,7 +26,7 @@ class FileSubsitesTest extends BaseSubsiteTest { function testWritingSubsiteID() { $this->objFromFixture('SilverStripe\\Security\\Member', 'admin')->logIn(); - $subsite = $this->objFromFixture('Subsite', 'domaintest1'); + $subsite = $this->objFromFixture(Subsite::class, 'domaintest1'); FileSubsites::$default_root_folders_global = true; Subsite::changeSubsite(0); diff --git a/tests/GroupSubsitesTest.php b/tests/GroupSubsitesTest.php index 4e7d1e3..e994d83 100644 --- a/tests/GroupSubsitesTest.php +++ b/tests/GroupSubsitesTest.php @@ -2,15 +2,18 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Security\Group; +use SilverStripe\Subsites\Extensions\GroupSubsites; +use SilverStripe\Subsites\Model\Subsite; + class GroupSubsitesTest extends BaseSubsiteTest { static $fixture_file = 'subsites/tests/SubsiteTest.yml'; - protected $requireDefaultRecordsFrom = array('GroupSubsites'); + protected $requireDefaultRecordsFrom = array(GroupSubsites::class); function testTrivialFeatures() { - $this->assertTrue(is_array(singleton('GroupSubsites')->extraStatics())); - $this->assertTrue(is_array(singleton('GroupSubsites')->providePermissions())); + $this->assertTrue(is_array(singleton(GroupSubsites::class)->extraStatics())); + $this->assertTrue(is_array(singleton(GroupSubsites::class)->providePermissions())); $this->assertTrue(singleton('SilverStripe\\Security\\Group')->getCMSFields() instanceof FieldList); } @@ -21,8 +24,8 @@ class GroupSubsitesTest extends BaseSubsiteTest { $this->assertEquals($group->getTreeTitle(), 'The A Team (global group)'); $group->AccessAllSubsites = false; $group->write(); - $group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest1')); - $group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest2')); + $group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest1')); + $group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest2')); $this->assertEquals($group->getTreeTitle(), 'The A Team (Test 1, Test 2)'); } } \ No newline at end of file diff --git a/tests/LeftAndMainSubsitesTest.php b/tests/LeftAndMainSubsitesTest.php index 405d9ed..17572bc 100644 --- a/tests/LeftAndMainSubsitesTest.php +++ b/tests/LeftAndMainSubsitesTest.php @@ -3,6 +3,9 @@ use SilverStripe\Admin\LeftAndMain; use SilverStripe\Core\Config\Config; use SilverStripe\Dev\FunctionalTest; +use SilverStripe\Subsites\Model\Subsite; +use SilverStripe\AssetAdmin\Controller\AssetAdmin; + class LeftAndMainSubsitesTest extends FunctionalTest { @@ -28,7 +31,7 @@ class LeftAndMainSubsitesTest extends FunctionalTest { array('Title' =>'Subsite1 Template') ), $subsites, 'Lists member-accessible sites for the accessible controller.'); - $assetadmin = singleton('AssetAdmin'); + $assetadmin = singleton(AssetAdmin::class); $subsites = $assetadmin->sectionSites(true, "Main site", $member); $this->assertDOSEquals(array(), $subsites, 'Does not list any sites for forbidden controller.'); @@ -46,9 +49,9 @@ class LeftAndMainSubsitesTest extends FunctionalTest { $this->loginAs($admin); $ids = array(); - $subsite1 = $this->objFromFixture('Subsite', 'domaintest1'); - $subsite2 = $this->objFromFixture('Subsite', 'domaintest2'); - $subsite3 = $this->objFromFixture('Subsite', 'domaintest3'); + $subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1'); + $subsite2 = $this->objFromFixture(Subsite::class, 'domaintest2'); + $subsite3 = $this->objFromFixture(Subsite::class, 'domaintest3'); $ids[] = $subsite1->ID; $ids[] = $subsite2->ID; diff --git a/tests/SiteConfigSubsitesTest.php b/tests/SiteConfigSubsitesTest.php index 263d55c..f7f5d87 100644 --- a/tests/SiteConfigSubsitesTest.php +++ b/tests/SiteConfigSubsitesTest.php @@ -1,15 +1,18 @@ objFromFixture('Subsite', 'domaintest1'); - $subsite2 = $this->objFromFixture('Subsite', 'domaintest2'); + $subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1'); + $subsite2 = $this->objFromFixture(Subsite::class, 'domaintest2'); - $this->assertTrue(is_array(singleton('SiteConfigSubsites')->extraStatics())); + $this->assertTrue(is_array(singleton(SiteConfigSubsites::class)->extraStatics())); Subsite::changeSubsite(0); $sc = SiteConfig::current_site_config(); diff --git a/tests/SiteTreeSubsitesTest.php b/tests/SiteTreeSubsitesTest.php index 3cc2ca5..484a77c 100644 --- a/tests/SiteTreeSubsitesTest.php +++ b/tests/SiteTreeSubsitesTest.php @@ -8,6 +8,10 @@ use SilverStripe\CMS\Controllers\CMSMain; use SilverStripe\Core\Convert; use SilverStripe\Dev\TestOnly; use SilverStripe\CMS\Model\ErrorPage; +use SilverStripe\Subsites\Model\Subsite; +use SilverStripe\Subsites\Pages\SubsitesVirtualPage; +use SilverStripe\Subsites\Extensions\SiteTreeSubsites; + class SiteTreeSubsitesTest extends BaseSubsiteTest { @@ -24,8 +28,8 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest { ); function testPagesInDifferentSubsitesCanShareURLSegment() { - $subsiteMain = $this->objFromFixture('Subsite', 'main'); - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); + $subsiteMain = $this->objFromFixture(Subsite::class, 'main'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); $pageMain = new SiteTree(); $pageMain->URLSegment = 'testpage'; @@ -57,12 +61,12 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest { $this->assertTrue(singleton('SilverStripe\\CMS\\Model\\SiteTree')->getSiteConfig() instanceof SiteConfig); // The following assert is breaking in Translatable. $this->assertTrue(singleton('SilverStripe\\CMS\\Model\\SiteTree')->getCMSFields() instanceof FieldList); - $this->assertTrue(singleton('SubsitesVirtualPage')->getCMSFields() instanceof FieldList); - $this->assertTrue(is_array(singleton('SiteTreeSubsites')->extraStatics())); + $this->assertTrue(singleton(SubsitesVirtualPage::class)->getCMSFields() instanceof FieldList); + $this->assertTrue(is_array(singleton(SiteTreeSubsites::class)->extraStatics())); } function testErrorPageLocations() { - $subsite1 = $this->objFromFixture('Subsite', 'domaintest1'); + $subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1'); Subsite::changeSubsite($subsite1->ID); $path = SiteTreeSubsitesTest_ErrorPage::get_error_filename_spy(500); @@ -78,8 +82,8 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest { $mainpage = $this->objFromFixture('Page', 'home'); $subsite1page = $this->objFromFixture('Page', 'subsite1_home'); $subsite2page = $this->objFromFixture('Page', 'subsite2_home'); - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); - $subsite2 = $this->objFromFixture('Subsite', 'subsite2'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); + $subsite2 = $this->objFromFixture(Subsite::class, 'subsite2'); // Cant pass member as arguments to canEdit() because of GroupSubsites Session::set("loggedInAs", $admin->ID); @@ -116,8 +120,8 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest { */ function testTwoPagesWithSameURLOnDifferentSubsites() { // Set up a couple of pages with the same URL on different subsites - $s1 = $this->objFromFixture('Subsite','domaintest1'); - $s2 = $this->objFromFixture('Subsite','domaintest2'); + $s1 = $this->objFromFixture(Subsite::class,'domaintest1'); + $s2 = $this->objFromFixture(Subsite::class,'domaintest2'); $p1 = new SiteTree(); $p1->Title = $p1->URLSegment = "test-page"; @@ -145,8 +149,8 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest { $editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor'); Session::set("loggedInAs", $editor->ID); - $s1 = $this->objFromFixture('Subsite','domaintest1'); - $s2 = $this->objFromFixture('Subsite','domaintest2'); + $s1 = $this->objFromFixture(Subsite::class,'domaintest1'); + $s2 = $this->objFromFixture(Subsite::class,'domaintest2'); $page = singleton('SilverStripe\\CMS\\Model\\SiteTree'); $s1->PageTypeBlacklist = 'SiteTreeSubsitesTest_ClassA,ErrorPage'; @@ -184,8 +188,8 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest { $cmsmain = new CMSMain(); - $s1 = $this->objFromFixture('Subsite','domaintest1'); - $s2 = $this->objFromFixture('Subsite','domaintest2'); + $s1 = $this->objFromFixture(Subsite::class,'domaintest1'); + $s2 = $this->objFromFixture(Subsite::class,'domaintest2'); $s1->PageTypeBlacklist = 'SiteTreeSubsitesTest_ClassA,ErrorPage'; $s1->write(); diff --git a/tests/SubsiteAdminFunctionalTest.php b/tests/SubsiteAdminFunctionalTest.php index 468a229..a16dafe 100644 --- a/tests/SubsiteAdminFunctionalTest.php +++ b/tests/SubsiteAdminFunctionalTest.php @@ -3,6 +3,9 @@ use SilverStripe\Control\Session; use SilverStripe\Core\Config\Config; use SilverStripe\Dev\FunctionalTest; +use SilverStripe\Subsites\Model\Subsite; +use SilverStripe\Subsites\Controller\SubsiteXHRController; + class SubsiteAdminFunctionalTest extends FunctionalTest { static $fixture_file = 'subsites/tests/SubsiteTest.yml'; @@ -30,11 +33,11 @@ class SubsiteAdminFunctionalTest extends FunctionalTest { $response = $this->getAndFollowAll('admin/pages/?SubsiteID=0'); $this->assertRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Admin is disallowed'); - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); $response = $this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}"); $this->assertRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Admin is disallowed'); - $response = $this->getAndFollowAll('SubsiteXHRController'); + $response = $this->getAndFollowAll(SubsiteXHRController::class); $this->assertRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'SubsiteXHRController is disallowed'); } @@ -50,12 +53,12 @@ class SubsiteAdminFunctionalTest extends FunctionalTest { $this->assertEquals(Subsite::currentSubsiteID(), '0', 'Can access main site.'); $this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section'); - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); $this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}"); $this->assertEquals(Subsite::currentSubsiteID(), $subsite1->ID, 'Can access other subsite.'); $this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section'); - $response = $this->getAndFollowAll('SubsiteXHRController'); + $response = $this->getAndFollowAll(SubsiteXHRController::class); $this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'SubsiteXHRController is reachable'); } @@ -100,12 +103,12 @@ class SubsiteAdminFunctionalTest extends FunctionalTest { $this->assertEquals(Subsite::currentSubsiteID(), '0', 'Can access main site.'); $this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section'); - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); $this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}"); $this->assertEquals(Subsite::currentSubsiteID(), $subsite1->ID, 'Can access other subsite.'); $this->assertRegExp('#^admin/pages.*#', $this->mainSession->lastUrl(), 'Lands on the correct section'); - $response = $this->getAndFollowAll('SubsiteXHRController'); + $response = $this->getAndFollowAll(SubsiteXHRController::class); $this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'SubsiteXHRController is reachable'); } @@ -117,7 +120,7 @@ class SubsiteAdminFunctionalTest extends FunctionalTest { $member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member'); Session::set("loggedInAs", $member->ID); - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); // Check allowed URL. $this->getAndFollowAll("admin/pages/?SubsiteID={$subsite1->ID}"); @@ -140,7 +143,7 @@ class SubsiteAdminFunctionalTest extends FunctionalTest { $this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'Is not denied access'); // Check the standalone XHR controller. - $response = $this->getAndFollowAll('SubsiteXHRController'); + $response = $this->getAndFollowAll(SubsiteXHRController::class); $this->assertNotRegExp('#^Security/login.*#', $this->mainSession->lastUrl(), 'SubsiteXHRController is reachable'); } diff --git a/tests/SubsiteAdminTest.php b/tests/SubsiteAdminTest.php index 40288c4..9facc29 100644 --- a/tests/SubsiteAdminTest.php +++ b/tests/SubsiteAdminTest.php @@ -3,6 +3,8 @@ use SilverStripe\Control\Session; use SilverStripe\Control\Director; use SilverStripe\CMS\Controllers\CMSMain; +use SilverStripe\Subsites\Model\Subsite; + class SubsiteAdminTest extends BaseSubsiteTest { static $fixture_file = 'subsites/tests/SubsiteTest.yml'; @@ -18,7 +20,7 @@ class SubsiteAdminTest extends BaseSubsiteTest { */ function testBasicView() { Subsite::$write_hostmap = false; - $subsite1ID = $this->objFromFixture('Subsite','domaintest1')->ID; + $subsite1ID = $this->objFromFixture(Subsite::class,'domaintest1')->ID; // Open the admin area logged in as admin $response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession()); @@ -44,9 +46,9 @@ class SubsiteAdminTest extends BaseSubsiteTest { } $this->assertArrayHasKey(0, $ids, "Main site accessible"); - $this->assertArrayHasKey($this->idFromFixture('Subsite','main'), $ids, "Site with no groups inaccesible"); - $this->assertArrayHasKey($this->idFromFixture('Subsite','subsite1'), $ids, "Subsite1 Template inaccessible"); - $this->assertArrayHasKey($this->idFromFixture('Subsite','subsite2'), $ids, "Subsite2 Template inaccessible"); + $this->assertArrayHasKey($this->idFromFixture(Subsite::class,'main'), $ids, "Site with no groups inaccesible"); + $this->assertArrayHasKey($this->idFromFixture(Subsite::class,'subsite1'), $ids, "Subsite1 Template inaccessible"); + $this->assertArrayHasKey($this->idFromFixture(Subsite::class,'subsite2'), $ids, "Subsite2 Template inaccessible"); } diff --git a/tests/SubsiteTest.php b/tests/SubsiteTest.php index fa63eda..21dd23b 100644 --- a/tests/SubsiteTest.php +++ b/tests/SubsiteTest.php @@ -2,6 +2,9 @@ use SilverStripe\ORM\DataObject; use SilverStripe\Control\Director; +use SilverStripe\Subsites\Model\Subsite; +use SilverStripe\Subsites\Model\SubsiteDomain; + class SubsiteTest extends BaseSubsiteTest { @@ -27,7 +30,7 @@ class SubsiteTest extends BaseSubsiteTest { Subsite::$write_hostmap = false; // Create the instance - $template = $this->objFromFixture('Subsite', 'main'); + $template = $this->objFromFixture(Subsite::class, 'main'); // Test that changeSubsite is working Subsite::changeSubsite($template->ID); @@ -65,8 +68,8 @@ class SubsiteTest extends BaseSubsiteTest { */ function testDomainLookup() { // Clear existing fixtures - foreach(DataObject::get('Subsite') as $subsite) $subsite->delete(); - foreach(DataObject::get('SubsiteDomain') as $domain) $domain->delete(); + foreach(DataObject::get(Subsite::class) as $subsite) $subsite->delete(); + foreach(DataObject::get(SubsiteDomain::class) as $domain) $domain->delete(); // Much more expressive than YML in this case $subsite1 = $this->createSubsiteWithDomains(array( @@ -135,8 +138,8 @@ class SubsiteTest extends BaseSubsiteTest { function testStrictSubdomainMatching() { // Clear existing fixtures - foreach(DataObject::get('Subsite') as $subsite) $subsite->delete(); - foreach(DataObject::get('SubsiteDomain') as $domain) $domain->delete(); + foreach(DataObject::get(Subsite::class) as $subsite) $subsite->delete(); + foreach(DataObject::get(SubsiteDomain::class) as $domain) $domain->delete(); // Much more expressive than YML in this case $subsite1 = $this->createSubsiteWithDomains(array( @@ -224,23 +227,23 @@ class SubsiteTest extends BaseSubsiteTest { */ function testDefaultDomain() { $this->assertEquals('one.example.org', - $this->objFromFixture('Subsite','domaintest1')->domain()); + $this->objFromFixture(Subsite::class,'domaintest1')->domain()); $this->assertEquals('two.mysite.com', - $this->objFromFixture('Subsite','domaintest2')->domain()); + $this->objFromFixture(Subsite::class,'domaintest2')->domain()); $originalHTTPHost = $_SERVER['HTTP_HOST']; $_SERVER['HTTP_HOST'] = "www.example.org"; $this->assertEquals('three.example.org', - $this->objFromFixture('Subsite','domaintest3')->domain()); + $this->objFromFixture(Subsite::class,'domaintest3')->domain()); $_SERVER['HTTP_HOST'] = "mysite.example.org"; $this->assertEquals('three.mysite.example.org', - $this->objFromFixture('Subsite','domaintest3')->domain()); + $this->objFromFixture(Subsite::class,'domaintest3')->domain()); - $this->assertEquals($_SERVER['HTTP_HOST'], singleton('Subsite')->PrimaryDomain); - $this->assertEquals('http://'.$_SERVER['HTTP_HOST'].Director::baseURL(), singleton('Subsite')->absoluteBaseURL()); + $this->assertEquals($_SERVER['HTTP_HOST'], singleton(Subsite::class)->PrimaryDomain); + $this->assertEquals('http://'.$_SERVER['HTTP_HOST'].Director::baseURL(), singleton(Subsite::class)->absoluteBaseURL()); $_SERVER['HTTP_HOST'] = $originalHTTPHost; } @@ -339,7 +342,7 @@ class SubsiteTest extends BaseSubsiteTest { function testDuplicateSubsite() { // get subsite1 & create page - $subsite1 = $this->objFromFixture('Subsite','domaintest1'); + $subsite1 = $this->objFromFixture(Subsite::class,'domaintest1'); $subsite1->activate(); $page1 = new Page(); $page1->Title = 'MyAwesomePage'; diff --git a/tests/SubsiteTest.yml b/tests/SubsiteTest.yml index dc2126c..ffef98c 100644 --- a/tests/SubsiteTest.yml +++ b/tests/SubsiteTest.yml @@ -1,4 +1,4 @@ -Subsite: +SilverStripe\Subsites\Model\Subsite: main: Title: 'Template' subsite1: @@ -11,7 +11,7 @@ Subsite: Title: 'Test 2' domaintest3: Title: 'Test 3' -SubsiteDomain: +SilverStripe\Subsites\Model\SubsiteDomain: subsite1: SubsiteID: =>Subsite.subsite1 Domain: 'subsite1.*' diff --git a/tests/SubsitesVirtualPageTest.php b/tests/SubsitesVirtualPageTest.php index 61eba29..52f9c5b 100644 --- a/tests/SubsitesVirtualPageTest.php +++ b/tests/SubsitesVirtualPageTest.php @@ -3,7 +3,12 @@ use SilverStripe\Assets\Filesystem; use SilverStripe\ORM\DB; use SilverStripe\Core\Config\Config; -use SilverStripe\ORM\Versioning\Versioned; + +use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore; +use SilverStripe\Subsites\Model\Subsite; +use SilverStripe\Subsites\Pages\SubsitesVirtualPage; +use SilverStripe\Versioned\Versioned; + class SubsitesVirtualPageTest extends BaseSubsiteTest { static $fixture_file = array( @@ -15,13 +20,13 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { parent::setUp(); // Set backend root to /DataDifferencerTest - AssetStoreTest_SpyStore::activate('SubsitesVirtualPageTest'); + TestAssetStore::activate('SubsitesVirtualPageTest'); // Create a test files for each of the fixture references $file = $this->objFromFixture('SilverStripe\\Assets\\File', 'file1'); $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'page1'); $fromPath = __DIR__ . '/testscript-test-file.pdf'; - $destPath = AssetStoreTest_SpyStore::getLocalPath($file); + $destPath = TestAssetStore::getLocalPath($file); Filesystem::makeFolder(dirname($destPath)); copy($fromPath, $destPath); @@ -31,7 +36,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { } public function tearDown() { - AssetStoreTest_SpyStore::reset(); + TestAssetStore::reset(); parent::tearDown(); } @@ -39,7 +44,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { function testVirtualPageFromAnotherSubsite() { Subsite::$write_hostmap = false; - $subsite = $this->objFromFixture('Subsite', 'subsite2'); + $subsite = $this->objFromFixture(Subsite::class, 'subsite2'); Subsite::changeSubsite($subsite->ID); Subsite::$disable_subsite_filter = false; @@ -152,7 +157,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { $this->assertTrue($p->ExistsOnLive); // change to subsite - $subsite = $this->objFromFixture('Subsite', 'subsite2'); + $subsite = $this->objFromFixture(Subsite::class, 'subsite2'); Subsite::changeSubsite($subsite->ID); Subsite::$disable_subsite_filter = false; @@ -187,19 +192,19 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { Config::modify()->set('StaticPublisher', 'disable_realtime', true); // Go to main site, get parent page - $subsite = $this->objFromFixture('Subsite', 'main'); + $subsite = $this->objFromFixture(Subsite::class, 'main'); Subsite::changeSubsite($subsite->ID); $page = $this->objFromFixture('Page', 'importantpage'); // Create two SVPs on other subsites - $subsite = $this->objFromFixture('Subsite', 'subsite1'); + $subsite = $this->objFromFixture(Subsite::class, 'subsite1'); Subsite::changeSubsite($subsite->ID); $vp1 = new SubsitesVirtualPage(); $vp1->CopyContentFromID = $page->ID; $vp1->write(); $vp1->doPublish(); - $subsite = $this->objFromFixture('Subsite', 'subsite2'); + $subsite = $this->objFromFixture(Subsite::class, 'subsite2'); Subsite::changeSubsite($subsite->ID); $vp2 = new SubsitesVirtualPage(); $vp2->CopyContentFromID = $page->ID; @@ -207,18 +212,18 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { $vp2->doPublish(); // Switch back to main site, unpublish source - $subsite = $this->objFromFixture('Subsite', 'main'); + $subsite = $this->objFromFixture(Subsite::class, 'main'); Subsite::changeSubsite($subsite->ID); $page = $this->objFromFixture('Page', 'importantpage'); $page->doUnpublish(); Subsite::changeSubsite($vp1->SubsiteID); - $onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp1->ID); + $onLive = Versioned::get_one_by_stage(SubsitesVirtualPage::class, 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp1->ID); $this->assertNull($onLive, 'SVP has been removed from live'); - $subsite = $this->objFromFixture('Subsite', 'subsite2'); + $subsite = $this->objFromFixture(Subsite::class, 'subsite2'); Subsite::changeSubsite($vp2->SubsiteID); - $onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp2->ID); + $onLive = Versioned::get_one_by_stage(SubsitesVirtualPage::class, 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp2->ID); $this->assertNull($onLive, 'SVP has been removed from live'); } @@ -228,8 +233,8 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest { */ function testSubsiteVirtualPageCanHaveSameUrlsegmentAsOtherSubsite() { Subsite::$write_hostmap = false; - $subsite1 = $this->objFromFixture('Subsite', 'subsite1'); - $subsite2 = $this->objFromFixture('Subsite', 'subsite2'); + $subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); + $subsite2 = $this->objFromFixture(Subsite::class, 'subsite2'); Subsite::changeSubsite($subsite1->ID); $subsite1Page = $this->objFromFixture('Page', 'subsite1_staff');