mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
MDL-58018 core: finish dev to support open sessions without a lock
This commit is contained in:
parent
82da35fd51
commit
4400ed3e1c
12 changed files with 159 additions and 54 deletions
|
@ -854,4 +854,61 @@ class core_session_manager_testcase extends advanced_testcase {
|
|||
$this->assertCount(1, $SESSION->recentsessionlocks);
|
||||
$this->assertEquals('/good.php?id=4', $SESSION->recentsessionlocks[0]['url']);
|
||||
}
|
||||
|
||||
public function test_array_session_diff_same_array() {
|
||||
$a = [];
|
||||
$a['c'] = new stdClass();
|
||||
$a['c']->o = new stdClass();
|
||||
$a['c']->o->o = new stdClass();
|
||||
$a['c']->o->o->l = 'cool';
|
||||
|
||||
$class = new ReflectionClass('\core\session\manager');
|
||||
$method = $class->getMethod('array_session_diff');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invokeArgs(null, [$a, $a]);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
public function test_array_session_diff_first_array_larger() {
|
||||
$a = [];
|
||||
$a['stdClass'] = new stdClass();
|
||||
$a['stdClass']->attribute = 'This is an attribute';
|
||||
$a['array'] = ['array', 'contents'];
|
||||
|
||||
$b = [];
|
||||
$b['array'] = ['array', 'contents'];
|
||||
|
||||
$class = new ReflectionClass('\core\session\manager');
|
||||
$method = $class->getMethod('array_session_diff');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invokeArgs(null, [$a, $b]);
|
||||
|
||||
$expected = [];
|
||||
$expected['stdClass'] = new stdClass();
|
||||
$expected['stdClass']->attribute = 'This is an attribute';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function test_array_session_diff_second_array_larger() {
|
||||
$a = [];
|
||||
$a['array'] = ['array', 'contents'];
|
||||
|
||||
$b = [];
|
||||
$b['stdClass'] = new stdClass();
|
||||
$b['stdClass']->attribute = 'This is an attribute';
|
||||
$b['array'] = ['array', 'contents'];
|
||||
|
||||
$class = new ReflectionClass('\core\session\manager');
|
||||
$method = $class->getMethod('array_session_diff');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invokeArgs(null, [$a, $b]);
|
||||
|
||||
// It's empty because the first array contains all the contents of the second.
|
||||
$expected = [];
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue