You are here

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

Test rescue.

File

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

Class

EntityUpdateUIFunctionsTest
Test Entity Update UI Functions.

Namespace

Drupal\Tests\entity_update\Functional

Code

public function testEntityUpdateRescueWebExec() {
  $assert = $this
    ->assertSession();
  $path = 'admin/config/development/entity-update/exec/rescue';
  $edit = [];
  $edit['confirm'] = FALSE;
  $this
    ->drupalGet($path);
  $this
    ->drupalPostForm($path, $edit, 'Run Entity Rescue');
  $assert
    ->pageTextContainsOnce('If you want to execute, please check the checkbox.');
  $edit['confirm'] = TRUE;
  $this
    ->drupalPostForm($path, $edit, 'Run Entity Rescue');

  // Nothing to rescue.
  $assert
    ->pageTextContainsOnce('Entity rescue FAIL');

  // Real rescue test.
  EntityUpdateTestHelper::fieldEnable('name');
  EntityUpdateTestHelper::fieldEnable('description');
  EntityUpdate::basicUpdate();
  $data = [
    'id' => 1,
    'name' => 'name',
    'description' => 'description',
  ];
  $entity = EntityUpdateTestsContentEntity::create($data);
  $entity
    ->save();
  EntityUpdateTestHelper::fieldDisable('name');
  $res = EntityUpdate::basicUpdate(TRUE);
  $this
    ->assertTrue($res, 'Entity schema is updated (Uninstall + data).');
  $edit['confirm'] = TRUE;
  $this
    ->drupalPostForm($path, $edit, 'Run Entity Rescue');

  // @TODO : Create a correct test.
}