public function BaseFieldMigrationTest::test in Lightning Workflow 8.3
Same name and namespace in other branches
- 8.2 modules/lightning_scheduler/tests/src/Functional/BaseFieldMigrationTest.php \Drupal\Tests\lightning_scheduler\Functional\BaseFieldMigrationTest::test()
Runs a basic test of migrating old Lightning Scheduler data.
This doesn't really test that data integrity is preserved, so subclasses should override this method and call it before asserting other things.
Overrides MigrationTestBase::test
File
- modules/
lightning_scheduler/ tests/ src/ Functional/ BaseFieldMigrationTest.php, line 14
Class
- BaseFieldMigrationTest
- @group lightning_workflow @group lightning_scheduler
Namespace
Drupal\Tests\lightning_scheduler\FunctionalCode
public function test() {
parent::test();
$assert = $this
->assertSession();
$assert
->pageTextContains('You are about to migrate scheduled transitions for all custom blocks 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');
// This is disabled because it fails on a SQLite backend. For reasons I'm
// too busy to look into, revision 4 is loaded as the default revision,
// rather than revision 5. I suspect this is because system_update_8501(),
// which runs before lightning_scheduler_update_8001(), installs the
// revision_default base field and sets its value to 1 for all existing
// revisions. I could be wrong, but I believe this has the effect of marking
// all revisions as being the "default" revision. So which one will be
// loaded as the "default" revision appears to be a toss-up. On a MySQL
// backend, it loaded revision 5. On SQLite, it loads revision 4. Rather
// than find an elaborate workaround, I'm just disabling this part of the
// test for now and testing the actual revisions, one at a time.
/** @var \Drupal\node\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'));
}