Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

DML read/read-write database handle use tests

Copyright: 2018 Srdjan Janković, Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 432 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 lib/dml/tests/fixtures/read_slave_moodle_database_table_names.php
 lib/dml/tests/fixtures/read_slave_moodle_database_special.php

Defines 1 class


Class: core_dml_read_slave_testcase  - X-Ref

DML read/read-write database handle use tests

new_db($wantlatency = false,$readonly = [['dbhost' => 'test_ro1', 'dbport' => 1, 'dbuser' => 'test1', 'dbpass' => 'test1'],['dbhost' => 'test_ro2', 'dbport' => 2, 'dbuser' => 'test2', 'dbpass' => 'test2'],['dbhost' => 'test_ro3', 'dbport' => 3, 'dbuser' => 'test3', 'dbpass' => 'test3'],],$dbclass = read_slave_moodle_database::class)   X-Ref
Instantiates a test database interface object.

param: bool $wantlatency
param: mixed $readonly
param: mixed $dbclass
return: read_slave_moodle_database $db

assert_readonly_handle($handle)   X-Ref
Asert that the mock handle returned from read_slave_moodle_database methods
is a readonly slave handle.

param: string $handle
return: void

table_names_provider()   X-Ref
moodle_read_slave_trait::table_names() test data provider

return: array

test_table_names($sql, $tables)   X-Ref
Test moodle_read_slave_trait::table_names() query parser.

param: string $sql
param: array $tables
return: void

test_read_read_write_read()   X-Ref
Test correct database handles are used in a read-read-write-read scenario.
Test lazy creation of the write handle.

return: void

test_read_write_write()   X-Ref
Test correct database handles are used in a read-write-write scenario.

return: void

test_write_read_read()   X-Ref
Test correct database handles are used in a write-read-read scenario.

return: void

test_read_temptable()   X-Ref
Test readonly handle is not used for reading from temptables.

return: void

test_read_excluded_tables()   X-Ref
Test readonly handle is not used for reading from excluded tables.

return: void

test_transaction()   X-Ref
Test readonly handle is not used during transactions.
Test last written time is adjusted post-transaction,
so the latency parameter is applied properly.

return: void

test_read_only_conn_fail()   X-Ref
Test failed readonly connection falls back to write connection.

return: void

test_read_only_conn_first_fail()   X-Ref
In multiple slaves scenario, test failed readonly connection falls back to
another readonly connection.

return: void

with_global_db($test)   X-Ref
Helper to restore global $DB

param: callable $test
return: void

test_lock_db()   X-Ref
Test lock_db table exclusion

return: void

test_sessions()   X-Ref
Test sessions table exclusion

return: void