Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
database_driver_testcase Class Reference

Special test case for testing of DML drivers and DDL layer. More...

Inheritance diagram for database_driver_testcase:
base_testcase

Public Member Functions

 __construct ($name=null, array $data=array(), $dataName='')
 Constructs a test case with the given name.
 
 assertDebuggingCalled ($debugmessage=null, $debuglevel=null, $message='')
 Assert that exactly debugging was just called once.
 
 assertDebuggingNotCalled ($message='')
 Call when no debugging() messages expected.
 
 assertEqualsIgnoringWhitespace ($expected, $actual, string $message='')
 Assert that two Date/Time strings are equal.
 
 getDebuggingMessages ()
 Return debugging messages from the current test.
 
 resetDebugging ()
 Clear all previous debugging messages in current test.
 
 runBare ()
 Runs the bare test sequence.
 

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 setUpBeforeClass ()
 
static tearDownAfterClass ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

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

moodle_database $tdb
 used in these tests
 

Detailed Description

Special test case for testing of DML drivers and DDL layer.

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

Note: Use only 'test_table*' names when creating new tables.

For DML/DDL developers: you can add following settings to config.php if you want to test different driver than the main one, the reason is to allow testing of incomplete drivers that do not allow full PHPUnit environment initialisation (the database can be empty). $CFG->phpunit_extra_drivers = array( 1=>array('dbtype'=>'mysqli', 'dbhost'=>'localhost', 'dbname'=>'moodle', 'dbuser'=>'root', 'dbpass'=>'', 'prefix'=>'phpu2_'), 2=>array('dbtype'=>'pgsql', 'dbhost'=>'localhost', 'dbname'=>'moodle', 'dbuser'=>'postgres', 'dbpass'=>'', 'prefix'=>'phpu2_'), 3=>array('dbtype'=>'sqlsrv', 'dbhost'=>'127.0.0.1', 'dbname'=>'moodle', 'dbuser'=>'sa', 'dbpass'=>'', 'prefix'=>'phpu2_'), 4=>array('dbtype'=>'oci', 'dbhost'=>'127.0.0.1', 'dbname'=>'XE', 'dbuser'=>'sa', 'dbpass'=>'', 'prefix'=>'t_'), ); define('PHPUNIT_TEST_DRIVER')=1; //number is index in the previous array

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructs a test case with the given name.

Parameters
string$name
array$data
string$dataName

Member Function Documentation

◆ assertDebuggingCalled()

database_driver_testcase::assertDebuggingCalled ( $debugmessage = null,
$debuglevel = null,
$message = '' )

Assert that exactly debugging was just called once.

Discards the debugging message if successful.

Parameters
null | string$debugmessagenull means any
null | string$debuglevelnull means any
string$message

◆ assertDebuggingNotCalled()

database_driver_testcase::assertDebuggingNotCalled ( $message = '')

Call when no debugging() messages expected.

Parameters
string$message

◆ 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

◆ getDebuggingMessages()

database_driver_testcase::getDebuggingMessages ( )

Return debugging messages from the current test.

Return values
arraywith instances having 'message', 'level' and 'stacktrace' property.

◆ 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()

database_driver_testcase::runBare ( )

Runs the bare test sequence.

Return values
void

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