mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Add a failing test for session concurrency problems
This commit is contained in:
parent
3cc3db8380
commit
e86365ca0f
1 changed files with 30 additions and 0 deletions
|
@ -191,4 +191,34 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
$storage->gc();
|
||||
$this->assertFalse($storage->read('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testConcurrentInsert
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConcurrentInsert() {
|
||||
ClassRegistry::removeObject('Session');
|
||||
|
||||
$mockedModel = $this->getMockForModel(
|
||||
'SessionTestModel',
|
||||
array('exists'),
|
||||
array('alias' => 'MockedSessionTestModel', 'table' => 'sessions')
|
||||
);
|
||||
Configure::write('Session.handler.model', 'MockedSessionTestModel');
|
||||
|
||||
$mockedModel->expects($this->any())
|
||||
->method('exists')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->storage = new DatabaseSession();
|
||||
|
||||
$this->storage->write('foo', 'Some value');
|
||||
$return = $this->storage->read('foo');
|
||||
$this->assertSame('Some value', $return);
|
||||
|
||||
$this->storage->write('foo', 'Some other value');
|
||||
$return = $this->storage->read('foo');
|
||||
$this->assertSame('Some other value', $return);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue