Skip to content

Commit

Permalink
Add a failing test for session concurrency problems
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Jan 22, 2015
1 parent 3cc3db8 commit e86365c
Showing 1 changed file with 30 additions and 0 deletions.
Expand Up @@ -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.