Verified Commit 6cc7ccc7 authored by Michael Strelan's avatar Michael Strelan
Browse files

task: #3629594 PHPUnit 13.2 - Replace expectExceptionMessage() with...

task: #3629594 PHPUnit 13.2 - Replace expectExceptionMessage() with expectExceptionMessageIs*() - later additions

By: mondrake
By: dcam
parent ecc5d942
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for core/modules/field/tests/src/Kernel/Plugin/Validation/Constraint/NoFieldItemsExistWithHigherCardinalityTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public function testValidation(): void {
    $field_storage->set('cardinality', 1);

    $this->expectException(SchemaIncompleteException::class);
    $this->expectExceptionMessageIs('Schema errors for field.storage.entity_test.field_int with the following errors: 0 [cardinality] The field 'field_int' of entity type 'entity_test' has more entries (2) than the cardinality (1) allows');
    $this->expectExceptionMessageIs('Schema errors for field.storage.entity_test.field_int with the following errors: 0 [cardinality] The field 'field_int' of entity type 'entity_test' has more entries (2) than the cardinality (1) allows.');
    $field_storage->save();
  }

+1 −1
Changes for core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ protected function getColumnDefinitions(string $schema, string $table): array {

    };
    $this->expectException(SchemaException::class);
    $this->expectExceptionMessage("Unable to recover the definition of generated column double_age");
    $this->expectExceptionMessageIs("Unable to recover the definition of generated column double_age");
    // Schema::fieldExists() introspects the whole table, so it trips on
    // 'double_age' no matter which column it is asked about.
    $schema->fieldExists($tableName, 'age');
+2 −2
Changes for core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ public function testInvokeWithNotMergeableString(): void {

    $expected_exception_message = 'Module hook_single_invoke should not implement custom_hook_invoke_string more than once.';
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage($expected_exception_message);
    $this->expectExceptionMessageIs($expected_exception_message);
    $this->moduleHandler()->invoke('hook_single_invoke', 'custom_hook_invoke_string', args: [TRUE]);
  }

@@ -436,7 +436,7 @@ public function testInvokeWithNotMergeableClass(): void {

    $expected_exception_message = 'Module hook_single_invoke should not implement custom_hook_invoke_class more than once.';
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage($expected_exception_message);
    $this->expectExceptionMessageIs($expected_exception_message);
    $this->moduleHandler()->invoke('hook_single_invoke', 'custom_hook_invoke_class', args: [TRUE]);
  }

+2 −2
Changes for core/tests/Drupal/KernelTests/Core/Database/SerializeQueryTest.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ class SerializeQueryTest extends DatabaseTestBase {
  public function testSerializeQuery(): void {
    $query = $this->connection->select('test');
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage('Database query objects are not serializable');
    $this->expectExceptionMessageIs('Database query objects are not serializable. This probably means you are serializing an object that has a reference to a query object. Adjust your code so that is not necessary, for example by storing the query arguments or results instead.');
    serialize($query);
  }

@@ -30,7 +30,7 @@ public function testSerializeQuery(): void {
  public function testUnserializeQuery(): void {
    $class = get_class($this->connection->select('test'));
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage('Database query objects cannot be unserialized');
    $this->expectExceptionMessageIs('Database query objects cannot be unserialized.');
    unserialize(sprintf('O:%d:"%s":0:{}', strlen($class), $class));
  }

+1 −1
Changes for core/tests/Drupal/KernelTests/Core/Plugin/DefaultPluginManagerTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public function testDefaultPluginManagerAnnotationsOnly(): void {
    $namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory]);
    $module_handler = $this->container->get('module_handler');

    $this->expectExceptionMessage('Drupal\Core\Plugin\DefaultPluginManager only supports annotation-based discovery, which is no longer supported as of Drupal 12.0. Provide an Attribute class and an Annotation class for BC. See https://www.drupal.org/node/3395582');
    $this->expectExceptionMessageIs('Drupal\Core\Plugin\DefaultPluginManager only supports annotation-based discovery, which is no longer supported as of Drupal 12.0. Provide an Attribute class and an Annotation class for BC. See https://www.drupal.org/node/3395582');

    $manager = new DefaultPluginManager($subdir, $namespaces, $module_handler, NULL, AnnotationPluginExample::class);
    $manager->getDefinitions();
Loading