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) {
$big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($this->prophesize(AttachmentsResponseProcessorInterface::class));
$non_html_response = new $response_class();
$this->setExpectedException(\AssertionError::class);
$this->expectException(\AssertionError::class);
$big_pipe_response_attachments_processor->processAttachments($non_html_response);
}
......
......@@ -95,7 +95,8 @@ public function testTransformException() {
->method('getSourceProperty')
->willReturnMap([['bid', 99], ['module', 'foobar']]);
$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');
}
......
......@@ -116,7 +116,8 @@ protected function getExpectedUnauthorizedAccessMessage($method) {
*/
public function testGet() {
// 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();
Url::fromRoute('rest.entity.contact_message.GET')->toString(TRUE);
......@@ -127,7 +128,8 @@ public function testGet() {
*/
public function testPatch() {
// 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();
Url::fromRoute('rest.entity.contact_message.PATCH')->toString(TRUE);
......@@ -138,7 +140,8 @@ public function testPatch() {
*/
public function testDelete() {
// 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();
Url::fromRoute('rest.entity.contact_message.DELETE')->toString(TRUE);
......
......@@ -120,7 +120,8 @@ public function testInvalidRecipient() {
$sender->expects($this->once())
->method('isAnonymous')
->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);
}
......
......@@ -21,7 +21,8 @@ class ContentModerationStateResourceTest extends KernelTestBase {
* @see \Drupal\content_moderation\Entity\ContentModerationState
*/
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([
'id' => 'entity.content_moderation_state',
'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY,
......
......@@ -147,7 +147,7 @@ public function testBasicModeration($entity_type_id) {
}
// Set an invalid moderation state.
$this->setExpectedException(EntityStorageException::class);
$this->expectException(EntityStorageException::class);
$entity->moderation_state->value = 'foobar';
$entity->save();
}
......
......@@ -101,7 +101,7 @@ public function testGetValue() {
*/
public function testGet() {
$this->assertEquals('draft', $this->testNode->moderation_state->get(0)->value);
$this->setExpectedException(\InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->testNode->moderation_state->get(2);
}
......
......@@ -255,7 +255,7 @@ public function testSetValueProperty() {
* @dataProvider datetimeValidationProvider
*/
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->save();
......@@ -315,7 +315,7 @@ public function datetimeValidationProvider() {
* @dataProvider dateonlyValidationProvider
*/
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->save();
......
......@@ -18,7 +18,8 @@ public function testUnknownDateType($method = 'defineValueProcessPipeline') {
$migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal();
$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']);
}
......
......@@ -35,7 +35,8 @@ protected function setUp() {
public function testUnknownDateType($method = 'defineValueProcessPipeline') {
$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']);
}
......
......@@ -207,7 +207,8 @@ public function testCalculateDependenciesIncorrectBundle() {
'bundle' => 'test_bundle_not_exists',
'field_type' => 'test_field',
], $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();
}
......
......@@ -192,7 +192,8 @@ public function testInvalidEnforcedCardinality($enforced_cardinality) {
'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();
}
......
......@@ -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());
if ($migrate_exception) {
$this->setExpectedException(MigrateException::class, $migrate_exception);
$this->expectException(MigrateException::class);
$this->expectExceptionMessage($migrate_exception);
}
if ($plugin_not_found) {
......
......@@ -47,8 +47,8 @@ public function testDefaults() {
* @covers ::transform
*/
public function testDefaultsException() {
$this->setExpectedException(MigrateException::class,
sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE)));
$this->expectException(MigrateException::class);
$this->expectExceptionMessage(sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE)));
$this->plugin->transform([], $this->migrateExecutable, $this->row, 'property');
}
......
......@@ -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);
}
......@@ -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);
}
......@@ -146,7 +146,8 @@ public function testMarkFieldForDeletion() {
public function testDenormalizeSerializedItem() {
$entity = EntitySerializedField::create(['serialized' => 'boo']);
$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);
}
......@@ -159,7 +160,8 @@ public function testDenormalizeInvalidCustomSerializedField() {
$this->assertEquals($normalized['serialized_long'][0]['value'], ['Hello world!']);
$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);
}
......
......@@ -23,7 +23,7 @@ public function testFieldItemNormalizerDenormalizeExceptions($context) {
$field_item_normalizer = new FieldItemNormalizer();
$data = [];
$class = [];
$this->setExpectedException(InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$field_item_normalizer->denormalize($data, $class, NULL, $context);
}
......
......@@ -23,7 +23,7 @@ public function testFieldNormalizerDenormalizeExceptions($context) {
$field_item_normalizer = new FieldNormalizer();
$data = [];
$class = [];
$this->setExpectedException(InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$field_item_normalizer->denormalize($data, $class, NULL, $context);
}
......
......@@ -115,7 +115,8 @@ protected function getExpectedUnauthorizedAccessMessage($method) {
*/
public function testGetIndividual() {
// 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);
}
......@@ -125,7 +126,8 @@ public function testGetIndividual() {
*/
public function testPatchIndividual() {
// 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);
}
......@@ -135,7 +137,8 @@ public function testPatchIndividual() {
*/
public function testDeleteIndividual() {
// 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);
}
......@@ -145,7 +148,8 @@ public function testDeleteIndividual() {
*/
public function testRelated() {
// 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);
}
......@@ -155,7 +159,8 @@ public function testRelated() {
*/
public function testRelationships() {
// 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);
}
......@@ -181,7 +186,8 @@ public function testCollection() {
*/
public function testRevisions() {
// 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);
}
......
......@@ -126,7 +126,10 @@ public function resolveInternalIncludePathProvider() {
*/
public function testResolveInternalIncludePathError($entity_type, $bundle, $external_path, $expected_message = '') {
$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);
$this->sut->resolveInternalIncludePath($resource_type, $path_parts);
}
......@@ -245,7 +248,10 @@ public function resolveInternalEntityQueryPathProvider() {
* @dataProvider resolveInternalEntityQueryPathErrorProvider
*/
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);
}
......
......@@ -205,7 +205,7 @@ public function testGetIndividualDenied() {
$role = Role::load(RoleInterface::ANONYMOUS_ID);
$role->revokePermission('access content');
$role->save();
$this->setExpectedException(EntityAccessDeniedHttpException::class);
$this->expectException(EntityAccessDeniedHttpException::class);
$this->entityResource->getIndividual($this->node, Request::create('/jsonapi/node/article'));
}
......@@ -420,7 +420,8 @@ public function testCreateIndividualWithMissingRequiredData() {
Role::load(Role::ANONYMOUS_ID)
->grantPermission('create article content')
->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);
$payload = Json::encode([
'data' => [
......@@ -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->setRelatableResourceTypes([
'field_relationships' => [new ResourceType('node', 'article', NULL)],
......
......@@ -74,7 +74,8 @@ public function setUp() {
* @covers ::queryCondition
*/
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);
Filter::createFromQueryParameter(['colors' => ''], $resource_type, $this->fieldResolver);
}
......@@ -83,7 +84,8 @@ public function testInvalidFilterPathDueToMissingPropertyName() {
* @covers ::queryCondition
*/
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);
Filter::createFromQueryParameter(['photo' => ''], $resource_type, $this->fieldResolver);
}
......@@ -92,7 +94,8 @@ public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWithM
* @covers ::queryCondition
*/
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);
Filter::createFromQueryParameter(['photo.alt' => ''], $resource_type, $this->fieldResolver);
}
......@@ -101,7 +104,8 @@ public function testInvalidFilterPathDueMissingMetaPrefixReferenceFieldWithMetaP
* @covers ::queryCondition
*/
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);
Filter::createFromQueryParameter(['uid' => ''], $resource_type, $this->fieldResolver);
}
......@@ -110,7 +114,8 @@ public function testInvalidFilterPathDueToMissingPropertyNameReferenceFieldWitho
* @covers ::queryCondition
*/
public function testInvalidFilterPathDueToNonexistentProperty() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'Invalid nested filtering. The property `foobar`, given in the path `colors.foobar`, does not exist. Must be one of the following property names: `value`, `format`, `processed`.');
$this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('Invalid nested filtering. The property `foobar`, given in the path `colors.foobar`, does not exist. Must be one of the following property names: `value`, `format`, `processed`.');
$resource_type = new ResourceType('node', 'painting', NULL);
Filter::createFromQueryParameter(['colors.foobar' => ''], $resource_type, $this->fieldResolver);
}
......@@ -119,7 +124,8 @@ public function testInvalidFilterPathDueToNonexistentProperty() {
* @covers ::queryCondition
*/
public function testInvalidFilterPathDueToElidedSoleProperty() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'Invalid nested filtering. The property `value`, given in the path `promote.value`, does not exist. Filter by `promote`, not `promote.value` (the JSON:API module elides property names from single-property fields).');
$this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('Invalid nested filtering. The property `value`, given in the path `promote.value`, does not exist. Filter by `promote`, not `promote.value` (the JSON:API module elides property names from single-property fields).');
$resource_type = new ResourceType('node', 'painting', NULL);
Filter::createFromQueryParameter(['promote.value' => ''], $resource_type, $this->fieldResolver);
}
......
......@@ -134,7 +134,8 @@ public function testOldRevision() {
* @covers \Drupal\jsonapi\Revisions\VersionById::getRevision
*/
public function testInvalidRevisionId() {
$this->setExpectedException(CacheableNotFoundHttpException::class, sprintf('The requested version, identified by `id:%s`, could not be found.', $this->node2->getRevisionId()));
$this->expectException(CacheableNotFoundHttpException::class);
$this->expectExceptionMessage(sprintf('The requested version, identified by `id:%s`, could not be found.', $this->node2->getRevisionId()));
$this->versionNegotiator->getRevision($this->node, 'id:' . $this->node2->getRevisionId());
}
......@@ -161,7 +162,8 @@ public function testCurrentVersion() {
* @covers \Drupal\jsonapi\Revisions\VersionByRel::getRevision
*/
public function testInvalidRevisionRel() {
$this->setExpectedException(CacheableBadRequestHttpException::class, 'An invalid resource version identifier, `rel:erroneous-revision-name`, was provided.');
$this->expectException(CacheableBadRequestHttpException::class);
$this->expectExceptionMessage('An invalid resource version identifier, `rel:erroneous-revision-name`, was provided.');
$this->versionNegotiator->getRevision($this->node, 'rel:erroneous-revision-name');
}
......
......@@ -216,10 +216,8 @@ public function testDenormalizeUuid($id, $expect_exception) {
['type' => 'node--article'];
if ($expect_exception) {
$this->setExpectedException(
UnprocessableEntityHttpException::class,
'IDs should be properly generated and formatted UUIDs as described in RFC 4122.'
);
$this->expectException(UnprocessableEntityHttpException::class);
$this->expectExceptionMessage('IDs should be properly generated and formatted UUIDs as described in RFC 4122.');
}
$denormalized = $this->normalizer->denormalize($data, NULL, 'api_json', [
......
......@@ -149,7 +149,7 @@ public function testDenormalizeInvalidResource($data, $field_name) {
'related' => $field_name,
'target_entity' => $this->prophesize(FieldableEntityInterface::class)->reveal(),
];
$this->setExpectedException(BadRequestHttpException::class);
$this->expectException(BadRequestHttpException::class);
$this->normalizer->denormalize($data, NULL, 'api_json', $context);
}
......
......@@ -32,7 +32,7 @@ public function testConstruct($case) {
* @covers ::__construct
*/
public function testConstructException() {
$this->setExpectedException(\InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
new EntityConditionGroup('NOT_ALLOWED', []);
}
......
......@@ -75,7 +75,8 @@ public function queryParameterProvider() {
*/
public function testValidation($input, $exception) {
if ($exception) {
$this->setExpectedException(get_class($exception), $exception->getMessage());
$this->expectException(get_class($exception));
$this->expectExceptionMessage($exception->getMessage());
}
EntityCondition::createFromQueryParameter($input);
$this->assertTrue(is_null($exception), 'No exception was expected.');
......
......@@ -58,7 +58,7 @@ public function parameterProvider() {
* @covers ::createFromQueryParameter
*/
public function testCreateFromQueryParameterFail() {
$this->setExpectedException(BadRequestHttpException::class);
$this->expectException(BadRequestHttpException::class);
OffsetPage::createFromQueryParameter('lorem');
}
......
......@@ -84,7 +84,7 @@ public function parameterProvider() {
* @dataProvider badParameterProvider
*/
public function testCreateFromQueryParameterFail($input) {
$this->setExpectedException(BadRequestHttpException::class);
$this->expectException(BadRequestHttpException::class);
Sort::createFromQueryParameter($input);
}
......
......@@ -79,7 +79,8 @@ public function testTransformWithoutWeights() {
*/
public function testStringInput() {
$this->plugin = new LanguageNegotiation([], 'map', []);
$this->setExpectedException(MigrateException::class, 'The input should be an array');
$this->expectException(MigrateException::class);
$this->expectExceptionMessage('The input should be an array');
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
}
......
......@@ -53,7 +53,8 @@ public function testTransformConfigurable() {
*/
public function testStringInput() {
$this->plugin = new LanguageTypes([], 'map', []);
$this->setExpectedException(MigrateException::class, 'The input should be an array');
$this->expectException(MigrateException::class);
$this->expectExceptionMessage('The input should be an array');
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
}
......
......@@ -179,7 +179,8 @@ public function testGetContextsDuringPreview() {
*/
public function testSetSectionList() {
$section_list = $this->prophesize(SectionListInterface::class);
$this->setExpectedException(\Exception::class, '\Drupal\layout_builder\SectionStorageInterface::setSectionList() must no longer be called. The section list should be derived from context. See https://www.drupal.org/node/3016262.');
$this->expectException(\Exception::class);
$this->expectExceptionMessage('\Drupal\layout_builder\SectionStorageInterface::setSectionList() must no longer be called. The section list should be derived from context. See https://www.drupal.org/node/3016262.');
$this->plugin->setSectionList($section_list->reveal());
}
......
......@@ -300,7 +300,7 @@ public function testBuildWithFormException() {
$entity->get('the_field_name')->willReturn($field->reveal());
$block = $this->getTestBlock($entity);
$this->setExpectedException(EnforcedResponseException::class);
$this->expectException(EnforcedResponseException::class);
$block->build();
}
......
......@@ -37,7 +37,7 @@ protected function getSectionStorage(array $section_data) {
* Tests that configuration schema enforces valid values.
*/
public function testInvalidConfiguration() {
$this->setExpectedException(SchemaIncompleteException::class);
$this->expectException(SchemaIncompleteException::class);
$this->sectionStorage->getSection(0)->getComponent('first-uuid')->setConfiguration(['id' => 'foo', 'bar' => 'baz']);
$this->sectionStorage->save();
}
......
......@@ -216,7 +216,8 @@ public function testGetContextsDuringPreview() {
*/
public function testSetSectionList() {
$section_list = $this->prophesize(SectionListInterface::class);
$this->setExpectedException(\Exception::class, '\Drupal\layout_builder\SectionStorageInterface::setSectionList() must no longer be called. The section list should be derived from context. See https://www.drupal.org/node/3016262.');
$this->expectException(\Exception::class);
$this->expectExceptionMessage('\Drupal\layout_builder\SectionStorageInterface::setSectionList() must no longer be called. The section list should be derived from context. See https://www.drupal.org/node/3016262.');
$this->plugin->setSectionList($section_list->reveal());
}
......
......@@ -23,7 +23,8 @@ protected function getSectionStorage(array $section_data) {
* @covers ::addBlankSection
*/
public function testAddBlankSection() {
$this->setExpectedException(\Exception::class, 'A blank section must only be added to an empty list');
$this->expectException(\Exception::class);
$this->expectExceptionMessage('A blank section must only be added to an empty list');
$this->sectionStorage->addBlankSection();
}
......