RangeUpdatePathTest.php in Range 8
File
tests/src/Functional/Update/RangeUpdatePathTest.php
View source
<?php
namespace Drupal\Tests\range\Functional\Update;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class RangeUpdatePathTest extends UpdatePathTestBase {
protected function setUp() : void {
parent::setUp();
$definitions = \Drupal::service('entity.last_installed_schema.repository')
->getLastInstalledFieldStorageDefinitions('node');
$definitions['field_decimal'] = FieldStorageConfig::load('node.field_decimal');
$definitions['field_float'] = FieldStorageConfig::load('node.field_float');
$definitions['field_integer'] = FieldStorageConfig::load('node.field_integer');
\Drupal::service('entity.last_installed_schema.repository')
->setLastInstalledFieldStorageDefinitions('node', $definitions);
}
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/drupal-8.range-8100.php',
];
}
public function testUpdateHook8101() {
foreach (EntityViewDisplay::load('node.page.unformatted_formatter')
->getComponents() as $component) {
if (!empty($component['type']) && $component['type'] === 'range_unformatted') {
$this
->assertArrayNotHasKey('range_combine', $component['settings']);
}
}
$this
->runUpdates();
foreach (EntityViewDisplay::load('node.page.unformatted_formatter')
->getComponents() as $component) {
if (!empty($component['type']) && $component['type'] === 'range_unformatted') {
$this
->assertFalse($component['settings']['range_combine']);
}
}
}
public function testNoRegressionsAfterUpdates() {
$this
->runUpdates();
$this
->drupalLogin($this
->drupalCreateUser([
'administer node display',
'administer node form display',
'create page content',
]));
$range_fields = [
'field_decimal',
'field_float',
'field_integer',
];
$this
->drupalGet('node/add/page');
foreach ($range_fields as $field_name) {
$edit = [
$field_name . '[0][from]' => 0,
$field_name . '[0][to]' => 5,
];
$this
->submitForm($edit, 'Save');
}
foreach ($range_fields as $field_name) {
$this
->drupalGet('admin/structure/types/manage/page/fields');
$this
->drupalGet('admin/structure/types/manage/page/fields/node.page.' . $field_name);
$this
->drupalGet('admin/structure/types/manage/page/fields/node.page.' . $field_name);
$this
->drupalGet('admin/structure/types/manage/page/fields/node.page.' . $field_name . '/storage');
}
$view_modes = [
'default_formatter',
'unformatted_formatter',
];
foreach ($view_modes as $view_mode) {
$this
->drupalGet('admin/structure/types/manage/page/display/' . $view_mode);
foreach ($range_fields as $field_name) {
$this
->submitForm([], $field_name . '_settings_edit');
$this
->submitForm([], 'Cancel');
}
}
$form_modes = [
'default',
];
foreach ($form_modes as $form_mode) {
$this
->drupalGet('admin/structure/types/manage/page/form-display/' . $form_mode);
foreach ($range_fields as $field_name) {
$this
->submitForm([], $field_name . '_settings_edit');
$this
->submitForm([], 'Cancel');
}
}
}
}