You are here

public function LingotekActionsInstalledUpdate8219Test::testUpgrade in Lingotek Translation 8.2

Tests that the upgrade sets the correct field formatter id in a view.

File

tests/src/Functional/Update/LingotekActionsInstalledUpdate8219Test.php, line 43

Class

LingotekActionsInstalledUpdate8219Test
Tests the upgrade path for installing the lingotek actions if required.

Namespace

Drupal\Tests\lingotek\Functional\Update

Code

public function testUpgrade() {
  $notExpectedActions = [
    'node_lingotek_disassociate_action',
  ];
  $expectedActions = [
    'node_lingotek_cancel_action',
    'node_es_lingotek_cancel_translation_action',
    'node_en_lingotek_cancel_translation_action',
    'node_de_lingotek_cancel_translation_action',
  ];
  $actions = Action::loadMultiple();
  $this
    ->assertCount(38, $actions);
  foreach ($expectedActions as $expectedAction) {
    $this
      ->assertArrayNotHasKey($expectedAction, $actions, 'There is not an action with id: ' . $expectedAction);
  }
  foreach ($notExpectedActions as $notExpectedAction) {
    $this
      ->assertArrayHasKey($notExpectedAction, $actions, 'There is an action with id: ' . $notExpectedAction);
  }
  $this
    ->runUpdates();
  $actions = Action::loadMultiple();

  // There should be no new action: 1 for cancel was added, but the
  // action for disassociating was removed.
  // And then then three cancel translation (one per language)
  $this
    ->assertCount(38 + 3, $actions);
  foreach ($expectedActions as $expectedAction) {
    $this
      ->assertArrayHasKey($expectedAction, $actions, 'There is an action with id: ' . $expectedAction);
  }
  foreach ($notExpectedActions as $notExpectedAction) {
    $this
      ->assertArrayNotHasKey($notExpectedAction, $actions, 'There is not an action with id: ' . $notExpectedAction);
  }
}