MenuTreeSerializationTitleTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Update/MenuTreeSerializationTitleTest.php
View source
<?php
namespace Drupal\system\Tests\Update;
use Drupal\Core\StringTranslation\TranslatableMarkup;
class MenuTreeSerializationTitleTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
];
}
public function testUpdate() {
$this
->runUpdates();
$database = \Drupal::database();
$schema = $database
->schema();
if (!$schema
->tableExists('menu_tree')) {
return;
}
$this
->assertFalse($schema
->fieldExists('menu_tree', 'title_arguments'));
$this
->assertFalse($schema
->fieldExists('menu_tree', 'title_contexts'));
$select = $database
->select('menu_tree');
$result = $select
->fields('menu_tree', [
'id',
'title',
'description',
])
->execute()
->fetchAllAssoc('id');
foreach ($result as $link) {
$title = unserialize($link->title);
$description = unserialize($link->description);
if (strpos($link->id, 'system.') === 0) {
$this
->assertTrue($title instanceof TranslatableMarkup, get_class($title));
if ($description) {
$this
->assertTrue($description instanceof TranslatableMarkup, get_class($description));
}
}
}
}
}