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