diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php index 8f99198..91b941d 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php @@ -6,6 +6,7 @@ namespace Drupal\Tests\Core\StringTranslation; +use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Tests\UnitTestCase; use Drupal\Core\StringTranslation\TranslationWrapper; @@ -50,17 +51,16 @@ public function errorHandler($error_number, $error_message) { * @covers ::__toString */ public function testToString() { - $text = new TranslationWrapper('May I have an exception please?'); + $string = 'May I have an exception please?'; + $text = new TranslationWrapper($string); - $translation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'); - $translation->expects($this->any()) - ->method('translate') - ->willReturnCallback(function () { - throw new \Exception('Yes you may.'); - }); - $text->setStringTranslation($translation); + $translation = $this->prophesize(TranslationInterface::class); + $translation->translate($string, [], [])->will(function () { + throw new \Exception('Yes you may.'); + }); + $text->setStringTranslation($translation->reveal()); - set_error_handler(array($this, "errorHandler")); + set_error_handler([$this, 'errorHandler']); // We want this to trigger an error. $result = (string) $text; restore_error_handler();