Default block generator class.
More...
|
| __construct (testing_data_generator $datagenerator, string $blockname) |
| Constructor.
|
|
| create_instance ($record=null, $options=array()) |
| Create a test block instance.
|
|
| get_blockname () |
| {Returns block name.- Return values
-
string | name of block that this class describes |
- Exceptions
-
}
|
|
| reset () |
| To be called from data reset code only, do not use in tests.
|
|
|
| insert_files (stdClass $instance, stdClass $record, string $table, context $context, string $component, string $filearea, int $targetitemid) |
| Update the instance record, inserting any files that are referenced.
|
|
| prepare_record (stdClass $record) |
| Fill in record defaults.
|
|
| preprocess_record (stdClass $record, array $options) |
| Can be overridden to do block-specific processing.
|
|
| set_user (?stdClass $user=null) |
| Set the current user during data generation.
|
|
|
testing_data_generator | $datagenerator |
|
int | $instancecount = 0 |
| number of created instances
|
|
Default block generator class.
- Copyright
- 2021 Moodle Pty Ltd. (http://moodle.com)
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later Default block generator class to be used when a specific one is not supported.
- Copyright
- 2021 Moodle Pty Ltd. (http://moodle.com)
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
default_block_generator::__construct |
( |
testing_data_generator | $datagenerator, |
|
|
string | $blockname ) |
Constructor.
- Parameters
-
testing_data_generator | $datagenerator | |
string | $blockname | |
◆ create_instance()
testing_block_generator::create_instance |
( |
| $record = null, |
|
|
| $options = array() ) |
|
inherited |
Create a test block instance.
The $record passed in becomes the basis for the new row added to the block_instances table. You only need to supply the values of interest. Any missing values have sensible defaults filled in.
The $options array provides additional data, not directly related to what will be inserted in the block_instance table, which may affect the block that is created. The meanings of any data passed here depends on the particular type of block being created.
- Parameters
-
array | stdClass | $record | forms the basis for the entry to be inserted in the block_instances table. |
array | $options | further, block-specific options to control how the block is created. |
- Return values
-
stdClass | the block_instance record that has just been created. |
◆ get_blockname()
default_block_generator::get_blockname |
( |
| ) |
|
{Returns block name.
- Return values
-
string | name of block that this class describes |
- Exceptions
-
}
Reimplemented from testing_block_generator.
◆ insert_files()
component_generator_base::insert_files |
( |
stdClass | $instance, |
|
|
stdClass | $record, |
|
|
string | $table, |
|
|
context | $context, |
|
|
string | $component, |
|
|
string | $filearea, |
|
|
int | $targetitemid ) |
|
protectedinherited |
Update the instance record, inserting any files that are referenced.
- Parameters
-
stdClass | $instance | The instance record of the already-created record |
stdClass | $record | The data passed in to create the instance |
string | $table | The table that the data exists in |
context | $context | The context of the instance |
string | $component | The component of the owning plugin |
string | $filearea | The name of the file area |
int | $targetitemid | The itemid to use when saving the files |
- Return values
-
stdClass | The updated instance record |
◆ prepare_record()
testing_block_generator::prepare_record |
( |
stdClass | $record | ) |
|
|
protectedinherited |
Fill in record defaults.
- Parameters
-
- Return values
-
◆ preprocess_record()
testing_block_generator::preprocess_record |
( |
stdClass | $record, |
|
|
array | $options ) |
|
protectedinherited |
Can be overridden to do block-specific processing.
$record can be modified in-place.
- Parameters
-
stdClass | $record | the data, before defaults are filled in. |
array | $options | further, block-specific options, as passed to create_instance(). |
◆ reset()
testing_block_generator::reset |
( |
| ) |
|
|
inherited |
◆ set_user()
component_generator_base::set_user |
( |
?stdClass | $user = null | ) |
|
|
protectedinherited |
Set the current user during data generation.
This should be avoided wherever possible, but in some situations underlying code will insert data as the current user.
- Parameters
-
The documentation for this class was generated from the following file: