2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
22 * @copyright 2013 Damyon Wiese
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
30 * Unit tests for our locking configuration.
34 * @copyright 2013 Damyon Wiese
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class lock_config_testcase
extends advanced_testcase
{
40 * Tests the static parse charset method
43 public function test_lock_config() {
46 if (isset($CFG->lock_factory
)) {
47 $original = $CFG->lock_factory
;
50 // Test no configuration.
51 unset($CFG->lock_factory
);
53 $factory = \core\lock\lock_config
::get_lock_factory('cache');
55 $this->assertNotEmpty($factory, 'Get a default factory with no configuration');
57 $CFG->lock_factory
= '\core\lock\file_lock_factory';
59 $factory = \core\lock\lock_config
::get_lock_factory('cache');
60 $this->assertTrue($factory instanceof \core\lock\file_lock_factory
,
61 'Get a default factory with a set configuration');
63 $CFG->lock_factory
= '\core\lock\db_record_lock_factory';
65 $factory = \core\lock\lock_config
::get_lock_factory('cache');
66 $this->assertTrue($factory instanceof \core\lock\db_record_lock_factory
,
67 'Get a default factory with a changed configuration');
70 $CFG->lock_factory
= $original;
72 unset($CFG->lock_factory
);