SerializeQueryTest.php 706 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Drupal\KernelTests\Core\Database;
  3. /**
  4. * Tests serializing and unserializing a query.
  5. *
  6. * @group Database
  7. */
  8. class SerializeQueryTest extends DatabaseTestBase {
  9. /**
  10. * Confirms that a query can be serialized and unserialized.
  11. */
  12. public function testSerializeQuery() {
  13. $query = $this->connection->select('test');
  14. $query->addField('test', 'age');
  15. $query->condition('name', 'Ringo');
  16. // If this doesn't work, it will throw an exception, so no need for an
  17. // assertion.
  18. $query = unserialize(serialize($query));
  19. $results = $query->execute()->fetchCol();
  20. $this->assertEqual($results[0], 28, 'Query properly executed after unserialization.');
  21. }
  22. }