public function MongoDbSessionHandlerTest::testWriteWhenUsingExpiresField in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/http-foundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php \Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\MongoDbSessionHandlerTest::testWriteWhenUsingExpiresField()
File
- vendor/
symfony/ http-foundation/ Tests/ Session/ Storage/ Handler/ MongoDbSessionHandlerTest.php, line 143
Class
- MongoDbSessionHandlerTest
- @author Markus Bachmann <markus.bachmann@bachi.biz>
Namespace
Symfony\Component\HttpFoundation\Tests\Session\Storage\HandlerCode
public function testWriteWhenUsingExpiresField() {
$this->options = array(
'id_field' => '_id',
'data_field' => 'data',
'time_field' => 'time',
'database' => 'sf2-test',
'collection' => 'session-test',
'expiry_field' => 'expiresAt',
);
$this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
$collection = $this
->createMongoCollectionMock();
$this->mongo
->expects($this
->once())
->method('selectCollection')
->with($this->options['database'], $this->options['collection'])
->will($this
->returnValue($collection));
$that = $this;
$data = array();
$collection
->expects($this
->once())
->method('update')
->will($this
->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) {
$that
->assertEquals(array(
$that->options['id_field'] => 'foo',
), $criteria);
$that
->assertEquals(array(
'upsert' => true,
'multiple' => false,
), $options);
$data = $updateData['$set'];
}));
$this
->assertTrue($this->storage
->write('foo', 'bar'));
$this
->assertEquals('bar', $data[$this->options['data_field']]->bin);
$that
->assertInstanceOf('MongoDate', $data[$this->options['time_field']]);
$that
->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]);
}