[Session] Utilize MongoDB::selectCollection()
This commit is contained in:
parent
2447757a4e
commit
20e93bf1a4
@ -137,7 +137,7 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
||||
private function getCollection()
|
||||
{
|
||||
if (null === $this->collection) {
|
||||
$this->collection = $this->mongo->selectDB($this->options['database'])->selectCollection($this->options['collection']);
|
||||
$this->collection = $this->mongo->selectCollection($this->options['database'], $this->options['collection']);
|
||||
}
|
||||
|
||||
return $this->collection;
|
||||
|
@ -58,22 +58,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testWrite()
|
||||
{
|
||||
$database = $this->getMockBuilder('MongoDB')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$collection = $this->getMockBuilder('MongoCollection')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectDB')
|
||||
->with($this->options['database'])
|
||||
->will($this->returnValue($database));
|
||||
|
||||
$database->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['collection'])
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
$that = $this;
|
||||
@ -96,22 +87,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testReplaceSessionData()
|
||||
{
|
||||
$database = $this->getMockBuilder('MongoDB')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$collection = $this->getMockBuilder('MongoCollection')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectDB')
|
||||
->with($this->options['database'])
|
||||
->will($this->returnValue($database));
|
||||
|
||||
$database->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['collection'])
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
$data = array();
|
||||
@ -130,22 +112,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDestroy()
|
||||
{
|
||||
$database = $this->getMockBuilder('MongoDB')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$collection = $this->getMockBuilder('MongoCollection')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectDB')
|
||||
->with($this->options['database'])
|
||||
->will($this->returnValue($database));
|
||||
|
||||
$database->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['collection'])
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
$collection->expects($this->once())
|
||||
@ -160,22 +133,13 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGc()
|
||||
{
|
||||
$database = $this->getMockBuilder('MongoDB')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$collection = $this->getMockBuilder('MongoCollection')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mongo->expects($this->once())
|
||||
->method('selectDB')
|
||||
->with($this->options['database'])
|
||||
->will($this->returnValue($database));
|
||||
|
||||
$database->expects($this->once())
|
||||
->method('selectCollection')
|
||||
->with($this->options['collection'])
|
||||
->with($this->options['database'], $this->options['collection'])
|
||||
->will($this->returnValue($collection));
|
||||
|
||||
$that = $this;
|
||||
|
Reference in New Issue
Block a user