Skip to content

Commit

Permalink
Fix for serialized test (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdef committed Jan 21, 2023
1 parent a1e96d9 commit 792cbf5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ConnectionTest.php
Expand Up @@ -7,6 +7,7 @@
use PDO;
use Throwable;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
Expand Down Expand Up @@ -115,4 +116,18 @@ static function (ConnectionInterface $db) {

$db->close();
}

public function testSerialized()
{
$connection = $this->getConnection();
$connection->open();
$serialized = serialize($connection);
$this->assertNotNull($connection->getPDO());

$unserialized = unserialize($serialized);
$this->assertInstanceOf(ConnectionPDOInterface::class, $unserialized);
$this->assertNull($unserialized->getPDO());
$this->assertEquals(123, $unserialized->createCommand('SELECT 123 FROM DUAL')->queryScalar());
$this->assertNotNull($connection->getPDO());
}
}

0 comments on commit 792cbf5

Please sign in to comment.