3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\Core\StringTranslation\TranslatableMarkup;
6 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
9 * Tests system_update_8001().
14 class MenuTreeSerializationTitleTest extends UpdatePathTestBase {
19 protected function setDatabaseDumpFiles() {
20 $this->databaseDumpFiles = [
21 __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
26 * Ensures that the system_update_8001() runs as expected.
28 public function testUpdate() {
31 // Ensure that some fields got dropped.
32 $database = \Drupal::database();
33 $schema = $database->schema();
35 if (!$schema->tableExists('menu_tree')) {
39 $this->assertFalse($schema->fieldExists('menu_tree', 'title_arguments'));
40 $this->assertFalse($schema->fieldExists('menu_tree', 'title_contexts'));
42 // Ensure that all titles and description values can be unserialized.
43 $select = $database->select('menu_tree');
44 $result = $select->fields('menu_tree', ['id', 'title', 'description'])
46 ->fetchAllAssoc('id');
48 // The test coverage relies upon the fact that unserialize() would emit a
49 // warning if the value is not a valid serialized value.
50 foreach ($result as $link) {
51 $title = unserialize($link->title);
52 $description = unserialize($link->description);
53 // Verify that all the links from system module have a been updated with
54 // a TranslatableMarkup as title and description due to the rebuild.
55 if (strpos($link->id, 'system.') === 0) {
56 $this->assertTrue($title instanceof TranslatableMarkup, get_class($title));
58 $this->assertTrue($description instanceof TranslatableMarkup, get_class($description));