protected function ContentModerationStateStorageSchemaTest::assertStorageException in Drupal 8
Same name and namespace in other branches
- 9 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);
}