public function EntityContext::assertCount in Lightning Core 8.4
Same name and namespace in other branches
- 8.5 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::assertCount()
- 8 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::assertCount()
- 8.2 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::assertCount()
- 8.3 tests/contexts/EntityContext.behat.inc \Acquia\LightningExtension\Context\EntityContext::assertCount()
Asserts that entities of a specific type and optional bundle exist.
@Then 1 :entity_type entity should exist @Then 1 :bundle :entity_type entity should exist @Then :n :entity_type entities should exist @Then :n :bundle :entity_type entities should exist
Parameters
string $entity_type: The entity type ID.
int $n: (optional) How many entities are expected to exist.
string $bundle: (optional) The bundle.
Throws
\Behat\Mink\Exception\ExpectationException If the number of existing entities does not match the expected number.
File
- tests/
contexts/ EntityContext.behat.inc, line 190
Class
- EntityContext
- Contains miscellaneous step definitions for working with Drupal entities.
Namespace
Acquia\LightningExtension\ContextCode
public function assertCount($entity_type, $n = 1, $bundle = NULL) {
$count = $this
->count($entity_type, $bundle);
if ($count !== (int) $n) {
$message = sprintf('Expected %s to exist, but there are only %s.', $this
->formatCount($entity_type, $n), $this
->formatCount($entity_type, $count));
throw new ExpectationException($message, $this
->getSession()
->getDriver());
}
}