public function setUp()
 {
     parent::setUp();
     // Set backend and base url
     \Versioned::reading_stage('Stage');
     AssetStoreTest_SpyStore::activate('AssetControlExtensionTest');
     $this->logInWithPermission('ADMIN');
     // Setup fixture manually
     $object1 = new AssetControlExtensionTest_VersionedObject();
     $object1->Title = 'My object';
     $fish1 = realpath(__DIR__ . '/../model/testimages/test-image-high-quality.jpg');
     $object1->Header->setFromLocalFile($fish1, 'Header/MyObjectHeader.jpg');
     $object1->Download->setFromString('file content', 'Documents/File.txt');
     $object1->write();
     $object1->doPublish();
     $object2 = new AssetControlExtensionTest_Object();
     $object2->Title = 'Unversioned';
     $object2->Image->setFromLocalFile($fish1, 'Images/BeautifulFish.jpg');
     $object2->write();
     $object3 = new AssetControlExtensionTest_ArchivedObject();
     $object3->Title = 'Archived';
     $object3->Header->setFromLocalFile($fish1, 'Archived/MyObjectHeader.jpg');
     $object3->write();
     $object3->doPublish();
 }
Пример #2
0
 public function setUp()
 {
     parent::setUp();
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     Config::inst()->update('SSViewer_FromString', 'cache_template', false);
     AssetStoreTest_SpyStore::activate('SSViewerTest');
 }
 public function setUp()
 {
     parent::setUp();
     // Set backend
     AssetStoreTest_SpyStore::activate('DBFileTest');
     Config::inst()->update('Director', 'alternate_base_url', '/mysite/');
 }
 public function setUp()
 {
     parent::setUp();
     $this->logInWithPermission('ADMIN');
     // Save versioned state
     $this->oldReadingMode = Versioned::get_reading_mode();
     Versioned::set_stage(Versioned::DRAFT);
     // Set backend root to /UploadFieldTest
     AssetStoreTest_SpyStore::activate('UploadFieldTest');
     // Set the File Name Filter replacements so files have the expected names
     Config::inst()->update('SilverStripe\\Assets\\FileNameFilter', 'default_replacements', array('/\\s/' => '-', '/_/' => '-', '/[^A-Za-z0-9+.\\-]+/' => '', '/[\\-]{2,}/' => '-', '/^[\\.\\-_]+/' => ''));
     // Create a test folders for each of the fixture references
     foreach (Folder::get() as $folder) {
         $path = AssetStoreTest_SpyStore::getLocalPath($folder);
         Filesystem::makeFolder($path);
     }
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder');
     foreach ($files as $file) {
         $path = AssetStoreTest_SpyStore::getLocalPath($file);
         Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
     }
 }
Пример #5
0
 public function setUp()
 {
     parent::setUp();
     // Set backend root to /ImageTest
     AssetStoreTest_SpyStore::activate('FileTest');
     // Create a test folders for each of the fixture references
     $folderIDs = $this->allFixtureIDs('Folder');
     foreach ($folderIDs as $folderID) {
         $folder = DataObject::get_by_id('Folder', $folderID);
         $filePath = ASSETS_PATH . '/FileTest/' . $folder->getFilename();
         SS_Filesystem::makeFolder($filePath);
     }
     // Create a test files for each of the fixture references
     $fileIDs = $this->allFixtureIDs('File');
     foreach ($fileIDs as $fileID) {
         $file = DataObject::get_by_id('File', $fileID);
         $root = ASSETS_PATH . '/FileTest/';
         if ($folder = $file->Parent()) {
             $root .= $folder->getFilename();
         }
         $path = $root . substr($file->getHash(), 0, 10) . '/' . basename($file->getFilename());
         SS_Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
     }
     // Conditional fixture creation in case the 'cms' module is installed
     if (class_exists('ErrorPage')) {
         $page = new ErrorPage(array('Title' => 'Page not Found', 'ErrorCode' => 404));
         $page->write();
         $page->publish('Stage', 'Live');
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->logInWithPermission('ADMIN');
     Versioned::reading_stage('Stage');
     // Set backend root to /AssetFieldTest
     AssetStoreTest_SpyStore::activate('AssetFieldTest');
     $create = function ($path) {
         Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
     };
     // Write all DBFile references
     foreach (AssetFieldTest_Object::get() as $object) {
         $path = AssetStoreTest_SpyStore::getLocalPath($object->File);
         $create($path);
     }
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $path = AssetStoreTest_SpyStore::getLocalPath($file);
         $create($path);
     }
 }
 public function setUp()
 {
     if (get_class($this) == "ImageTest") {
         $this->skipTest = true;
     }
     parent::setUp();
     if ($this->skipTest) {
         return;
     }
     // Set backend root to /ImageTest
     AssetStoreTest_SpyStore::activate('ImageTest');
     // Copy test images for each of the fixture references
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $image) {
         $filePath = AssetStoreTest_SpyStore::getLocalPath($image);
         // Only correct for test asset store
         $sourcePath = BASE_PATH . '/framework/tests/model/testimages/' . $image->Name;
         if (!file_exists($filePath)) {
             SS_Filesystem::makeFolder(dirname($filePath));
             if (!copy($sourcePath, $filePath)) {
                 user_error('Failed to copy test images', E_USER_ERROR);
             }
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     SSViewer::config()->update('source_file_comments', false);
     SSViewer_FromString::config()->update('cache_template', false);
     AssetStoreTest_SpyStore::activate('SSViewerTest');
     $this->oldServer = $_SERVER;
 }
 public function setUp()
 {
     parent::setUp();
     // Set temporary asset backend store
     AssetStoreTest_SpyStore::activate('ErrorPageTest');
     Config::inst()->update('ErrorPage', 'enable_static_file', true);
     Config::inst()->update('Director', 'environment_type', 'live');
     $this->logInWithPermission('ADMIN');
 }
 public function setUp()
 {
     parent::setUp();
     AssetStoreTest_SpyStore::activate('SiteTreeHtmlEditorFieldTest');
     $this->logInWithPermission('ADMIN');
     // Write file contents
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $destPath = AssetStoreTest_SpyStore::getLocalPath($file);
         Filesystem::makeFolder(dirname($destPath));
         file_put_contents($destPath, str_repeat('x', 1000000));
     }
 }
 public function setUp()
 {
     parent::setUp();
     // Set backend root to /HtmlEditorFieldTest
     AssetStoreTest_SpyStore::activate('HtmlEditorFieldTest');
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $fromPath = BASE_PATH . '/framework/tests/forms/images/' . $file->Name;
         $destPath = AssetStoreTest_SpyStore::getLocalPath($file);
         // Only correct for test asset store
         SS_Filesystem::makeFolder(dirname($destPath));
         copy($fromPath, $destPath);
     }
 }
 public function setUp()
 {
     parent::setUp();
     Versioned::set_stage(Versioned::DRAFT);
     // Set backend root to /DataDifferencerTest
     AssetStoreTest_SpyStore::activate('DataDifferencerTest');
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder');
     foreach ($files as $file) {
         $fromPath = FRAMEWORK_PATH . '/tests/model/testimages/' . $file->Name;
         $destPath = AssetStoreTest_SpyStore::getLocalPath($file);
         // Only correct for test asset store
         Filesystem::makeFolder(dirname($destPath));
         copy($fromPath, $destPath);
     }
 }
 public function setUp()
 {
     Config::nest();
     // additional nesting here necessary
     Config::inst()->update('File', 'migrate_legacy_file', false);
     parent::setUp();
     // Set backend root to /FileMigrationHelperTest/assets
     AssetStoreTest_SpyStore::activate('FileMigrationHelperTest/assets');
     // Ensure that each file has a local record file in this new assets base
     $from = FRAMEWORK_PATH . '/tests/model/testimages/test-image-low-quality.jpg';
     foreach (File::get()->exclude('ClassName', 'Folder') as $file) {
         $dest = AssetStoreTest_SpyStore::base_path() . '/' . $file->generateFilename();
         SS_Filesystem::makeFolder(dirname($dest));
         copy($from, $dest);
     }
 }
 public function setUp()
 {
     parent::setUp();
     // Set backend root to /HTMLEditorFieldTest
     AssetStoreTest_SpyStore::activate('HTMLEditorFieldTest');
     // Set the File Name Filter replacements so files have the expected names
     Config::inst()->update('SilverStripe\\Assets\\FileNameFilter', 'default_replacements', array('/\\s/' => '-', '/_/' => '-', '/[^A-Za-z0-9+.\\-]+/' => '', '/[\\-]{2,}/' => '-', '/^[\\.\\-_]+/' => ''));
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder');
     foreach ($files as $file) {
         $fromPath = FRAMEWORK_PATH . '/tests/forms/images/' . $file->Name;
         $destPath = AssetStoreTest_SpyStore::getLocalPath($file);
         // Only correct for test asset store
         Filesystem::makeFolder(dirname($destPath));
         copy($fromPath, $destPath);
     }
 }
 public function setUp()
 {
     parent::setUp();
     Config::inst()->update('HTMLEditorField_Toolbar', 'fileurl_scheme_whitelist', array('http'));
     Config::inst()->update('HTMLEditorField_Toolbar', 'fileurl_domain_whitelist', array('example.com'));
     // Filesystem mock
     AssetStoreTest_SpyStore::activate(__CLASS__);
     // Load up files
     /** @var File $file1 */
     $file1 = $this->objFromFixture('File', 'example_file');
     $file1->setFromString(str_repeat('x', 1000), $file1->Name);
     $file1->write();
     /** @var Image $image1 */
     $image1 = $this->objFromFixture('Image', 'example_image');
     $image1->setFromLocalFile(__DIR__ . '/images/HTMLEditorFieldTest-example.jpg', 'folder/subfolder/HTMLEditorFieldTest_example.jpg');
     $image1->write();
 }
 public function setUp()
 {
     parent::setUp();
     AssetStoreTest_SpyStore::activate('FileLinkTrackingTest');
     $this->logInWithPermission('ADMIN');
     // Write file contents
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $destPath = AssetStoreTest_SpyStore::getLocalPath($file);
         Filesystem::makeFolder(dirname($destPath));
         file_put_contents($destPath, str_repeat('x', 1000000));
     }
     // Since we can't hard-code IDs, manually inject image tracking shortcode
     $imageID = $this->idFromFixture('Image', 'file1');
     $page = $this->objFromFixture('Page', 'page1');
     $page->Content = sprintf('<p><img src="/assets/FileLinkTrackingTest/55b443b601/testscript-test-file.jpg" data-fileid="%d" /></p>', $imageID);
     $page->write();
 }
Пример #17
0
 public function setUp()
 {
     parent::setUp();
     // Set backend root to /FolderTest
     AssetStoreTest_SpyStore::activate('FolderTest');
     // Create a test folders for each of the fixture references
     foreach (Folder::get() as $folder) {
         $path = AssetStoreTest_SpyStore::getLocalPath($folder);
         SS_Filesystem::makeFolder($path);
     }
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $path = AssetStoreTest_SpyStore::getLocalPath($file);
         SS_Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
     }
 }
 public function setUp()
 {
     parent::setUp();
     // Set backend root to /ImageTest
     AssetStoreTest_SpyStore::activate('ProtectedFileControllerTest');
     // Create a test folders for each of the fixture references
     foreach (Folder::get() as $folder) {
         /** @var Folder $folder */
         $filePath = AssetStoreTest_SpyStore::getLocalPath($folder);
         \Filesystem::makeFolder($filePath);
     }
     // Create a test files for each of the fixture references
     foreach (File::get()->exclude('ClassName', 'Folder') as $file) {
         /** @var File $file */
         $path = AssetStoreTest_SpyStore::getLocalPath($file);
         \Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
         // Create variant for each file
         $this->getAssetStore()->setFromString(str_repeat('y', 100), $file->Filename, $file->Hash, 'variant');
     }
 }
 public function setUp()
 {
     parent::setUp();
     // Execute specific subclass
     if (get_class($this) == "ImageTest") {
         $this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
         return;
     }
     // Set backend root to /ImageTest
     AssetStoreTest_SpyStore::activate('ImageTest');
     // Copy test images for each of the fixture references
     $files = File::get()->exclude('ClassName', 'SilverStripe\\Assets\\Folder');
     foreach ($files as $image) {
         $filePath = AssetStoreTest_SpyStore::getLocalPath($image);
         // Only correct for test asset store
         $sourcePath = FRAMEWORK_PATH . '/tests/model/testimages/' . $image->Name;
         if (!file_exists($filePath)) {
             SSFilesystem::makeFolder(dirname($filePath));
             if (!copy($sourcePath, $filePath)) {
                 user_error('Failed to copy test images', E_USER_ERROR);
             }
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->loginWithPermission('ADMIN');
     // Save versioned state
     $this->oldReadingMode = Versioned::get_reading_mode();
     Versioned::reading_stage('Stage');
     // Set backend root to /UploadFieldTest
     AssetStoreTest_SpyStore::activate('UploadFieldTest');
     // Create a test folders for each of the fixture references
     foreach (Folder::get() as $folder) {
         $path = AssetStoreTest_SpyStore::getLocalPath($folder);
         Filesystem::makeFolder($path);
     }
     // Create a test files for each of the fixture references
     $files = File::get()->exclude('ClassName', 'Folder');
     foreach ($files as $file) {
         $path = AssetStoreTest_SpyStore::getLocalPath($file);
         Filesystem::makeFolder(dirname($path));
         $fh = fopen($path, "w+");
         fwrite($fh, str_repeat('x', 1000000));
         fclose($fh);
     }
 }
 public function setUp()
 {
     parent::setUp();
     // Set backend and base url
     AssetStoreTest_SpyStore::activate('AssetStoreTest');
 }
Пример #22
0
 public function setUp()
 {
     parent::setUp();
     AssetStoreTest_SpyStore::activate('UploadTest');
 }
 public function setUp()
 {
     parent::setUp();
     Versioned::reading_stage('Stage');
     AssetStoreTest_SpyStore::activate('UploadTest');
 }
 public function setUp()
 {
     parent::setUp();
     AssetStoreTest_SpyStore::activate('RequirementsTest');
     // Set backend root to /RequirementsTest
 }
 public function setUp()
 {
     parent::setUp();
     Versioned::set_stage(Versioned::DRAFT);
     AssetStoreTest_SpyStore::activate('UploadTest');
 }