merged branch dosten/ticket_7683 (PR #8303)
This PR was squashed before being merged into the master branch (closes #8303).
Discussion
----------
[HttpFoundation] Add accessors methods to session handlers
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #7683
| License | MIT
| Doc PR |
Commits
-------
460c696
[HttpFoundation] Add accessors methods to session handlers
This commit is contained in:
commit
8b3d8c1bae
|
@ -5,6 +5,7 @@ CHANGELOG
|
|||
-----
|
||||
|
||||
* added Request::getEncodings()
|
||||
* added accessors methods to session handlers
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
|
|
@ -106,4 +106,14 @@ class MemcacheSessionHandler implements \SessionHandlerInterface
|
|||
// not required here because memcache will auto expire the records anyhow.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Memcache instance
|
||||
*
|
||||
* @return \Memcache
|
||||
*/
|
||||
protected function getMemcache()
|
||||
{
|
||||
return $this->memcache;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,4 +112,14 @@ class MemcachedSessionHandler implements \SessionHandlerInterface
|
|||
// not required here because memcached will auto expire the records anyhow.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Memcached instance
|
||||
*
|
||||
* @return \Memcached
|
||||
*/
|
||||
protected function getMemcached()
|
||||
{
|
||||
return $this->memcached;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,4 +160,14 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
|||
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Mongo instance
|
||||
*
|
||||
* @return \Mongo
|
||||
*/
|
||||
protected function getMongo()
|
||||
{
|
||||
return $this->mongo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,4 +240,14 @@ class PdoSessionHandler implements \SessionHandlerInterface
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a PDO instance
|
||||
*
|
||||
* @return \PDO
|
||||
*/
|
||||
protected function getConnection()
|
||||
{
|
||||
return $this->pdo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,4 +121,12 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
array(array('expiretime' => 100, 'foo' => 'bar'), false),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
{
|
||||
$method = new \ReflectionMethod($this->storage, 'getMemcache');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\Memcache', $method->invoke($this->storage));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,4 +116,12 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
array(array('expiretime' => 100, 'foo' => 'bar'), false),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
{
|
||||
$method = new \ReflectionMethod($this->storage, 'getMemcached');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\Memcached', $method->invoke($this->storage));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,4 +168,12 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertTrue($this->storage->gc(-1));
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
{
|
||||
$method = new \ReflectionMethod($this->storage, 'getMongo');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\Mongo', $method->invoke($this->storage));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,4 +98,14 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||
$storage->gc(-1);
|
||||
$this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll()));
|
||||
}
|
||||
|
||||
public function testGetConnection()
|
||||
{
|
||||
$storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array());
|
||||
|
||||
$method = new \ReflectionMethod($storage, 'getConnection');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$this->assertInstanceOf('\PDO', $method->invoke($storage));
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue