public function ScheduledTransitionModalFormTest::testLatestOptionPreselected in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x tests/src/Functional/ScheduledTransitionModalFormTest.php \Drupal\Tests\scheduled_transitions\Functional\ScheduledTransitionModalFormTest::testLatestOptionPreselected()
Test by default the latest revision radio is prechecked.
File
- tests/
src/ Functional/ ScheduledTransitionModalFormTest.php, line 113
Class
- ScheduledTransitionModalFormTest
- Tests the route to add a new transition to an entity (modal form).
Namespace
Drupal\Tests\scheduled_transitions\FunctionalCode
public function testLatestOptionPreselected() {
$this
->enabledBundles([
[
'st_entity_test',
'st_entity_test',
],
]);
$workflow = $this
->createEditorialWorkflow();
$workflow
->getTypePlugin()
->addEntityTypeAndBundle('st_entity_test', 'st_entity_test');
$workflow
->save();
$currentUser = $this
->drupalCreateUser([
'administer st_entity_test entities',
'use editorial transition create_new_draft',
'use editorial transition publish',
'use editorial transition archive',
Permissions::addScheduledTransitionsPermission('st_entity_test', 'st_entity_test'),
]);
$this
->drupalLogin($currentUser);
// Create another revision so the list has more options than only the
// 'latest' radio.
$entity = ScheduledTransitionsTestEntity::create([
'type' => 'st_entity_test',
]);
$entity
->setNewRevision();
$entity
->save();
$revisionId = $entity
->getRevisionId();
$this
->drupalGet($entity
->toUrl());
// Access the modal directly.
$this
->drupalGet($entity
->toUrl(ScheduledTransitionsRouteProvider::LINK_TEMPLATE_ADD));
// The revision should be listed.
$this
->assertSession()
->checkboxNotChecked('edit-revision-' . $revisionId);
// The latest radio should exist and checked.
$this
->assertSession()
->checkboxChecked('edit-revision-latest-revision');
}