Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
basic_testcase Class Reference

The simplest PHPUnit test case customised for Moodle. More...

Inheritance diagram for basic_testcase:
base_testcase

Public Member Functions

 __construct ($name=null, array $data=array(), $dataName='')
 Constructs a test case with the given name.
 
 runBare ()
 Runs the bare test sequence and log any changes in global state or database.
 

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 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.
 

Detailed Description

The simplest PHPUnit test case customised for Moodle.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

It is intended for isolated tests that do not modify database or any globals.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

basic_testcase::__construct ( $name = null,
array $data = array(),
$dataName = '' )
final

Constructs a test case with the given name.

Note: use setUp() or setUpBeforeClass() in your test cases.

Parameters
string$name
array$data
string$dataName

Member Function Documentation

◆ assertNotTag()

static base_testcase::assertNotTag ( $matcher,
$actual,
$message = '',
$ishtml = true )
staticinherited

Note: we are overriding this method to remove the deprecated error.

See also
https://tracker.moodle.org/browse/MDL-47129
Parameters
array$matcher
string$actual
string$message
boolean$ishtml
Deprecated
3.0

◆ assertTag()

static base_testcase::assertTag ( $matcher,
$actual,
$message = '',
$ishtml = true )
staticinherited

Note: we are overriding this method to remove the deprecated error.

See also
https://tracker.moodle.org/browse/MDL-47129
Parameters
array$matcher
string$actual
string$message
boolean$ishtml
Deprecated
3.0

◆ assertValidKeys()

static base_testcase::assertValidKeys ( array $hash,
array $validKeys )
staticinherited

Validate list of keys in the associative array.

Parameters
array$hash
array$validKeys
Return values
array
Exceptions
PHPUnit\Framework\Exception

◆ findNodes()

static base_testcase::findNodes ( DOMDocument $dom,
array $options,
$isHtml = true )
staticinherited

Parse out the options from the tag using DOM object tree.

Parameters
DOMDocument$dom
array$options
bool$isHtml
Return values
array

◆ getDescendants()

static base_testcase::getDescendants ( DOMNode $node)
staticprotectedinherited

Recursively get flat array of all descendants of this node.

Parameters
DOMNode$node
Return values
array

◆ getElementsByCaseInsensitiveTagName()

static base_testcase::getElementsByCaseInsensitiveTagName ( DOMDocument $dom,
$tag )
staticprotectedinherited

Gets elements by case insensitive tagname.

Parameters
DOMDocument$dom
string$tag
Return values
DOMNodeList

◆ getNodeText()

static base_testcase::getNodeText ( DOMNode $node)
staticprotectedinherited

Get the text value of this node's child text node.

Parameters
DOMNode$node
Return values
string

◆ runBare()

basic_testcase::runBare ( )
final

Runs the bare test sequence and log any changes in global state or database.

Return values
void

The documentation for this class was generated from the following file: