Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

Block generator base class.

Copyright: 2012 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 165 lines (6 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 3 classes

testing_block_generator:: (2 methods):
  reset()
  get_blockname()

name:: (3 methods):
  prepare_record()
  create_instance()
  preprocess_record()

name:: (3 methods):
  prepare_record()
  create_instance()
  preprocess_record()


Class: testing_block_generator  - X-Ref

Block generator base class.

Extend in blocks/xxxx/tests/generator/lib.php as class block_xxxx_generator.

reset()   X-Ref
To be called from data reset code only,
do not use in tests.

return: void

get_blockname()   X-Ref
Returns block name

return: string name of block that this class describes

Class: name  - X-Ref

prepare_record(stdClass $record)   X-Ref
Fill in record defaults.

param: stdClass $record
return: stdClass

create_instance($record = null, $options = array()   X-Ref
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.

param: array|stdClass $record forms the basis for the entry to be inserted in the block_instances table.
param: array $options further, block-specific options to control how the block is created.
return: stdClass the block_instance record that has just been created.

preprocess_record(stdClass $record, array $options)   X-Ref
Can be overridden to do block-specific processing. $record can be modified
in-place.

param: stdClass $record the data, before defaults are filled in.
param: array $options further, block-specific options, as passed to {@link create_instance()}.

Class: name  - X-Ref

prepare_record(stdClass $record)   X-Ref
Fill in record defaults.

param: stdClass $record
return: stdClass

create_instance($record = null, $options = array()   X-Ref
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.

param: array|stdClass $record forms the basis for the entry to be inserted in the block_instances table.
param: array $options further, block-specific options to control how the block is created.
return: stdClass the block_instance record that has just been created.

preprocess_record(stdClass $record, array $options)   X-Ref
Can be overridden to do block-specific processing. $record can be modified
in-place.

param: stdClass $record the data, before defaults are filled in.
param: array $options further, block-specific options, as passed to {@link create_instance()}.