You are here

public function BaseFieldMigrationTest::test in Lightning Workflow 8.2

Same name and namespace in other branches
  1. 8.3 modules/lightning_scheduler/tests/src/Functional/BaseFieldMigrationTest.php \Drupal\Tests\lightning_scheduler\Functional\BaseFieldMigrationTest::test()

Overrides MigrationTestBase::test

File

modules/lightning_scheduler/tests/src/Functional/BaseFieldMigrationTest.php, line 15

Class

BaseFieldMigrationTest
@group lightning @group lightning_workflow @group lightning_scheduler

Namespace

Drupal\Tests\lightning_scheduler\Functional

Code

public function test() {
  parent::test();
  $assert = $this
    ->assertSession();
  $assert
    ->pageTextContains('You are about to migrate scheduled transitions for all custom block entities and content items.');
  $assert
    ->elementExists('named', [
    'link',
    'switch to maintenance mode',
  ]);
  $assert
    ->buttonExists('Continue')
    ->press();
  $this
    ->checkForMetaRefresh();
  $assert
    ->pageTextContains('All migrations are completed.');
  $assert
    ->pageTextNotContains('You are about to migrate scheduled transitions');
  $assert
    ->buttonNotExists('Continue');
  $assert
    ->buttonNotExists('Cancel');
  $storage = $this
    ->postMigration('node');

  /** @var NodeInterface $node */
  $node = $storage
    ->load(1);
  $this
    ->assertInstanceOf(NodeInterface::class, $node);
  $this
    ->assertNode($node, '2018-09-19 08:57', 'published');
  $this
    ->assertTrue($node
    ->hasTranslation('fr'));
  $this
    ->assertNode($node
    ->getTranslation('fr'), '2018-09-04 20:15', 'published');

  // Test the default revision, loaded explicitly.
  $node = $storage
    ->loadRevision(5);
  $this
    ->assertInstanceOf(NodeInterface::class, $node);
  $this
    ->assertNode($node, '2018-09-19 08:57', 'published');
  $this
    ->assertTrue($node
    ->hasTranslation('fr'));
  $this
    ->assertNode($node
    ->getTranslation('fr'), '2018-09-04 20:15', 'published');

  // Test previous revisions too.
  $node = $storage
    ->loadRevision(4);
  $this
    ->assertInstanceOf(NodeInterface::class, $node);
  $this
    ->assertNode($node, '2018-09-19 08:57', 'published');
  $this
    ->assertTrue($node
    ->hasTranslation('fr'));
  $this
    ->assertNode($node
    ->getTranslation('fr'), '2018-11-05 02:30', 'published');
  $node = $storage
    ->loadRevision(3);
  $this
    ->assertInstanceOf(NodeInterface::class, $node);
  $this
    ->assertNode($node, '2018-09-19 08:57', 'published');
  $this
    ->assertFalse($node
    ->hasTranslation('fr'));
  $node = $storage
    ->loadRevision(2);
  $this
    ->assertInstanceOf(NodeInterface::class, $node);
  $this
    ->assertNode($node, '2018-09-05 17:00', 'published');
  $this
    ->assertFalse($node
    ->hasTranslation('fr'));
  $node = $storage
    ->loadRevision(1);
  $this
    ->assertInstanceOf(NodeInterface::class, $node);
  $this
    ->assertTrue($node
    ->get('scheduled_transition_date')
    ->isEmpty());
  $this
    ->assertTrue($node
    ->get('scheduled_transition_state')
    ->isEmpty());
  $this
    ->assertFalse($node
    ->hasTranslation('fr'));
}