Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250530) (c39b7370636)
basic_testcase Class Reference
Inheritance diagram for basic_testcase:
base_testcase

Public Member Functions

 __construct ($name=null)
 Constructs a test case with the given name.
 
 assertEqualsIgnoringWhitespace ($expected, $actual, string $message='')
 Assert that two Date/Time strings are equal.
 
 getName ()
 Get the name of the test.
 
 isInIsolation ()
 Determine whether the test is running in isolation.
 
 test_teardown ()
 

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 loadHTML (string $actual)
 Load HTML into a DomDocument.
 

Static Protected Member Functions

static get_invokable ()
 Get an invokable object for testing.
 
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 getInvocationCount (InvocationOrder $counter)
 Helper to get the count of invocation.
 
static getNodeText (DOMNode $node)
 Get the text value of this node's child text node.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

basic_testcase::__construct ( $name = null)
final

Constructs a test case with the given name.

Parameters
string$name

Member Function Documentation

◆ assertEqualsIgnoringWhitespace()

base_testcase::assertEqualsIgnoringWhitespace ( $expected,
$actual,
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.

Parameters
string$expected
string$actual
string$message

◆ 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

◆ get_invokable()

static base_testcase::get_invokable ( )
staticprotectedinherited

Get an invokable object for testing.

This is a helper method to create an invokable object for testing which can be used to track invocations, including arguments provided.

This can be useful for modifications to the error handler.

Return values
object

◆ 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

◆ getInvocationCount()

static base_testcase::getInvocationCount ( InvocationOrder $counter)
staticprotectedinherited

Helper to get the count of invocation.

This is required because the method to use changed names in PHPUnit 10.0 in a breaking change.

Parameters
PHPUnit::Framework::MockObject::Rule::InvocationOrder$counter
Return values
int

◆ getName()

basic_testcase::getName ( )
final

Get the name of the test.

Replaces the original PHPUnit method.

Return values
string

◆ 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

◆ isInIsolation()

base_testcase::isInIsolation ( )
inherited

Determine whether the test is running in isolation.

Note: This was previously a public method of the TestCase, but as removed in PHPUnit 10. There is no direct replacement, but we can use reflection to access the protected property.

Return values
bool

◆ loadHTML()

static base_testcase::loadHTML ( string $actual)
staticinherited

Load HTML into a DomDocument.

Note: THis is a replacement for functionality removed from PHPUnit 10.

Parameters
string$actual
Exceptions
PHPUnit::Util::Xml::XmlException
Return values
DOMDocument

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