MenuTreeSerializationTitleTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Update/MenuTreeSerializationTitleTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Update;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class MenuTreeSerializationTitleTest extends UpdatePathTestBase {
protected $defaultTheme = 'stark';
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
->assertInstanceOf(TranslatableMarkup::class, $title);
if ($description) {
$this
->assertInstanceOf(TranslatableMarkup::class, $description);
}
}
}
}
}