Explictly set the FileNameFilter replacements before relying on them

This commit is contained in:
Cochrane, Mike 2016-05-09 20:12:29 +12:00
parent e2d180a754
commit faffdf4981
3 changed files with 27 additions and 0 deletions

View File

@ -21,6 +21,15 @@ class FolderTest extends SapphireTest {
// Set backend root to /FolderTest
AssetStoreTest_SpyStore::activate('FolderTest');
// Set the File Name Filter replacements so files have the expected names
Config::inst()->update('FileNameFilter', 'default_replacements', array(
'/\s/' => '-', // remove whitespace
'/_/' => '-', // underscores to dashes
'/[^A-Za-z0-9+.\-]+/' => '', // remove non-ASCII chars, only allow alphanumeric plus dash and dot
'/[\-]{2,}/' => '-', // remove duplicate dashes
'/^[\.\-_]+/' => '', // Remove all leading dots, dashes or underscores
));
// Create a test folders for each of the fixture references
foreach(Folder::get() as $folder) {
$path = AssetStoreTest_SpyStore::getLocalPath($folder);

View File

@ -24,6 +24,15 @@ class HTMLEditorFieldTest extends FunctionalTest {
// Set backend root to /HTMLEditorFieldTest
AssetStoreTest_SpyStore::activate('HTMLEditorFieldTest');
// Set the File Name Filter replacements so files have the expected names
Config::inst()->update('FileNameFilter', 'default_replacements', array(
'/\s/' => '-', // remove whitespace
'/_/' => '-', // underscores to dashes
'/[^A-Za-z0-9+.\-]+/' => '', // remove non-ASCII chars, only allow alphanumeric plus dash and dot
'/[\-]{2,}/' => '-', // remove duplicate dashes
'/^[\.\-_]+/' => '', // Remove all leading dots, dashes or underscores
));
// Create a test files for each of the fixture references
$files = File::get()->exclude('ClassName', 'Folder');
foreach($files as $file) {

View File

@ -28,6 +28,15 @@ class UploadFieldTest extends FunctionalTest {
// Set backend root to /UploadFieldTest
AssetStoreTest_SpyStore::activate('UploadFieldTest');
// Set the File Name Filter replacements so files have the expected names
Config::inst()->update('FileNameFilter', 'default_replacements', array(
'/\s/' => '-', // remove whitespace
'/_/' => '-', // underscores to dashes
'/[^A-Za-z0-9+.\-]+/' => '', // remove non-ASCII chars, only allow alphanumeric plus dash and dot
'/[\-]{2,}/' => '-', // remove duplicate dashes
'/^[\.\-_]+/' => '', // Remove all leading dots, dashes or underscores
));
// Create a test folders for each of the fixture references
foreach(Folder::get() as $folder) {
$path = AssetStoreTest_SpyStore::getLocalPath($folder);