Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 39 and 311]

Database driver test case.

Copyright: 2012 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 227 lines (8 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

database_driver_testcase:: (10 methods):
  __construct()
  setUpBeforeClass()
  setUp()
  tearDown()
  tearDownAfterClass()
  runBare()
  getDebuggingMessages()
  resetDebugging()
  assertDebuggingCalled()
  assertDebuggingNotCalled()


Class: database_driver_testcase  - X-Ref

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

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

__construct($name = null, array $data = array()   X-Ref
Constructs a test case with the given name.

param: string $name
param: array  $data
param: string $dataName

setUpBeforeClass()   X-Ref
No description

setUp()   X-Ref
No description

tearDown()   X-Ref
No description

tearDownAfterClass()   X-Ref
No description

runBare()   X-Ref
Runs the bare test sequence.

return: void

getDebuggingMessages()   X-Ref
Return debugging messages from the current test.

return: array with instances having 'message', 'level' and 'stacktrace' property.

resetDebugging()   X-Ref
Clear all previous debugging messages in current test.


assertDebuggingCalled($debugmessage = null, $debuglevel = null, $message = '')   X-Ref
Assert that exactly debugging was just called once.

Discards the debugging message if successful.

param: null|string $debugmessage null means any
param: null|string $debuglevel null means any
param: string $message

assertDebuggingNotCalled($message = '')   X-Ref
Call when no debugging() messages expected.

param: string $message