Skip to content
Snippets Groups Projects
Verified Commit 0fc32f07 authored by quietone's avatar quietone
Browse files

Issue #3494633 by nikolay shapovalov, smustgrave: Remove FormattableMarkup...

Issue #3494633 by nikolay shapovalov, smustgrave: Remove FormattableMarkup from assertFileHookCalled()
parent 053c43e3
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
namespace Drupal\Tests\file\Functional; namespace Drupal\Tests\file\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\file\Entity\File; use Drupal\file\Entity\File;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
...@@ -75,13 +74,13 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL ...@@ -75,13 +74,13 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL
if (!isset($message)) { if (!isset($message)) {
if ($actual_count == $expected_count) { if ($actual_count == $expected_count) {
$message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]); $message = "hook_file_$hook was called correctly.";
} }
elseif ($expected_count == 0) { elseif ($expected_count == 0) {
$message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]); $message = "hook_file_$hook was not expected to be called but was actually called $actual_count time(s).";
} }
else { else {
$message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]); $message = "hook_file_$hook was expected to be called $expected_count time(s) but was called $actual_count time(s).";
} }
} }
$this->assertEquals($expected_count, $actual_count, $message); $this->assertEquals($expected_count, $actual_count, $message);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
namespace Drupal\Tests\file\Kernel; namespace Drupal\Tests\file\Kernel;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\file\Entity\File; use Drupal\file\Entity\File;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
...@@ -88,16 +87,16 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL ...@@ -88,16 +87,16 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL
if (!isset($message)) { if (!isset($message)) {
if ($actual_count == $expected_count) { if ($actual_count == $expected_count) {
$message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]); $message = "hook_file_$hook was called correctly.";
} }
elseif ($expected_count == 0) { elseif ($expected_count == 0) {
$message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]); $message = "hook_file_$hook was not expected to be called but was actually called $actual_count time(s).";
} }
else { else {
$message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]); $message = "hook_file_$hook was expected to be called $expected_count time(s) but was called $actual_count time(s).";
} }
} }
$this->assertEquals($expected_count, $actual_count, (string) $message); $this->assertEquals($expected_count, $actual_count, $message);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment