public function EntityContext::trashNewest in Lightning Core 8.4
Same name and namespace in other branches
- 8.5 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::trashNewest()
- 8 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::trashNewest()
- 8.2 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::trashNewest()
- 8.3 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::trashNewest()
Marks recently created entities to be deleted after the test scenario.
@When I delete the latest :entity_type @When I delete the latest :entity_type entity @When I delete the latest :n :entity_type entities
Parameters
string $entity_type: The entity type ID.
int $n: (optional) How many entities to delete.
File
- tests/
contexts/ EntityContext.behat.inc, line 138
Class
- EntityContext
- Contains miscellaneous step definitions for working with Drupal entities.
Namespace
Acquia\LightningExtension\ContextCode
public function trashNewest($entity_type, $n = 1) {
$items = \Drupal::entityTypeManager()
->getStorage($entity_type)
->getQuery()
->sort('created', 'DESC')
->range(0, $n)
->execute();
foreach ($items as $id) {
$this->trash[$entity_type][] = $id;
}
}