FieldSchemaDataUninstallUpdateTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Update/FieldSchemaDataUninstallUpdateTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class FieldSchemaDataUninstallUpdateTest extends UpdatePathTestBase {
protected $defaultTheme = 'stark';
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.block-content-uninstall.php',
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php',
];
}
public function testUpdateHookN() {
$this
->assertFieldSchemaData(TRUE, 'Field schema data to be purged found before update.');
$this
->runUpdates();
$this
->assertFieldSchemaData(FALSE, 'No field schema data to be purged found after update.');
}
protected function assertFieldSchemaData($found, $message) {
$query = \Drupal::database()
->select('key_value', 'kv')
->fields('kv');
$query
->condition('kv.collection', 'entity.storage_schema.sql')
->condition('kv.name', 'block_content.field_schema_data.%', 'LIKE');
$items = $query
->execute()
->fetchAll();
return $this
->assertEqual((bool) $items, $found, $message);
}
}