You are here

public function EntityUpdateUIFunctionsTest::testEntityUpdateSelectedWebExec in Entity Update 2.0.x

Run basic tests.

File

tests/src/Functional/EntityUpdateUIFunctionsTest.php, line 107

Class

EntityUpdateUIFunctionsTest
Test Entity Update UI Functions.

Namespace

Drupal\Tests\entity_update\Functional

Code

public function testEntityUpdateSelectedWebExec() {
  $assert = $this
    ->assertSession();

  // Initially, Disable the field 'name' => No need to update.
  EntityUpdateTestHelper::fieldDisable('name');
  EntityUpdateTestHelper::fieldDisable('description');
  EntityUpdateTestHelper::fieldSetType('type', NULL);

  // Check no updates message.
  $this
    ->drupalGet('admin/config/development/entity-update/status');
  $assert
    ->pageTextContainsOnce('All Entities are up to date.');

  // Check no updates message.
  $path = 'admin/config/development/entity-update/exec/type';
  $this
    ->drupalGet($path);
  $assert
    ->pageTextContainsOnce('Nothing to update');

  // One field to install.
  EntityUpdateTestHelper::fieldEnable('name');
  $this
    ->drupalGet('admin/config/development/entity-update/status');
  $assert
    ->pageTextContainsOnce('The Name field needs to be installed.');
  $edit = [];
  $edit['confirm'] = FALSE;
  $edit['entity_type_id'] = 'entity_update_tests_cnt';
  $this
    ->drupalGet($path);
  $assert
    ->elementTextContains('css', '#edit-entity-type-id option[value=entity_update_tests_cnt]', 'entity_update_tests_cnt');
  $this
    ->drupalPostForm($path, $edit, 'Run Type Update');
  $assert
    ->pageTextContainsOnce('If you want to execute, please check the checkbox.');
  $edit['confirm'] = TRUE;
  $this
    ->drupalGet($path);
  $this
    ->drupalPostForm($path, $edit, 'Run Type Update');
  $assert
    ->pageTextContainsOnce('Entity update SUCCESS');

  // One field to install, one field to uninstall (Check error message).
  EntityUpdateTestHelper::fieldDisable('name');
  EntityUpdateTestHelper::fieldEnable('description');
  $this
    ->drupalGet('admin/config/development/entity-update/status');
  $assert
    ->pageTextContainsOnce('The Description field needs to be installed.');
  $assert
    ->pageTextContainsOnce('The Name field needs to be uninstalled.');
  $this
    ->drupalGet($path);
  $this
    ->drupalPostForm($path, $edit, 'Run Type Update');
  $assert
    ->pageTextContainsOnce('Multiple actions detected, cant update if contains data. Use basic method.');
}