mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-15 05:45:33 +08:00
Implemented __sleep in yii\db\Connection
to support serializing the connection object without exceptions. - Added test for serializing an open connection. - Added unserialize test close #10149
This commit is contained in:
committed by
Carsten Brandt
parent
61acf28338
commit
603a956b8d
@@ -11,6 +11,7 @@ use yii\db\Transaction;
|
||||
*/
|
||||
class ConnectionTest extends DatabaseTestCase
|
||||
{
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
$connection = $this->getConnection(false);
|
||||
@@ -42,6 +43,17 @@ class ConnectionTest extends DatabaseTestCase
|
||||
$connection->open();
|
||||
}
|
||||
|
||||
public function testSerialize()
|
||||
{
|
||||
$connection = $this->getConnection(false, false);
|
||||
$connection->open();
|
||||
$serialized = serialize($connection);
|
||||
$unserialized = unserialize($serialized);
|
||||
$this->assertInstanceOf('yii\db\Connection', $unserialized);
|
||||
|
||||
$this->assertEquals(123, $connection->createCommand("SELECT 123")->queryScalar());
|
||||
}
|
||||
|
||||
public function testGetDriverName()
|
||||
{
|
||||
$connection = $this->getConnection(false, false);
|
||||
|
||||
Reference in New Issue
Block a user