function ContentModerationStateStorageSchemaTest::assertStorageException
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateStorageSchemaTest::assertStorageException()
- 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateStorageSchemaTest::assertStorageException()
- 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateStorageSchemaTest::assertStorageException()
Assert if a storage exception is triggered when saving a given entity.
Parameters
array $values: An array of entity values.
bool $has_exception: If an exception should be triggered when saving the entity.
1 call to ContentModerationStateStorageSchemaTest::assertStorageException()
- ContentModerationStateStorageSchemaTest::testUniqueKeys in core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateStorageSchemaTest.php - Test the ContentModerationState unique keys.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateStorageSchemaTest.php, line 128
Class
- ContentModerationStateStorageSchemaTest
- Test the ContentModerationState storage schema.
Namespace
Drupal\Tests\content_moderation\KernelCode
protected function assertStorageException(array $values, $has_exception) {
$defaults = [
'moderation_state' => 'draft',
'workflow' => 'editorial',
];
$entity = ContentModerationState::create($values + $defaults);
$exception_triggered = FALSE;
try {
ContentModerationState::updateOrCreateFromEntity($entity);
} catch (\Exception $e) {
$exception_triggered = TRUE;
}
$this->assertEquals($has_exception, $exception_triggered);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.