Permalink
Browse files

Add a failing test for session concurrency problems

  • Loading branch information...
AD7six committed Jan 22, 2015
1 parent 3cc3db8 commit e86365ca0ffba680d5aefce6098baa35752b9681
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php
@@ -191,4 +191,34 @@ public function testGc() {
$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);
}
}

0 comments on commit e86365c

Please sign in to comment.