diff --git a/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php b/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php index 25d153f885..350c2c2a18 100644 --- a/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php +++ b/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php @@ -11,27 +11,11 @@ * @coversDefaultClass \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase * * @group entity_reference + * @group legacy */ class EntityReferenceSelectionUnitTest extends UnitTestCase { /** - * Triggered errors. - * - * @var array - */ - protected $errors = []; - - /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - set_error_handler(function($severity, $message, $file, $line, $context) { - $this->errors[] = compact('severity', 'message', 'file', 'line', 'context'); - }); - } - - /** * Tests invalid default configuration. * * @covers ::defaultConfiguration @@ -203,59 +187,14 @@ public function testSetConfigurationBcLevel() { * * @covers ::setConfiguration * @covers ::resolveBackwardCompatibilityConfiguration + * @expectedDeprecation "Providing settings under 'handler_settings' is deprecated and will be removed before 9.0.0. Move the settings in the root of the configuration array. See https://www.drupal.org/node/2870971." */ public function testDeprecationErrorTriggering() { - $deprecation_message = "Providing settings under 'handler_settings' is deprecated and will be removed before 9.0.0. Move the settings in the root of the configuration array. See https://www.drupal.org/node/2870971."; - - // Configuration with no BC level. - $config = ['setting1' => TRUE]; - new TestSelection($config, 'test_selector', []); - // Check that deprecation error has not been triggered. - $this->assertNoError($deprecation_message, E_USER_DEPRECATED); - // Configuration with BC level. $config = ['handler_settings' => ['setting1' => TRUE]]; new TestSelection($config, 'test_selector', []); - // Check that deprecation error has been triggered. - $this->assertError($deprecation_message, E_USER_DEPRECATED); - } - - /** - * Asserts that an error has been triggered. - * - * @param string $message - * The error message. - * @param int $severity - * The error severity. - */ - protected function assertError($message, $severity) { - $assertion_message = "Error '$message' (severity $severity) was triggered."; - foreach ($this->errors as $error) { - if ($error['message'] === $message && $error['severity'] === $severity) { - $this->assertTrue(TRUE, $assertion_message); - return; - } - } - $this->fail($assertion_message); - } - - /** - * Asserts that a specific error has not been triggered. - * - * @param string $message - * The error message. - * @param int $severity - * The error severity. - */ - protected function assertNoError($message, $severity) { - $assertion_message = "Error '$message' (severity $severity) was not triggered."; - foreach ($this->errors as $error) { - if ($error['message'] === $message && $error['severity'] === $severity) { - $this->fail($assertion_message); - return; - } - } - $this->assertTrue(TRUE, $assertion_message); + // Ensure at least one assertion. + $this->assertTrue(TRUE); } }