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 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

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: 477 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 lib/dml/tests/fixtures/read_slave_moodle_database_special.php
 lib/dml/tests/fixtures/read_slave_moodle_database_table_names.php

Defines 1 class


Class: dml_read_slave_test  - 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_long_update()   X-Ref
Test readonly handle is not used immediately after update
Test last written time is adjusted post-write,
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