Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 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()}.