public function SchedulerDeleteEntityTest::testDeleteEntityWithPastDates in Scheduler 2.x
Tests the deletion of scheduled entities.
Check that entities can be deleted with no validation errors even if the dates are in the past.
@dataProvider dataStandardEntityTypes()
See also
https://www.drupal.org/project/scheduler/issues/2627370
File
- tests/
src/ Functional/ SchedulerDeleteEntityTest.php, line 72
Class
- SchedulerDeleteEntityTest
- Tests deletion of entities enabled for Scheduler.
Namespace
Drupal\Tests\scheduler\FunctionalCode
public function testDeleteEntityWithPastDates($entityTypeId, $bundle) {
// Log in.
$this
->drupalLogin($this->adminUser);
// Create entities with publish_on and unpublish_on dates in the past.
$published_entity = $this
->createEntity($entityTypeId, $bundle, [
'status' => TRUE,
'unpublish_on' => strtotime('- 2 day'),
]);
$unpublished_entity = $this
->createEntity($entityTypeId, $bundle, [
'status' => FALSE,
'publish_on' => strtotime('- 2 day'),
]);
$entity_type_label = $published_entity
->getEntityType()
->getSingularLabel();
// Attempt to delete the published entity and check for no validation error.
$this
->drupalGet($published_entity
->toUrl('edit-form'));
$this
->clickLink('Delete');
$this
->assertSession()
->pageTextNotContains('Error message');
$this
->assertSession()
->pageTextContains("Are you sure you want to delete the {$entity_type_label} {$published_entity->label()}");
// Attempt to delete the unpublished entity and check no validation error.
$this
->drupalGet($unpublished_entity
->toUrl('edit-form'));
$this
->clickLink('Delete');
$this
->assertSession()
->pageTextNotContains('Error message');
$this
->assertSession()
->pageTextContains("Are you sure you want to delete the {$entity_type_label} {$unpublished_entity->label()}");
}