From 38070ab2d3a8d768c60047e31d39d74e12c13242 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 15 Nov 2016 18:06:31 +1300 Subject: [PATCH] API Update tests to reflect renamed services --- tests/model/ErrorPageFileExtensionTest.php | 6 ++++-- tests/model/ErrorPageTest.php | 12 +++++++----- tests/model/FileLinkTrackingTest.php | 8 +++++--- tests/model/SiteTreeBrokenLinksTest.php | 6 ++++-- tests/model/SiteTreeHTMLEditorFieldTest.php | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/tests/model/ErrorPageFileExtensionTest.php b/tests/model/ErrorPageFileExtensionTest.php index 804f35fc..c789d8fe 100644 --- a/tests/model/ErrorPageFileExtensionTest.php +++ b/tests/model/ErrorPageFileExtensionTest.php @@ -5,6 +5,8 @@ use SilverStripe\Assets\File; use SilverStripe\Control\Session; use SilverStripe\View\Parsers\ShortcodeParser; use SilverStripe\Dev\SapphireTest; +use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore; + class ErrorPageFileExtensionTest extends SapphireTest { @@ -17,7 +19,7 @@ class ErrorPageFileExtensionTest extends SapphireTest { parent::setUp(); $this->versionedMode = Versioned::get_reading_mode(); Versioned::set_stage(Versioned::DRAFT); - AssetStoreTest_SpyStore::activate('ErrorPageFileExtensionTest'); + TestAssetStore::activate('ErrorPageFileExtensionTest'); $file = new File(); $file->setFromString('dummy', 'dummy.txt'); $file->write(); @@ -25,7 +27,7 @@ class ErrorPageFileExtensionTest extends SapphireTest { public function tearDown() { Versioned::set_reading_mode($this->versionedMode); - AssetStoreTest_SpyStore::reset(); + TestAssetStore::reset(); parent::tearDown(); // TODO: Change the autogenerated stub } diff --git a/tests/model/ErrorPageTest.php b/tests/model/ErrorPageTest.php index dd1dc7f5..eef48b9f 100644 --- a/tests/model/ErrorPageTest.php +++ b/tests/model/ErrorPageTest.php @@ -4,6 +4,8 @@ use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\CMS\Model\ErrorPage; use SilverStripe\Core\Config\Config; use SilverStripe\Dev\FunctionalTest; +use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore; + @@ -25,14 +27,14 @@ class ErrorPageTest extends FunctionalTest { public function setUp() { parent::setUp(); // Set temporary asset backend store - AssetStoreTest_SpyStore::activate('ErrorPageTest'); + TestAssetStore::activate('ErrorPageTest'); Config::inst()->update('SilverStripe\\CMS\\Model\\ErrorPage', 'enable_static_file', true); Config::inst()->update('SilverStripe\\Control\\Director', 'environment_type', 'live'); $this->logInWithPermission('ADMIN'); } public function tearDown() { - AssetStoreTest_SpyStore::reset(); + TestAssetStore::reset(); parent::tearDown(); } @@ -88,7 +90,7 @@ class ErrorPageTest extends FunctionalTest { public function testStaticCaching() { // Test new error code does not have static content $this->assertEmpty(ErrorPage::get_content_for_errorcode('401')); - $expectedErrorPagePath = AssetStoreTest_SpyStore::base_path() . '/error-401.html'; + $expectedErrorPagePath = TestAssetStore::base_path() . '/error-401.html'; $this->assertFileNotExists($expectedErrorPagePath, 'Error page is not automatically cached'); // Write new 401 page @@ -101,7 +103,7 @@ class ErrorPageTest extends FunctionalTest { // Static cache should now exist $this->assertNotEmpty(ErrorPage::get_content_for_errorcode('401')); - $expectedErrorPagePath = AssetStoreTest_SpyStore::base_path() . '/error-401.html'; + $expectedErrorPagePath = TestAssetStore::base_path() . '/error-401.html'; $this->assertFileExists($expectedErrorPagePath, 'Error page is cached'); } @@ -126,7 +128,7 @@ class ErrorPageTest extends FunctionalTest { // Static content is not available $this->assertEmpty(ErrorPage::get_content_for_errorcode('405')); - $expectedErrorPagePath = AssetStoreTest_SpyStore::base_path() . '/error-405.html'; + $expectedErrorPagePath = TestAssetStore::base_path() . '/error-405.html'; $this->assertFileNotExists($expectedErrorPagePath, 'Error page is not cached in static location'); } } diff --git a/tests/model/FileLinkTrackingTest.php b/tests/model/FileLinkTrackingTest.php index ed5a4553..716bb9f1 100644 --- a/tests/model/FileLinkTrackingTest.php +++ b/tests/model/FileLinkTrackingTest.php @@ -6,6 +6,8 @@ use SilverStripe\CMS\Model\VirtualPage; use SilverStripe\Assets\File; use SilverStripe\Assets\Filesystem; use SilverStripe\Dev\SapphireTest; +use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore; + @@ -20,13 +22,13 @@ class FileLinkTrackingTest extends SapphireTest { Versioned::set_stage(Versioned::DRAFT); - AssetStoreTest_SpyStore::activate('FileLinkTrackingTest'); + TestAssetStore::activate('FileLinkTrackingTest'); $this->logInWithPermission('ADMIN'); // Write file contents $files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder'); foreach($files as $file) { - $destPath = AssetStoreTest_SpyStore::getLocalPath($file); + $destPath = TestAssetStore::getLocalPath($file); Filesystem::makeFolder(dirname($destPath)); file_put_contents($destPath, str_repeat('x', 1000000)); // Ensure files are published, thus have public urls @@ -44,7 +46,7 @@ class FileLinkTrackingTest extends SapphireTest { } public function tearDown() { - AssetStoreTest_SpyStore::reset(); + TestAssetStore::reset(); parent::tearDown(); } diff --git a/tests/model/SiteTreeBrokenLinksTest.php b/tests/model/SiteTreeBrokenLinksTest.php index 311efa24..f00332db 100644 --- a/tests/model/SiteTreeBrokenLinksTest.php +++ b/tests/model/SiteTreeBrokenLinksTest.php @@ -7,6 +7,8 @@ use SilverStripe\CMS\Model\VirtualPage; use SilverStripe\CMS\Model\RedirectorPage; use SilverStripe\Assets\File; use SilverStripe\Dev\SapphireTest; +use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore; + @@ -23,12 +25,12 @@ class SiteTreeBrokenLinksTest extends SapphireTest { parent::setUp(); Versioned::set_stage(Versioned::DRAFT); - AssetStoreTest_SpyStore::activate('SiteTreeBrokenLinksTest'); + TestAssetStore::activate('SiteTreeBrokenLinksTest'); $this->logInWithPermission('ADMIN'); } public function tearDown() { - AssetStoreTest_SpyStore::reset(); + TestAssetStore::reset(); parent::tearDown(); } diff --git a/tests/model/SiteTreeHTMLEditorFieldTest.php b/tests/model/SiteTreeHTMLEditorFieldTest.php index bdff016a..80672901 100644 --- a/tests/model/SiteTreeHTMLEditorFieldTest.php +++ b/tests/model/SiteTreeHTMLEditorFieldTest.php @@ -6,6 +6,8 @@ use SilverStripe\Assets\Filesystem; use SilverStripe\Forms\HTMLEditor\HTMLEditorField; use SilverStripe\Dev\CSSContentParser; use SilverStripe\Dev\FunctionalTest; +use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore; + class SiteTreeHTMLEditorFieldTest extends FunctionalTest { protected static $fixture_file = 'SiteTreeHTMLEditorFieldTest.yml'; @@ -14,20 +16,20 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest { public function setUp() { parent::setUp(); - AssetStoreTest_SpyStore::activate('SiteTreeHTMLEditorFieldTest'); + TestAssetStore::activate('SiteTreeHTMLEditorFieldTest'); $this->logInWithPermission('ADMIN'); // Write file contents $files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder'); foreach($files as $file) { - $destPath = AssetStoreTest_SpyStore::getLocalPath($file); + $destPath = TestAssetStore::getLocalPath($file); Filesystem::makeFolder(dirname($destPath)); file_put_contents($destPath, str_repeat('x', 1000000)); } } public function tearDown() { - AssetStoreTest_SpyStore::reset(); + TestAssetStore::reset(); parent::tearDown(); }