Unverified Commit e82e0c05 authored by alexpott's avatar alexpott

Issue #3059090 by clepson, mondrake, alexpott: Deprecate...

Issue #3059090 by clepson, mondrake, alexpott: Deprecate \Drupal\Tests\PhpunitCompatibilityTrait::setExpectedException()
parent 6d3ac6c7
...@@ -33,7 +33,7 @@ public function testNonHtmlResponse($response_class) { ...@@ -33,7 +33,7 @@ public function testNonHtmlResponse($response_class) {
$big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($this->prophesize(AttachmentsResponseProcessorInterface::class)); $big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($this->prophesize(AttachmentsResponseProcessorInterface::class));
$non_html_response = new $response_class(); $non_html_response = new $response_class();
$this->setExpectedException(\AssertionError::class); $this->expectException(\AssertionError::class);
$big_pipe_response_attachments_processor->processAttachments($non_html_response); $big_pipe_response_attachments_processor->processAttachments($non_html_response);
} }
......
...@@ -95,7 +95,8 @@ public function testTransformException() { ...@@ -95,7 +95,8 @@ public function testTransformException() {
->method('getSourceProperty') ->method('getSourceProperty')
->willReturnMap([['bid', 99], ['module', 'foobar']]); ->willReturnMap([['bid', 99], ['module', 'foobar']]);
$this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal()); $this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal());
$this->setExpectedException(MigrateSkipRowException::class, "The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration."); $this->expectException(MigrateSkipRowException::class);
$this->expectExceptionMessage("The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration.");
$this->plugin->transform([2, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty'); $this->plugin->transform([2, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty');
} }
......
...@@ -116,7 +116,8 @@ protected function getExpectedUnauthorizedAccessMessage($method) { ...@@ -116,7 +116,8 @@ protected function getExpectedUnauthorizedAccessMessage($method) {
*/ */
public function testGet() { public function testGet() {
// Contact Message entities are not stored, so they cannot be retrieved. // Contact Message entities are not stored, so they cannot be retrieved.
$this->setExpectedException(RouteNotFoundException::class, 'Route "rest.entity.contact_message.GET" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "rest.entity.contact_message.GET" does not exist.');
$this->provisionEntityResource(); $this->provisionEntityResource();
Url::fromRoute('rest.entity.contact_message.GET')->toString(TRUE); Url::fromRoute('rest.entity.contact_message.GET')->toString(TRUE);
...@@ -127,7 +128,8 @@ public function testGet() { ...@@ -127,7 +128,8 @@ public function testGet() {
*/ */
public function testPatch() { public function testPatch() {
// Contact Message entities are not stored, so they cannot be modified. // Contact Message entities are not stored, so they cannot be modified.
$this->setExpectedException(RouteNotFoundException::class, 'Route "rest.entity.contact_message.PATCH" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "rest.entity.contact_message.PATCH" does not exist.');
$this->provisionEntityResource(); $this->provisionEntityResource();
Url::fromRoute('rest.entity.contact_message.PATCH')->toString(TRUE); Url::fromRoute('rest.entity.contact_message.PATCH')->toString(TRUE);
...@@ -138,7 +140,8 @@ public function testPatch() { ...@@ -138,7 +140,8 @@ public function testPatch() {
*/ */
public function testDelete() { public function testDelete() {
// Contact Message entities are not stored, so they cannot be deleted. // Contact Message entities are not stored, so they cannot be deleted.
$this->setExpectedException(RouteNotFoundException::class, 'Route "rest.entity.contact_message.DELETE" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "rest.entity.contact_message.DELETE" does not exist.');
$this->provisionEntityResource(); $this->provisionEntityResource();
Url::fromRoute('rest.entity.contact_message.DELETE')->toString(TRUE); Url::fromRoute('rest.entity.contact_message.DELETE')->toString(TRUE);
......
...@@ -120,7 +120,8 @@ public function testInvalidRecipient() { ...@@ -120,7 +120,8 @@ public function testInvalidRecipient() {
$sender->expects($this->once()) $sender->expects($this->once())
->method('isAnonymous') ->method('isAnonymous')
->willReturn(FALSE); ->willReturn(FALSE);
$this->setExpectedException(MailHandlerException::class, 'Unable to determine message recipient'); $this->expectException(MailHandlerException::class);
$this->expectExceptionMessage('Unable to determine message recipient');
$this->contactMailHandler->sendMailMessages($message, $sender); $this->contactMailHandler->sendMailMessages($message, $sender);
} }
......
...@@ -21,7 +21,8 @@ class ContentModerationStateResourceTest extends KernelTestBase { ...@@ -21,7 +21,8 @@ class ContentModerationStateResourceTest extends KernelTestBase {
* @see \Drupal\content_moderation\Entity\ContentModerationState * @see \Drupal\content_moderation\Entity\ContentModerationState
*/ */
public function testCreateContentModerationStateResource() { public function testCreateContentModerationStateResource() {
$this->setExpectedException(PluginNotFoundException::class, 'The "entity:content_moderation_state" plugin does not exist.'); $this->expectException(PluginNotFoundException::class);
$this->expectExceptionMessage('The "entity:content_moderation_state" plugin does not exist.');
RestResourceConfig::create([ RestResourceConfig::create([
'id' => 'entity.content_moderation_state', 'id' => 'entity.content_moderation_state',
'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY, 'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY,
......
...@@ -147,7 +147,7 @@ public function testBasicModeration($entity_type_id) { ...@@ -147,7 +147,7 @@ public function testBasicModeration($entity_type_id) {
} }
// Set an invalid moderation state. // Set an invalid moderation state.
$this->setExpectedException(EntityStorageException::class); $this->expectException(EntityStorageException::class);
$entity->moderation_state->value = 'foobar'; $entity->moderation_state->value = 'foobar';
$entity->save(); $entity->save();
} }
......
...@@ -101,7 +101,7 @@ public function testGetValue() { ...@@ -101,7 +101,7 @@ public function testGetValue() {
*/ */
public function testGet() { public function testGet() {
$this->assertEquals('draft', $this->testNode->moderation_state->get(0)->value); $this->assertEquals('draft', $this->testNode->moderation_state->get(0)->value);
$this->setExpectedException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->testNode->moderation_state->get(2); $this->testNode->moderation_state->get(2);
} }
......
...@@ -255,7 +255,7 @@ public function testSetValueProperty() { ...@@ -255,7 +255,7 @@ public function testSetValueProperty() {
* @dataProvider datetimeValidationProvider * @dataProvider datetimeValidationProvider
*/ */
public function testDatetimeValidation($value) { public function testDatetimeValidation($value) {
$this->setExpectedException(\PHPUnit_Framework_AssertionFailedError::class); $this->expectException(\PHPUnit_Framework_AssertionFailedError::class);
$this->fieldStorage->setSetting('datetime_type', DateTimeItem::DATETIME_TYPE_DATETIME); $this->fieldStorage->setSetting('datetime_type', DateTimeItem::DATETIME_TYPE_DATETIME);
$this->fieldStorage->save(); $this->fieldStorage->save();
...@@ -315,7 +315,7 @@ public function datetimeValidationProvider() { ...@@ -315,7 +315,7 @@ public function datetimeValidationProvider() {
* @dataProvider dateonlyValidationProvider * @dataProvider dateonlyValidationProvider
*/ */
public function testDateonlyValidation($value) { public function testDateonlyValidation($value) {
$this->setExpectedException(\PHPUnit_Framework_AssertionFailedError::class); $this->expectException(\PHPUnit_Framework_AssertionFailedError::class);
$this->fieldStorage->setSetting('datetime_type', DateTimeItem::DATETIME_TYPE_DATE); $this->fieldStorage->setSetting('datetime_type', DateTimeItem::DATETIME_TYPE_DATE);
$this->fieldStorage->save(); $this->fieldStorage->save();
......
...@@ -18,7 +18,8 @@ public function testUnknownDateType($method = 'defineValueProcessPipeline') { ...@@ -18,7 +18,8 @@ public function testUnknownDateType($method = 'defineValueProcessPipeline') {
$migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); $migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal();
$plugin = new DateField([], '', []); $plugin = new DateField([], '', []);
$this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); $this->expectException(MigrateException::class);
$this->expectExceptionMessage("Field field_date of type 'timestamp' is an unknown date field type.");
$plugin->$method($migration, 'field_date', ['type' => 'timestamp']); $plugin->$method($migration, 'field_date', ['type' => 'timestamp']);
} }
......
...@@ -35,7 +35,8 @@ protected function setUp() { ...@@ -35,7 +35,8 @@ protected function setUp() {
public function testUnknownDateType($method = 'defineValueProcessPipeline') { public function testUnknownDateType($method = 'defineValueProcessPipeline') {
$plugin = new DateField([], '', []); $plugin = new DateField([], '', []);
$this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); $this->expectException(MigrateException::class);
$this->expectExceptionMessage("Field field_date of type 'timestamp' is an unknown date field type.");
$plugin->$method($this->migration, 'field_date', ['type' => 'timestamp']); $plugin->$method($this->migration, 'field_date', ['type' => 'timestamp']);
} }
......
...@@ -207,7 +207,8 @@ public function testCalculateDependenciesIncorrectBundle() { ...@@ -207,7 +207,8 @@ public function testCalculateDependenciesIncorrectBundle() {
'bundle' => 'test_bundle_not_exists', 'bundle' => 'test_bundle_not_exists',
'field_type' => 'test_field', 'field_type' => 'test_field',
], $this->entityTypeId); ], $this->entityTypeId);
$this->setExpectedException(\LogicException::class, 'Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.');
$field->calculateDependencies(); $field->calculateDependencies();
} }
......
...@@ -192,7 +192,8 @@ public function testInvalidEnforcedCardinality($enforced_cardinality) { ...@@ -192,7 +192,8 @@ public function testInvalidEnforcedCardinality($enforced_cardinality) {
'module' => 'test_module', 'module' => 'test_module',
]); ]);
$this->setExpectedException(FieldException::class, "Invalid enforced cardinality '$enforced_cardinality'. Allowed values: a positive integer or -1."); $this->expectException(FieldException::class);
$this->expectExceptionMessage("Invalid enforced cardinality '$enforced_cardinality'. Allowed values: a positive integer or -1.");
$field_storage->getCardinality(); $field_storage->getCardinality();
} }
......
...@@ -63,7 +63,8 @@ public function testTransform($method, $value, $expected_value, $migrate_excepti ...@@ -63,7 +63,8 @@ public function testTransform($method, $value, $expected_value, $migrate_excepti
$this->plugin = new ProcessField(['method' => $method], $value, [], $this->cckFieldManager->reveal(), $this->fieldManager->reveal(), $this->migration->reveal()); $this->plugin = new ProcessField(['method' => $method], $value, [], $this->cckFieldManager->reveal(), $this->fieldManager->reveal(), $this->migration->reveal());
if ($migrate_exception) { if ($migrate_exception) {
$this->setExpectedException(MigrateException::class, $migrate_exception); $this->expectException(MigrateException::class);
$this->expectExceptionMessage($migrate_exception);
} }
if ($plugin_not_found) { if ($plugin_not_found) {
......
...@@ -47,8 +47,8 @@ public function testDefaults() { ...@@ -47,8 +47,8 @@ public function testDefaults() {
* @covers ::transform * @covers ::transform
*/ */
public function testDefaultsException() { public function testDefaultsException() {
$this->setExpectedException(MigrateException::class, $this->expectException(MigrateException::class);
sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE))); $this->expectExceptionMessage(sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE)));
$this->plugin->transform([], $this->migrateExecutable, $this->row, 'property'); $this->plugin->transform([], $this->migrateExecutable, $this->row, 'property');
} }
......
...@@ -86,7 +86,7 @@ public function testTypeHandlingWithInvalidType() { ...@@ -86,7 +86,7 @@ public function testTypeHandlingWithInvalidType() {
], ],
]; ];
$this->setExpectedException(UnexpectedValueException::class); $this->expectException(UnexpectedValueException::class);
$this->serializer->denormalize($data_with_invalid_type, $this->entityClass, $this->format); $this->serializer->denormalize($data_with_invalid_type, $this->entityClass, $this->format);
} }
...@@ -100,7 +100,7 @@ public function testTypeHandlingWithNoTypes() { ...@@ -100,7 +100,7 @@ public function testTypeHandlingWithNoTypes() {
], ],
]; ];
$this->setExpectedException(UnexpectedValueException::class); $this->expectException(UnexpectedValueException::class);
$this->serializer->denormalize($data_with_no_types, $this->entityClass, $this->format); $this->serializer->denormalize($data_with_no_types, $this->entityClass, $this->format);
} }
...@@ -146,7 +146,8 @@ public function testMarkFieldForDeletion() { ...@@ -146,7 +146,8 @@ public function testMarkFieldForDeletion() {
public function testDenormalizeSerializedItem() { public function testDenormalizeSerializedItem() {
$entity = EntitySerializedField::create(['serialized' => 'boo']); $entity = EntitySerializedField::create(['serialized' => 'boo']);
$normalized = $this->serializer->normalize($entity, $this->format); $normalized = $this->serializer->normalize($entity, $this->format);
$this->setExpectedException(\LogicException::class, 'The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized" field (field item class: Drupal\entity_test\Plugin\Field\FieldType\SerializedItem).'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized" field (field item class: Drupal\entity_test\Plugin\Field\FieldType\SerializedItem).');
$this->serializer->denormalize($normalized, EntitySerializedField::class, $this->format); $this->serializer->denormalize($normalized, EntitySerializedField::class, $this->format);
} }
...@@ -159,7 +160,8 @@ public function testDenormalizeInvalidCustomSerializedField() { ...@@ -159,7 +160,8 @@ public function testDenormalizeInvalidCustomSerializedField() {
$this->assertEquals($normalized['serialized_long'][0]['value'], ['Hello world!']); $this->assertEquals($normalized['serialized_long'][0]['value'], ['Hello world!']);
$normalized['serialized_long'][0]['value'] = 'boo'; $normalized['serialized_long'][0]['value'] = 'boo';
$this->setExpectedException(\LogicException::class, 'The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized_long" field (field item class: Drupal\Core\Field\Plugin\Field\FieldType\StringLongItem).'); $this->expectException(\LogicException::class);
$this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized_long" field (field item class: Drupal\Core\Field\Plugin\Field\FieldType\StringLongItem).');
$this->serializer->denormalize($normalized, EntitySerializedField::class); $this->serializer->denormalize($normalized, EntitySerializedField::class);
} }
......
...@@ -23,7 +23,7 @@ public function testFieldItemNormalizerDenormalizeExceptions($context) { ...@@ -23,7 +23,7 @@ public function testFieldItemNormalizerDenormalizeExceptions($context) {
$field_item_normalizer = new FieldItemNormalizer(); $field_item_normalizer = new FieldItemNormalizer();
$data = []; $data = [];
$class = []; $class = [];
$this->setExpectedException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
$field_item_normalizer->denormalize($data, $class, NULL, $context); $field_item_normalizer->denormalize($data, $class, NULL, $context);
} }
......
...@@ -23,7 +23,7 @@ public function testFieldNormalizerDenormalizeExceptions($context) { ...@@ -23,7 +23,7 @@ public function testFieldNormalizerDenormalizeExceptions($context) {
$field_item_normalizer = new FieldNormalizer(); $field_item_normalizer = new FieldNormalizer();
$data = []; $data = [];
$class = []; $class = [];
$this->setExpectedException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
$field_item_normalizer->denormalize($data, $class, NULL, $context); $field_item_normalizer->denormalize($data, $class, NULL, $context);
} }
......
...@@ -115,7 +115,8 @@ protected function getExpectedUnauthorizedAccessMessage($method) { ...@@ -115,7 +115,8 @@ protected function getExpectedUnauthorizedAccessMessage($method) {
*/ */
public function testGetIndividual() { public function testGetIndividual() {
// Contact Message entities are not stored, so they cannot be retrieved. // Contact Message entities are not stored, so they cannot be retrieved.
$this->setExpectedException(RouteNotFoundException::class, 'Route "jsonapi.contact_message--camelids.individual" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.individual" does not exist.');
Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE); Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE);
} }
...@@ -125,7 +126,8 @@ public function testGetIndividual() { ...@@ -125,7 +126,8 @@ public function testGetIndividual() {
*/ */
public function testPatchIndividual() { public function testPatchIndividual() {
// Contact Message entities are not stored, so they cannot be modified. // Contact Message entities are not stored, so they cannot be modified.
$this->setExpectedException(RouteNotFoundException::class, 'Route "jsonapi.contact_message--camelids.individual" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.individual" does not exist.');
Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE); Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE);
} }
...@@ -135,7 +137,8 @@ public function testPatchIndividual() { ...@@ -135,7 +137,8 @@ public function testPatchIndividual() {
*/ */
public function testDeleteIndividual() { public function testDeleteIndividual() {
// Contact Message entities are not stored, so they cannot be deleted. // Contact Message entities are not stored, so they cannot be deleted.
$this->setExpectedException(RouteNotFoundException::class, 'Route "jsonapi.contact_message--camelids.individual" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.individual" does not exist.');
Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE); Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE);
} }
...@@ -145,7 +148,8 @@ public function testDeleteIndividual() { ...@@ -145,7 +148,8 @@ public function testDeleteIndividual() {
*/ */
public function testRelated() { public function testRelated() {
// Contact Message entities are not stored, so they cannot be retrieved. // Contact Message entities are not stored, so they cannot be retrieved.
$this->setExpectedException(RouteNotFoundException::class, 'Route "jsonapi.contact_message--camelids.related" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.related" does not exist.');
Url::fromRoute('jsonapi.contact_message--camelids.related')->toString(TRUE); Url::fromRoute('jsonapi.contact_message--camelids.related')->toString(TRUE);
} }
...@@ -155,7 +159,8 @@ public function testRelated() { ...@@ -155,7 +159,8 @@ public function testRelated() {
*/ */
public function testRelationships() { public function testRelationships() {
// Contact Message entities are not stored, so they cannot be retrieved. // Contact Message entities are not stored, so they cannot be retrieved.
$this->setExpectedException(RouteNotFoundException::class, 'Route "jsonapi.contact_message--camelids.relationship.get" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.relationship.get" does not exist.');
Url::fromRoute('jsonapi.contact_message--camelids.relationship.get')->toString(TRUE); Url::fromRoute('jsonapi.contact_message--camelids.relationship.get')->toString(TRUE);
} }
...@@ -181,7 +186,8 @@ public function testCollection() { ...@@ -181,7 +186,8 @@ public function testCollection() {
*/ */
public function testRevisions() { public function testRevisions() {
// Contact Message entities are not stored, so they cannot be retrieved. // Contact Message entities are not stored, so they cannot be retrieved.
$this->setExpectedException(RouteNotFoundException::class, 'Route "jsonapi.contact_message--camelids.individual" does not exist.'); $this->expectException(RouteNotFoundException::class);
$this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.individual" does not exist.');
Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE); Url::fromRoute('jsonapi.contact_message--camelids.individual')->toString(TRUE);
} }
......
...@@ -126,7 +126,10 @@ public function resolveInternalIncludePathProvider() { ...@@ -126,7 +126,10 @@ public function resolveInternalIncludePathProvider() {
*/ */
public function testResolveInternalIncludePathError($entity_type, $bundle, $external_path, $expected_message = '') { public function testResolveInternalIncludePathError($entity_type, $bundle, $external_path, $expected_message = '') {
$path_parts = explode('.', $external_path); $path_parts = explode('.', $external_path);
$this->setExpectedException(CacheableBadRequestHttpException::class, $expected_message); $this->expectException(CacheableBadRequestHttpException::class);
if (!empty($expected_message)) {
$this->expectExceptionMessage($expected_message);
}
$resource_type = $this->resourceTypeRepository->get($entity_type, $bundle); $resource_type = $this->resourceTypeRepository->get($entity_type, $bundle);
$this->sut->resolveInternalIncludePath($resource_type, $path_parts); $this->sut->resolveInternalIncludePath($resource_type, $path_parts);
} }
...@@ -245,7 +248,10 @@ public function resolveInternalEntityQueryPathProvider() { ...@@ -245,7 +248,10 @@ public function resolveInternalEntityQueryPathProvider() {
* @dataProvider resolveInternalEntityQueryPathErrorProvider * @dataProvider resolveInternalEntityQueryPathErrorProvider
*/ */
public function testResolveInternalEntityQueryPathError($entity_type, $bundle, $external_path, $expected_message = '') { public function testResolveInternalEntityQueryPathError($entity_type, $bundle, $external_path, $expected_message = '') {
$this->setExpectedException(CacheableBadRequestHttpException::class, $expected_message); $this->expectException(CacheableBadRequestHttpException::class);
if (!empty($expected_message)) {
$this->expectExceptionMessage($expected_message);
}
$this->sut->resolveInternalEntityQueryPath($entity_type, $bundle, $external_path); $this->sut->resolveInternalEntityQueryPath($entity_type, $bundle, $external_path);
} }
......
...@@ -205,7 +205,7 @@ public function testGetIndividualDenied() { ...@@ -205,7 +205,7 @@ public function testGetIndividualDenied() {
$role = Role::load(RoleInterface::ANONYMOUS_ID); $role = Role::load(RoleInterface::ANONYMOUS_ID);
$role->revokePermission('access content'); $role->revokePermission('access content');
$role->save(); $role->save();
$this->setExpectedException(EntityAccessDeniedHttpException::class); $this->expectException(EntityAccessDeniedHttpException::class);
$this->entityResource->getIndividual($this->node, Request::create('/jsonapi/node/article')); $this->entityResource->getIndividual($this->node, Request::create('/jsonapi/node/article'));
} }
...@@ -420,7 +420,8 @@ public function testCreateIndividualWithMissingRequiredData() { ...@@ -420,7 +420,8 @@ public function testCreateIndividualWithMissingRequiredData() {
Role::load(Role::ANONYMOUS_ID) Role::load(Role::ANONYMOUS_ID)
->grantPermission('create article content') ->grantPermission('create article content')
->save(); ->save();
$this->setExpectedException(HttpException::class, 'Unprocessable Entity: validation failed.'); $this->expectException(HttpException::class);
$this->expectExceptionMessage('Unprocessable Entity: validation failed.');
$resource_type = new ResourceType('node', 'article', Node::class); $resource_type = new ResourceType('node', 'article', Node::class);
$payload = Json::encode([ $payload = Json::encode([
'data' => [ 'data' => [
...@@ -455,7 +456,8 @@ public function testCreateIndividualDuplicateError() { ...@@ -455,7 +456,8 @@ public function testCreateIndividualDuplicateError() {
], ],
]); ]);
$this->setExpectedException(ConflictHttpException::class, 'Conflict: Entity already exists.'); $this->expectException(ConflictHttpException::class);
$this->expectExceptionMessage('Conflict: Entity already exists.');
$resource_type = new ResourceType('node', 'article', Node::class); $resource_type = new ResourceType('node', 'article', Node::class);
$resource_type->setRelatableResourceTypes([ $resource_type->setRelatableResourceTypes([
'field_relationships' => [new ResourceType('node', 'article', NULL)], 'field_relationships' => [new ResourceType('node', 'article', NULL)],
......
...@@ -74,7 +74,8 @@ public function setUp() { ...@@ -74,7 +74,8 @@ public function setUp() {
* @covers ::queryCondition * @covers ::queryCondition
*/ */
public function testInvalidFilterPathDueToMissingPropertyName() { public function testInvalidFilterPathDueToMissingPropertyName() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'Invalid nested filtering. The field `colors`, given in the path `colors` is incomplete, it must end with one of the following specifiers: `value`, `format`, `processed`.'); $this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('Invalid nested filtering. The field `colors`, given in the path `colors` is incomplete, it must end with one of the following specifiers: `value`, `format`, `processed`.');
$resource_type = new ResourceType('node', 'painting', NULL); $resource_type = new ResourceType('node', 'painting', NULL);
Filter::createFromQueryParameter(['colors' => ''], $resource_type, $this->fieldResolver); Filter::createFromQueryParameter(['colors' => ''], $resource_type, $this->fieldResolver);
} }
...@@ -83,7 +84,8 @@ public function testInvalidFilterPathDueToMissingPropertyName() { ...@@ -83,7 +84,8 @@ public function testInvalidFilterPathDueToMissingPropertyName() {
* @covers ::queryCondition * @covers ::queryCondition
*/ */
public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithMetaProperties() { public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithMetaProperties() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'Invalid nested filtering. The field `photo`, given in the path `photo` is incomplete, it must end with one of the following specifiers: `id`, `meta.alt`, `meta.title`, `meta.width`, `meta.height`.'); $this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('Invalid nested filtering. The field `photo`, given in the path `photo` is incomplete, it must end with one of the following specifiers: `id`, `meta.alt`, `meta.title`, `meta.width`, `meta.height`.');
$resource_type = new ResourceType('node', 'painting', NULL); $resource_type = new ResourceType('node', 'painting', NULL);
Filter::createFromQueryParameter(['photo' => ''], $resource_type, $this->fieldResolver); Filter::createFromQueryParameter(['photo' => ''], $resource_type, $this->fieldResolver);
} }
...@@ -92,7 +94,8 @@ public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithM ...@@ -92,7 +94,8 @@ public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithM
* @covers ::queryCondition * @covers ::queryCondition
*/ */
public function testInvalidFilterPathDueMissingMetaPrefixReferenceFieldWithMetaProperties() { public function testInvalidFilterPathDueMissingMetaPrefixReferenceFieldWithMetaProperties() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'Invalid nested filtering. The property `alt`, given in the path `photo.alt` belongs to the meta object of a relationship and must be preceded by `meta`.'); $this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('Invalid nested filtering. The property `alt`, given in the path `photo.alt` belongs to the meta object of a relationship and must be preceded by `meta`.');
$resource_type = new ResourceType('node', 'painting', NULL); $resource_type = new ResourceType('node', 'painting', NULL);
Filter::createFromQueryParameter(['photo.alt' => ''], $resource_type, $this->fieldResolver); Filter::createFromQueryParameter(['photo.alt' => ''], $resource_type, $this->fieldResolver);
} }
...@@ -101,7 +104,8 @@ public function testInvalidFilterPathDueMissingMetaPrefixReferenceFieldWithMetaP ...@@ -101,7 +104,8 @@ public function testInvalidFilterPathDueMissingMetaPrefixReferenceFieldWithMetaP
* @covers ::queryCondition * @covers ::queryCondition
*/ */
public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithoutMetaProperties() { public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithoutMetaProperties() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'Invalid nested filtering. The field `uid`, given in the path `uid` is incomplete, it must end with one of the following specifiers: `id`.'); $this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('Invalid nested filtering. The field `uid`, given in the path `uid` is incomplete, it must end with one of the following specifiers: `id`.');
$resource_type = new ResourceType('node', 'painting', NULL); $resource_type = new ResourceType('node', 'painting', NULL);