Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Public Member Functions | |
assertDebuggingCalled ($debugmessage=null, $debuglevel=null, $message='') | |
Assert that exactly debugging was just called once. | |
assertDebuggingCalledCount ($expectedcount, $debugmessages=array(), $debuglevels=array(), $message='') | |
Asserts how many times debugging has been called. | |
assertDebuggingNotCalled ($message='') | |
Call when no debugging() messages expected. | |
assertEqualsIgnoringWhitespace ($expected, $actual, string $message='') | |
Assert that two Date/Time strings are equal. | |
assertEventContextNotUsed (\core\event\base $event, $message='') | |
Assert that various event methods are not using event->context. | |
assertEventLegacyData ($expected, core\event\base $event, $message='') | |
Assert that an event legacy data is equal to the expected value. | |
assertEventLegacyLogData ($expected, core\event\base $event, $message='') | |
Assert that an event legacy log data is equal to the expected value. | |
assertTimeCurrent ($time, $message='') | |
Assert that: start < $time < time() | |
filter (array $content) | |
Method used for filtering repository file nodes based on the current disallowed file extensions list. | |
getDebuggingMessages () | |
Return debugging messages from the current test. | |
getExternalTestFileUrl ($path, $https=false) | |
Returns UTL of the external test file. | |
preventResetByRollback () | |
Call this method from test if you want to make sure that the resetting of database is done the slow way without transaction rollback. | |
recurseFolders ($path, $callback, $fileregexp='/.*/', $exclude=false, $ignorefolders=array()) | |
Recursively visit all the files in the source tree. | |
redirectEmails () | |
Starts email redirection. | |
redirectEvents () | |
Starts event redirection. | |
redirectHook (string $hookname, callable $callback) | |
Override hook callbacks. | |
redirectMessages () | |
Starts message redirection. | |
resetAfterTest ($reset=true) | |
Reset everything after current test. | |
resetDebugging () | |
Clear all previous debugging messages in current test and revert to default DEVELOPER_DEBUG level. | |
runBare () | |
Runs the bare test sequence. | |
setCurrentTimeStart () | |
Stores current time as the base for assertTimeCurrent(). | |
stopHookRedirections () | |
Remove all hook overrides. | |
waitForSecond () | |
Wait for a second to roll over, ensures future calls to time() return a different result. | |
Static Public Member Functions | |
static | assertNotTag ($matcher, $actual, $message='', $ishtml=true) |
Note: we are overriding this method to remove the deprecated error. | |
static | assertTag ($matcher, $actual, $message='', $ishtml=true) |
Note: we are overriding this method to remove the deprecated error. | |
static | assertValidKeys (array $hash, array $validKeys) |
Validate list of keys in the associative array. | |
static | findNodes (DOMDocument $dom, array $options, $isHtml=true) |
Parse out the options from the tag using DOM object tree. | |
static | getDataGenerator () |
Get data generator. | |
static | resetAllData ($detectchanges=false) |
Reset all database tables, restore global state and clear caches and optionally purge dataroot dir. | |
static | setAdminUser () |
Set current $USER to admin account, reset access cache. | |
static | setGuestUser () |
Set current $USER to guest account, reset access cache. | |
static | setTimezone ($servertimezone='Australia/Perth', $defaultphptimezone='Australia/Perth') |
Change server and default php timezones. | |
static | setUser ($user=null) |
Set current $USER, reset access cache. | |
Protected Member Functions | |
create_file_content_node_array (string $id, string $name, string $title, ?string $size=null, string $modified='', string $thumbnail='', string $link='', string $exportformat='', ?string $googledoctype=null) | |
Create an array that would replicate the structure of a repository file node array. | |
create_folder_content_node_array (string $id, string $name, string $path, string $modified='') | |
Create an array that would replicate the structure of a repository folder node array. | |
create_google_drive_file_object (string $id, string $name, string $mimetype, ?string $extension=null, ?string $size=null, ?string $modified=null, ?string $webcontentlink=null, ?string $webviewlink=null) | |
Create an object that would replicate the metadata for a file returned by the Google Drive API call. | |
create_google_drive_folder_object (string $id, string $name, ?string $modified=null) | |
Create an object that would replicate the metadata for a folder returned by the Google Drive API call. | |
create_google_drive_shared_drive_object (string $id, string $name) | |
Create an object that would replicate the metadata for a shared drive returned by the Google Drive API call. | |
createArrayDataSet () | |
createCsvDataSet () | |
createXMLDataSet () | |
dataset_from_array (array $data) | |
Creates a new dataset from PHP array. | |
dataset_from_files (array $files) | |
Creates a new dataset from CVS/XML files. | |
dataset_from_string (string $content, string $type, ?string $table=null) | |
Creates a new dataset from string (CSV or XML). | |
loadDataSet () | |
run_all_adhoc_tasks () | |
Run adhoc tasks. | |
runAdhocTasks ($matchclass='', $matchuserid=null) | |
Run adhoc tasks, optionally matching the specified classname. | |
Static Protected Member Functions | |
static | getDescendants (DOMNode $node) |
Recursively get flat array of all descendants of this node. | |
static | getElementsByCaseInsensitiveTagName (DOMDocument $dom, $tag) |
Gets elements by case insensitive tagname. | |
static | getNodeText (DOMNode $node) |
Get the text value of this node's child text node. | |
Protected Attributes | |
array | $disallowedextensions = [] |
The array which contains the disallowed file extensions. | |
|
inherited |
Assert that exactly debugging was just called once.
Discards the debugging message if successful.
null | string | $debugmessage | null means any |
null | string | $debuglevel | null means any |
string | $message |
|
inherited |
Asserts how many times debugging has been called.
int | $expectedcount | The expected number of times |
array | $debugmessages | Expected debugging messages, one for each expected message. |
array | $debuglevels | Expected debugging levels, one for each expected message. |
string | $message |
void |
|
inherited |
Call when no debugging() messages expected.
string | $message |
|
inherited |
Assert that two Date/Time strings are equal.
The strings generated by DateTime, strtotime, date, time, etc. are generated outside of our control. From time-to-time string changes are made. One such example is from ICU 72.1 which changed the time format to include a narrow-non-breaking-space (U+202F) between the time and AM/PM.
We should not update our tests to match these changes, as it is not our code that is generating the strings and they may change again. In addition, the changes are not equal amongst all systems as they depend on the version of ICU installed.
string | $expected | |
string | $actual | |
string | $message |
|
inherited |
Assert that various event methods are not using event->context.
While restoring context might not be valid and it should not be used by event url or description methods.
core\event\base | $event | the event object. |
string | $message |
void |
|
inherited |
Assert that an event legacy data is equal to the expected value.
mixed | $expected | expected data. |
core\event\base | $event | the event object. |
string | $message |
void |
|
inherited |
Assert that an event legacy log data is equal to the expected value.
mixed | $expected | expected data. |
core\event\base | $event | the event object. |
string | $message |
void |
|
staticinherited |
Note: we are overriding this method to remove the deprecated error.
array | $matcher | |
string | $actual | |
string | $message | |
boolean | $ishtml |
|
staticinherited |
Note: we are overriding this method to remove the deprecated error.
array | $matcher | |
string | $actual | |
string | $message | |
boolean | $ishtml |
|
inherited |
|
staticinherited |
Validate list of keys in the associative array.
array | $hash | |
array | $validKeys |
array |
PHPUnit\Framework\Exception |
|
protectedinherited |
Create an array that would replicate the structure of a repository file node array.
string | $id | The ID of the file |
string | $name | The name of the file |
string | $title | The title of the file node |
string | null | $size | The size of the file |
string | $modified | The date of the last modification |
string | $thumbnail | The thumbnail of the file |
string | null | $link | The external link to the file |
string | null | $exportformat | The export format of the file |
string | null | $googledoctype | The type of the Google Doc file (if applicable) |
array | The repository file node array |
|
protectedinherited |
Create an array that would replicate the structure of a repository folder node array.
string | $id | The ID of the folder |
string | $name | The name of the folder |
string | $path | The root path |
string | $modified | The date of the last modification |
array | The repository folder node array |
|
protectedinherited |
Create an object that would replicate the metadata for a file returned by the Google Drive API call.
string | $id | The ID of the file |
string | $name | The name of the file |
string | $mimetype | The mimetype of the file |
string | null | $extension | The extension of the file |
string | null | $size | The size of the file |
string | null | $modified | The date of the last modification |
string | null | $webcontentlink | The link for downloading the content of the file |
string | null | $webviewlink | The link for opening the file in a browser |
stdClass | The file object |
|
protectedinherited |
Create an object that would replicate the metadata for a folder returned by the Google Drive API call.
string | $id | The ID of the folder |
string | $name | The name of the folder |
string | null | $modified | The date of the last modification |
stdClass | The folder object |
|
protectedinherited |
Create an object that would replicate the metadata for a shared drive returned by the Google Drive API call.
string | $id | The ID of the shared drive |
string | $name | The name of the shared drive |
stdClass | The shared drive object |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Creates a new dataset from PHP array.
array | $data | array of tables, see { |
phpunit_dataset |
|
protectedinherited |
Creates a new dataset from CVS/XML files.
This method accepts an array of full paths to CSV or XML files to be loaded into the dataset. For CSV files, the name of the table which the file belongs to needs to be specified. Example:
$fullpaths = [ '/path/to/users.xml', 'course' => '/path/to/courses.csv', ];
array | $files | full paths to CSV or XML files to load. |
phpunit_dataset |
|
protectedinherited |
Creates a new dataset from string (CSV or XML).
string | $content | contents (CSV or XML) to load. |
string | $type | format of the content to be loaded (csv or xml). |
string | $table | name of the table which the file belongs to (only for CSV files). |
phpunit_dataset |
googledocs_content_testcase::filter | ( | array | $content | ) |
Method used for filtering repository file nodes based on the current disallowed file extensions list.
array | $content | The repository content node |
bool | If returns false, the repository content node should be filtered, otherwise do not filter. |
|
staticinherited |
Parse out the options from the tag using DOM object tree.
DOMDocument | $dom | |
array | $options | |
bool | $isHtml |
array |
|
staticinherited |
Get data generator.
testing_data_generator |
|
inherited |
Return debugging messages from the current test.
array | with instances having 'message', 'level' and 'stacktrace' property. |
|
staticprotectedinherited |
Recursively get flat array of all descendants of this node.
DOMNode | $node |
array |
|
staticprotectedinherited |
Gets elements by case insensitive tagname.
DOMDocument | $dom | |
string | $tag |
DOMNodeList |
|
inherited |
Returns UTL of the external test file.
The result depends on the value of following constants:
They should point to standard external test files repository, it defaults to 'http://download.moodle.org/unittest'.
False value means skip tests that require external files.
string | $path | |
bool | $https | true if https required |
string | url |
|
staticprotectedinherited |
Get the text value of this node's child text node.
DOMNode | $node |
string |
|
protectedinherited |
|
inherited |
Call this method from test if you want to make sure that the resetting of database is done the slow way without transaction rollback.
This is useful especially when testing stuff that is not compatible with transactions.
void |
|
inherited |
Recursively visit all the files in the source tree.
Calls the callback function with the pathname of each file found.
string | $path | the folder to start searching from. |
string | $callback | the method of this class to call with the name of each file found. |
string | $fileregexp | a regexp used to filter the search (optional). |
bool | $exclude | If true, pathnames that match the regexp will be ignored. If false, only files that match the regexp will be included. (default false). |
array | $ignorefolders | will not go into any of these folders (optional). |
void |
|
inherited |
Starts email redirection.
You can verify if email were sent or not by inspecting the email array in the returned phpmailer sink instance. The redirection can be stopped by calling $sink->close();
phpunit_message_sink |
|
inherited |
Starts event redirection.
You can verify if events were triggered or not by inspecting the events array in the returned event sink instance. The redirection can be stopped by calling $sink->close();
phpunit_event_sink |
|
inherited |
Override hook callbacks.
string | $hookname | |
callable | $callback |
void |
|
inherited |
Starts message redirection.
You can verify if messages were sent or not by inspecting the messages array in the returned messaging sink instance. The redirection can be stopped by calling $sink->close();
phpunit_message_sink |
|
inherited |
Reset everything after current test.
bool | $reset | true means reset state back, false means keep all data for the next test, null means reset state and show warnings if anything changed |
void |
|
staticinherited |
Reset all database tables, restore global state and clear caches and optionally purge dataroot dir.
bool | $detectchanges | true - changes in global state and database are reported as errors false - no errors reported null - only critical problems are reported as errors |
void |
|
protectedinherited |
Run adhoc tasks, optionally matching the specified classname.
string | $matchclass | The name of the class to match on. |
int | $matchuserid | The userid to match. |
|
finalinherited |
Runs the bare test sequence.
void |
|
staticinherited |
Set current $USER to admin account, reset access cache.
void |
|
inherited |
Stores current time as the base for assertTimeCurrent().
Note: this is called automatically before calling individual test methods.
int | current time |
|
staticinherited |
Set current $USER to guest account, reset access cache.
void |
|
staticinherited |
Change server and default php timezones.
string | $servertimezone | timezone to set in $CFG->timezone (not validated) |
string | $defaultphptimezone | timezone to fake default php timezone (must be valid) |
|
staticinherited |
Set current $USER, reset access cache.
null | int | stdClass | $user | user record, null or 0 means non-logged-in, positive integer means userid |
void |
|
inherited |
Remove all hook overrides.
void |
|
inherited |
Wait for a second to roll over, ensures future calls to time() return a different result.
This is implemented instead of sleep() as we do not need to wait a full second. In some cases due to calls we may wait more than sleep() would have, on average it will be less.