SerializeQueryTest.php
Same filename and directory in other branches
Namespace
Drupal\KernelTests\Core\DatabaseFile
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SerializeQueryTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\KernelTests\Core\Database;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
/**
* Tests serializing and unserializing a query.
*/
class SerializeQueryTest extends DatabaseTestBase {
/**
* Confirms that a query cannot be serialized.
*/
public function testSerializeQuery() : void {
$query = $this->connection
->select('test');
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Database query objects are not serializable');
serialize($query);
}
/**
* Confirms that a query cannot be unserialized.
*/
public function testUnserializeQuery() : void {
$class = get_class($this->connection
->select('test'));
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Database query objects cannot be unserialized');
unserialize(sprintf('O:%d:"%s":0:{}', strlen($class), $class));
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| SerializeQueryTest | Tests serializing and unserializing a query. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.