mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Add counts to file task, update readme
This commit is contained in:
parent
e0d4faec11
commit
f932f5e110
21
README.md
21
README.md
@ -3,7 +3,7 @@
|
|||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Aids core and module developers in testing their code against
|
Aids core and module developers in testing their code against
|
||||||
a set of sample data and behaviour.
|
a set of sample data and behaviour.
|
||||||
|
|
||||||
* Shows all core form fields, including their disabled and readonly state
|
* Shows all core form fields, including their disabled and readonly state
|
||||||
* Shows sample GridField instance including data
|
* Shows sample GridField instance including data
|
||||||
@ -25,17 +25,32 @@ For example, to test the tagfield module, remove the `frameworktest/code/tagfiel
|
|||||||
|
|
||||||
The module creates some default pages for different CMS behaviours.
|
The module creates some default pages for different CMS behaviours.
|
||||||
The CMS is intended to be perform well with a couple of thousand pages.
|
The CMS is intended to be perform well with a couple of thousand pages.
|
||||||
If you want to test the CMS behaviour for a large and nested tree,
|
If you want to test the CMS behaviour for a large and nested tree,
|
||||||
the module includes a simple generator task: `dev/tasks/FTPageMakerTask`.
|
the module includes a simple generator task: `dev/tasks/FTPageMakerTask`.
|
||||||
It will create 3^5 pages by default, so takes a while to run through.
|
It will create 3^5 pages by default, so takes a while to run through.
|
||||||
|
|
||||||
|
## Configuring the amount of data
|
||||||
|
|
||||||
|
Both `FTPageMagerTask` and `FTFileMakerTask` allow the amount of generated content to be configured.
|
||||||
|
To do this, pass a comma-seprarated list of integers representing the amount of records to create at each
|
||||||
|
depth.
|
||||||
|
|
||||||
|
`$ vendor/bin/sake dev/tasks/FTPageMakerTask pageCounts=10,200,5,5`
|
||||||
|
|
||||||
|
`$ vendor/bin/sake dev/tasks/FTFileMakerTask fileCounts=5,300,55,5 folderCounts=1,5,5,5`
|
||||||
|
|
||||||
|
## Guaranteed unique images
|
||||||
|
|
||||||
|
The `FTFileMakerTask` will randomly watermark each reference to your images by default. If you want to disable this,
|
||||||
|
set the `uniqueImages` config variable to `false`.
|
||||||
|
|
||||||
## Blocks
|
## Blocks
|
||||||
|
|
||||||
When [dnadesign/silverstripe-elemental](https://github.com/dnadesign/silverstripe-elemental)
|
When [dnadesign/silverstripe-elemental](https://github.com/dnadesign/silverstripe-elemental)
|
||||||
is installed, the `FTPageMakerTask` can also generate blocks within those pages automatically.
|
is installed, the `FTPageMakerTask` can also generate blocks within those pages automatically.
|
||||||
It has a few hardcoded sample data structures for common block types,
|
It has a few hardcoded sample data structures for common block types,
|
||||||
and randomly creates a number of blocks, as well as randomly choosing to publish them.
|
and randomly creates a number of blocks, as well as randomly choosing to publish them.
|
||||||
Relies on files and images being available to add as sample data.
|
Relies on files and images being available to add as sample data.
|
||||||
|
|
||||||
Additional setup:
|
Additional setup:
|
||||||
|
|
||||||
|
@ -185,6 +185,18 @@ class FTFileMakerTask extends BuildTask
|
|||||||
/** @var Member */
|
/** @var Member */
|
||||||
protected $anonymousMember = null;
|
protected $anonymousMember = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow override of the fileCountByDepth
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fileCounts = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow override of the folderCountByDepth
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $folderCounts = [];
|
||||||
|
|
||||||
public function run($request)
|
public function run($request)
|
||||||
{
|
{
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
@ -209,6 +221,26 @@ class FTFileMakerTask extends BuildTask
|
|||||||
$this->reset();
|
$this->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fileCounts = $request->getVar('fileCounts');
|
||||||
|
if ($fileCounts) {
|
||||||
|
$counts = explode(',', $fileCounts);
|
||||||
|
$this->fileCounts = array_map(function ($int) {
|
||||||
|
return (int) trim($int);
|
||||||
|
}, $counts);
|
||||||
|
} else {
|
||||||
|
$this->fileCounts = self::config()->get('fileCountByDepth');
|
||||||
|
}
|
||||||
|
|
||||||
|
$folderCounts = $request->getVar('folderCounts');
|
||||||
|
if ($folderCounts) {
|
||||||
|
$counts = explode(',', $folderCounts);
|
||||||
|
$this->folderCounts = array_map(function ($int) {
|
||||||
|
return (int) trim($int);
|
||||||
|
}, $counts);
|
||||||
|
} else {
|
||||||
|
$this->folderCounts = self::config()->get('folderCountByDepth');
|
||||||
|
}
|
||||||
|
|
||||||
echo "Downloading fixtures" . $this->lineBreak;
|
echo "Downloading fixtures" . $this->lineBreak;
|
||||||
$fixtureFilePaths = $this->downloadFixtureFiles();
|
$fixtureFilePaths = $this->downloadFixtureFiles();
|
||||||
|
|
||||||
@ -302,8 +334,8 @@ class FTFileMakerTask extends BuildTask
|
|||||||
protected function generateFiles($fixtureFilePaths, $depth = 0, $prefix = "0", $parentID = 0)
|
protected function generateFiles($fixtureFilePaths, $depth = 0, $prefix = "0", $parentID = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
$folderCount = self::config()->get('folderCountByDepth')[$depth];
|
$folderCount = $this->folderCounts[$depth];
|
||||||
$fileCount = self::config()->get('fileCountByDepth')[$depth];
|
$fileCount = $this->fileCounts[$depth];
|
||||||
|
|
||||||
$doSetFolderPermissions = (bool) self::config()->get('doSetFolderPermissions');
|
$doSetFolderPermissions = (bool) self::config()->get('doSetFolderPermissions');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user