Add a failing test for session concurrency problems

This commit is contained in:
AD7six 2015-01-22 10:59:33 +00:00
parent 3cc3db8380
commit e86365ca0f

View file

@ -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);
}
}