mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Improve the file maker default and make the protected attribute configuration flags like they are menat to be
This commit is contained in:
parent
fc7d41930d
commit
04918fa862
@ -34,25 +34,26 @@ use SilverStripe\Security\Security;
|
|||||||
* The following yml config make 1040 files / 520mb:
|
* The following yml config make 1040 files / 520mb:
|
||||||
*
|
*
|
||||||
* To make 100K records, increase the base folderCountByDepth from 1 to 100 and run the task overnight
|
* To make 100K records, increase the base folderCountByDepth from 1 to 100 and run the task overnight
|
||||||
|
*
|
||||||
FTFileMakerTask:
|
* ```
|
||||||
documentsOnly: true
|
* FTFileMakerTask:
|
||||||
doSetFolderPermissions: true
|
* documentsOnly: true
|
||||||
doSetOldCreationDate: false
|
* doSetFolderPermissions: true
|
||||||
doRandomlyPublish: false
|
* doSetOldCreationDate: false
|
||||||
depth: 3
|
* doRandomlyPublish: false
|
||||||
folderCountByDepth:
|
* depth: 3
|
||||||
- 1
|
* folderCountByDepth:
|
||||||
- 9
|
* - 1
|
||||||
- 7
|
* - 9
|
||||||
- 0
|
* - 7
|
||||||
- 0
|
* - 0
|
||||||
fileCountByDepth:
|
* - 0
|
||||||
- 50
|
* fileCountByDepth:
|
||||||
- 25
|
* - 50
|
||||||
- 20
|
* - 25
|
||||||
- 0
|
* - 20
|
||||||
- 0
|
* - 0
|
||||||
|
* - 0
|
||||||
*
|
*
|
||||||
* Flush and run:
|
* Flush and run:
|
||||||
* /dev/tasks/FTFileMakerTask?flush&reset=1
|
* /dev/tasks/FTFileMakerTask?flush&reset=1
|
||||||
@ -62,21 +63,54 @@ FTFileMakerTask:
|
|||||||
*/
|
*/
|
||||||
class FTFileMakerTask extends BuildTask
|
class FTFileMakerTask extends BuildTask
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* If set to TRUE skip thumbnail generation
|
||||||
|
* @var bool
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $documentsOnly = false;
|
||||||
|
|
||||||
protected $documentsOnly = false;
|
/**
|
||||||
|
* Vary the permission on the folders
|
||||||
|
* @var bool
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $doSetFolderPermissions = true;
|
||||||
|
|
||||||
protected $doSetFolderPermissions = false;
|
/**
|
||||||
|
* Put some files in wrong store to test logic meant to correct this kind of problem..
|
||||||
|
* @var bool
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $doPutProtectedFilesInPublicStore = false;
|
||||||
|
|
||||||
// simulate scenario where protected files were uploaded into the wrong asset store
|
/**
|
||||||
protected $doPutProtectedFilesInPublicStore = false;
|
* Set the date of some files to an old date.
|
||||||
|
* @var bool
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $doSetOldCreationDate = true;
|
||||||
|
|
||||||
protected $doSetOldCreationDate = true;
|
/**
|
||||||
|
* Publish some files.
|
||||||
|
* @var bool
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $doRandomlyPublish = true;
|
||||||
|
|
||||||
protected $doRandomlyPublish = true;
|
/**
|
||||||
|
* How deep should or folder hierachy be.
|
||||||
|
* @var int
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $depth = 2;
|
||||||
|
|
||||||
protected $depth = 2;
|
/**
|
||||||
|
* Number of folders to create certain hierachy.
|
||||||
protected $folderCountByDepth = [
|
* @var int[]
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $folderCountByDepth = [
|
||||||
0 => 2,
|
0 => 2,
|
||||||
1 => 2,
|
1 => 2,
|
||||||
2 => 2,
|
2 => 2,
|
||||||
@ -84,9 +118,14 @@ class FTFileMakerTask extends BuildTask
|
|||||||
4 => 2,
|
4 => 2,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fileCountByDepth = [
|
/**
|
||||||
0 => 10,
|
* Number of files to create at various depths in the hierachy
|
||||||
1 => 8,
|
* @var int[]
|
||||||
|
* @config
|
||||||
|
*/
|
||||||
|
private static $fileCountByDepth = [
|
||||||
|
0 => 100,
|
||||||
|
1 => 30,
|
||||||
2 => 5,
|
2 => 5,
|
||||||
3 => 5,
|
3 => 5,
|
||||||
4 => 5,
|
4 => 5,
|
||||||
@ -269,15 +308,15 @@ class FTFileMakerTask extends BuildTask
|
|||||||
'Name' => "testfolder-{$prefix}{$i}",
|
'Name' => "testfolder-{$prefix}{$i}",
|
||||||
]);
|
]);
|
||||||
if ($doSetFolderPermissions) {
|
if ($doSetFolderPermissions) {
|
||||||
if ($i == 1) {
|
if ($i === 1) {
|
||||||
// the first folder should always be public to ensure there's some public folders
|
// the first folder should always be public to ensure there's some public folders
|
||||||
$folder->CanViewType = 'Inherit';
|
$folder->CanViewType = 'Inherit';
|
||||||
} elseif ($i == $folderCount) {
|
} elseif ($i === $folderCount) {
|
||||||
// the last folder should always be protected to ensure there's some protected folders
|
// the last folder should always be protected to ensure there's some protected folders
|
||||||
$folder->CanViewType = 'OnlyTheseUsers';
|
$folder->CanViewType = 'OnlyTheseUsers';
|
||||||
} else {
|
} else {
|
||||||
// all the other folder have a 33% chance of being a protected folder
|
// all the other folder have a 33% chance of being a protected folder
|
||||||
$folder->CanViewType = rand(0, 2) == 0 ? 'OnlyTheseUsers' : 'Inherit';
|
$folder->CanViewType = rand(0, 2) === 0 ? 'OnlyTheseUsers' : 'Inherit';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +345,7 @@ class FTFileMakerTask extends BuildTask
|
|||||||
|
|
||||||
// Randomly set old created date (for testing)
|
// Randomly set old created date (for testing)
|
||||||
if ($doSetOldCreationDate) {
|
if ($doSetOldCreationDate) {
|
||||||
if (rand(0, 10) == 0) {
|
if (rand(0, 10) === 0) {
|
||||||
$file->Created = '2010-01-01 00:00:00';
|
$file->Created = '2010-01-01 00:00:00';
|
||||||
$file->Title = '[old] ' . $file->Title;
|
$file->Title = '[old] ' . $file->Title;
|
||||||
}
|
}
|
||||||
@ -315,7 +354,7 @@ class FTFileMakerTask extends BuildTask
|
|||||||
$file->write();
|
$file->write();
|
||||||
|
|
||||||
if ($doRandomlyPublish) {
|
if ($doRandomlyPublish) {
|
||||||
if (rand(0, 1) == 0) {
|
if (rand(0, 1) === 0) {
|
||||||
$file->publishFile();
|
$file->publishFile();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user