Issue #3412464 by mstrelan, smustgrave, quietone: Fix strict type errors: Convert FormattableMarkup to strings (complex replacement) in core Functional tests
parent
8b9ff02e52
commit
362a5f61d9
|
@ -4,7 +4,6 @@ namespace Drupal\Tests\block_content\Functional\Views;
|
|||
|
||||
use Drupal\block_content\Entity\BlockContent;
|
||||
use Drupal\block_content\Entity\BlockContentType;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
|
||||
/**
|
||||
|
@ -71,7 +70,7 @@ abstract class BlockContentTestBase extends ViewTestBase {
|
|||
if ($block_content = BlockContent::create($values)) {
|
||||
$status = $block_content->save();
|
||||
}
|
||||
$this->assertEquals(SAVED_NEW, $status, new FormattableMarkup('Created block content %info.', ['%info' => $block_content->label()]));
|
||||
$this->assertEquals(SAVED_NEW, $status, "Created block content {$block_content->label()}.");
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,7 @@ abstract class BlockContentTestBase extends ViewTestBase {
|
|||
$status = $bundle->save();
|
||||
block_content_add_body_field($bundle->id());
|
||||
|
||||
$this->assertEquals(SAVED_NEW, $status, new FormattableMarkup('Created block content type %bundle.', ['%bundle' => $bundle->id()]));
|
||||
$this->assertEquals(SAVED_NEW, $status, sprintf('Created block content type %s.', $bundle->id()));
|
||||
return $bundle;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\comment\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
|
@ -149,8 +148,7 @@ class CommentLanguageTest extends BrowserTestBase {
|
|||
->range(0, 1)
|
||||
->execute();
|
||||
$comment = Comment::load(reset($cids));
|
||||
$args = ['%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode];
|
||||
$this->assertEquals($langcode, $comment->langcode->value, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
|
||||
$this->assertEquals($langcode, $comment->langcode->value, "The comment posted with content language $langcode and belonging to the node with language $node_langcode has language {$comment->langcode->value}");
|
||||
$this->assertEquals($comment_values[$node_langcode][$langcode], $comment->comment_body->value, 'Comment body correctly stored.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ class CommentPagerTest extends CommentTestBase {
|
|||
foreach ($comment_anchors as $anchor) {
|
||||
$result_order[] = substr($anchor->getAttribute('id'), 8);
|
||||
}
|
||||
$this->assertEquals($expected_cids, $result_order, new FormattableMarkup('Comment order: expected @expected, returned @returned.', ['@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)]));
|
||||
$this->assertEquals($expected_cids, $result_order, sprintf('Comment order: expected %s, returned %s.', implode(',', $expected_cids), implode(',', $result_order)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\comment\Functional\Views;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\comment\CommentInterface;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
|
@ -140,9 +139,7 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
|
|||
|
||||
// Check the number of results given by the display is the expected.
|
||||
$this->assertCount($this->blockDisplayResults, $view->result,
|
||||
new FormattableMarkup('There are exactly @results comments. Expected @expected',
|
||||
['@results' => count($view->result), '@expected' => $this->blockDisplayResults]
|
||||
)
|
||||
'There are exactly ' . count($view->result) . ' comments. Expected ' . $this->blockDisplayResults
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\contact\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\contact\Entity\ContactForm;
|
||||
use Drupal\Core\Mail\MailFormatHelper;
|
||||
|
@ -612,7 +611,7 @@ class ContactSitewideTest extends BrowserTestBase {
|
|||
$this->drupalGet("admin/structure/contact/manage/{$id}/delete");
|
||||
$this->submitForm([], 'Delete');
|
||||
$this->assertSession()->pageTextContains("The contact form {$contact_form->label()} has been deleted.");
|
||||
$this->assertNull(ContactForm::load($id), new FormattableMarkup('Form %contact_form not found', ['%contact_form' => $contact_form->label()]));
|
||||
$this->assertNull(ContactForm::load($id), "Form {$contact_form->label()} not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\content_translation\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\Core\Field\Entity\BaseFieldOverride;
|
||||
|
@ -282,8 +281,8 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
|
|||
protected function assertSettings(string $entity_type, ?string $bundle, bool $enabled, array $edit): void {
|
||||
$this->drupalGet('admin/config/regional/content-language');
|
||||
$this->submitForm($edit, 'Save configuration');
|
||||
$args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'];
|
||||
$message = new FormattableMarkup('Translation for entity @entity_type (@bundle) is @enabled.', $args);
|
||||
$status = $enabled ? 'enabled' : 'disabled';
|
||||
$message = "Translation for entity $entity_type ($bundle) is $status.";
|
||||
$this->assertEquals($enabled, \Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle), $message);
|
||||
}
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ class DbLogTest extends BrowserTestBase {
|
|||
$ids[] = $row->wid;
|
||||
}
|
||||
$count_before = (isset($ids)) ? count($ids) : 0;
|
||||
$this->assertGreaterThan(0, $count_before, new FormattableMarkup('DBLog contains @count records for @name', ['@count' => $count_before, '@name' => $user->getAccountName()]));
|
||||
$this->assertGreaterThan(0, $count_before, "DBLog contains $count_before records for {$user->getAccountName()}");
|
||||
|
||||
// Log in the admin user.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Functional\EntityReference;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
@ -172,7 +171,7 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
|
|||
// Ensure the configuration has the expected dependency on the entity that
|
||||
// is being used a default value.
|
||||
$field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);
|
||||
$this->assertContains($referenced_entities[0]->getConfigDependencyName(), $field->getDependencies()[$key], new FormattableMarkup('Expected @type dependency @name found', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
|
||||
$this->assertContains($referenced_entities[0]->getConfigDependencyName(), $field->getDependencies()[$key], 'Expected ' . $key . ' dependency ' . $referenced_entities[0]->getConfigDependencyName() . ' found');
|
||||
// Ensure that the field can be imported without change even after the
|
||||
// default value deleted.
|
||||
$referenced_entities[0]->delete();
|
||||
|
@ -186,7 +185,7 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
|
|||
$field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);
|
||||
$field->save();
|
||||
$dependencies = $field->getDependencies();
|
||||
$this->assertFalse(isset($dependencies[$key]) && in_array($referenced_entities[0]->getConfigDependencyName(), $dependencies[$key]), new FormattableMarkup('@type dependency @name does not exist.', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
|
||||
$this->assertFalse(isset($dependencies[$key]) && in_array($referenced_entities[0]->getConfigDependencyName(), $dependencies[$key]), $key . ' dependency ' . $referenced_entities[0]->getConfigDependencyName() . ' does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
|
@ -145,7 +144,7 @@ class TranslationWebTest extends FieldTestBase {
|
|||
$entity = $storage->loadRevision($revision_id);
|
||||
foreach ($available_langcodes as $langcode => $value) {
|
||||
$passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1;
|
||||
$this->assertTrue($passed, new FormattableMarkup('The @language translation for revision @revision was correctly stored', ['@language' => $langcode, '@revision' => $entity->getRevisionId()]));
|
||||
$this->assertTrue($passed, "The $langcode translation for revision {$entity->getRevisionId()} was correctly stored");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\file\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\file\Entity\File;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +42,7 @@ class FileFieldPathTest extends FileFieldTestBase {
|
|||
$date_formatter->format(REQUEST_TIME, 'custom', 'Y') . '-' .
|
||||
$date_formatter->format(REQUEST_TIME, 'custom', 'm') . '/' .
|
||||
$test_file->getFilename();
|
||||
$this->assertPathMatch($expected_filename, $node_file->getFileUri(), new FormattableMarkup('The file %file was uploaded to the correct path.', ['%file' => $node_file->getFileUri()]));
|
||||
$this->assertPathMatch($expected_filename, $node_file->getFileUri(), "The file {$node_file->getFileUri()} was uploaded to the correct path.");
|
||||
|
||||
// Change the path to contain multiple subdirectories.
|
||||
$this->updateFileField($field_name, $type_name, ['file_directory' => 'foo/bar/baz']);
|
||||
|
@ -55,7 +54,7 @@ class FileFieldPathTest extends FileFieldTestBase {
|
|||
$node_storage->resetCache([$nid]);
|
||||
$node = $node_storage->load($nid);
|
||||
$node_file = File::load($node->{$field_name}->target_id);
|
||||
$this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), new FormattableMarkup('The file %file was uploaded to the correct path.', ['%file' => $node_file->getFileUri()]));
|
||||
$this->assertPathMatch('public://foo/bar/baz/' . $test_file->getFilename(), $node_file->getFileUri(), "The file {$node_file->getFileUri()} was uploaded to the correct path.");
|
||||
|
||||
// Check the path when used with tokens.
|
||||
// Change the path to contain multiple token directories.
|
||||
|
@ -72,7 +71,7 @@ class FileFieldPathTest extends FileFieldTestBase {
|
|||
// the user running the test case.
|
||||
$data = ['user' => $this->adminUser];
|
||||
$subdirectory = \Drupal::token()->replace('[user:uid]/[user:name]', $data);
|
||||
$this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), new FormattableMarkup('The file %file was uploaded to the correct path with token replacements.', ['%file' => $node_file->getFileUri()]));
|
||||
$this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->getFilename(), $node_file->getFileUri(), "The file {$node_file->getFileUri()} was uploaded to the correct path with token replacements.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\file\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\StringTranslation\ByteSizeMarkup;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
|
@ -44,7 +43,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
|
|||
|
||||
// Create a new node with the uploaded file.
|
||||
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
|
||||
$this->assertNotFalse($nid, new FormattableMarkup('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', ['@test_file' => $test_file->getFileUri(), '@field_name' => $field_name, '@type_name' => $type_name]));
|
||||
$this->assertNotFalse($nid, "uploadNodeFile({$test_file->getFileUri()}, $field_name, $type_name) succeeded");
|
||||
|
||||
$node_storage->resetCache([$nid]);
|
||||
$node = $node_storage->load($nid);
|
||||
|
@ -104,10 +103,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
|
|||
$node = $node_storage->load($nid);
|
||||
$node_file = File::load($node->{$field_name}->target_id);
|
||||
$this->assertFileExists($node_file->getFileUri());
|
||||
$this->assertFileEntryExists($node_file, new FormattableMarkup('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', [
|
||||
'%filesize' => ByteSizeMarkup::create($small_file->getSize()),
|
||||
'%maxsize' => $max_filesize,
|
||||
]));
|
||||
$this->assertFileEntryExists($node_file, sprintf('File entry exists after uploading a file (%s) under the max limit (%s).', ByteSizeMarkup::create($small_file->getSize()), $max_filesize));
|
||||
|
||||
// Check that uploading the large file fails (1M limit).
|
||||
$this->uploadNodeFile($large_file, $field_name, $type_name);
|
||||
|
@ -125,9 +121,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
|
|||
$node = $node_storage->load($nid);
|
||||
$node_file = File::load($node->{$field_name}->target_id);
|
||||
$this->assertFileExists($node_file->getFileUri());
|
||||
$this->assertFileEntryExists($node_file, new FormattableMarkup('File entry exists after uploading a file (%filesize) with no max limit.', [
|
||||
'%filesize' => ByteSizeMarkup::create($large_file->getSize()),
|
||||
]));
|
||||
$this->assertFileEntryExists($node_file, sprintf('File entry exists after uploading a file (%s) with no max limit.', ByteSizeMarkup::create($large_file->getSize())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\file\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\Component\Serialization\Json;
|
||||
|
@ -168,7 +167,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
|
|||
// Ensure we have the expected number of Remove buttons, and that they
|
||||
// are numbered sequentially.
|
||||
$buttons = $this->xpath('//input[@type="submit" and @value="Remove"]');
|
||||
$this->assertCount($num_expected_remove_buttons, $buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons]));
|
||||
$this->assertCount($num_expected_remove_buttons, $buttons, "There are $num_expected_remove_buttons \"Remove\" buttons displayed.");
|
||||
foreach ($buttons as $i => $button) {
|
||||
$key = $i >= $remaining ? $i - $remaining : $i;
|
||||
$check_field_name = $field_name2;
|
||||
|
|
|
@ -44,16 +44,16 @@ abstract class FileManagedTestBase extends BrowserTestBase {
|
|||
// Determine if there were any expected that were not called.
|
||||
$uncalled = array_diff($expected, $actual);
|
||||
if (count($uncalled)) {
|
||||
$this->assertTrue(FALSE, new FormattableMarkup('Expected hooks %expected to be called but %uncalled was not called.', ['%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)]));
|
||||
$this->assertTrue(FALSE, sprintf('Expected hooks %s to be called but %s was not called.', implode(', ', $expected), implode(', ', $uncalled)));
|
||||
}
|
||||
else {
|
||||
$this->assertTrue(TRUE, new FormattableMarkup('All the expected hooks were called: %expected', ['%expected' => empty($expected) ? '(none)' : implode(', ', $expected)]));
|
||||
$this->assertTrue(TRUE, sprintf('All the expected hooks were called: %s', empty($expected) ? '(none)' : implode(', ', $expected)));
|
||||
}
|
||||
|
||||
// Determine if there were any unexpected calls.
|
||||
$unexpected = array_diff($actual, $expected);
|
||||
if (count($unexpected)) {
|
||||
$this->assertTrue(FALSE, new FormattableMarkup('Unexpected hooks were called: %unexpected.', ['%unexpected' => empty($unexpected) ? '(none)' : implode(', ', $unexpected)]));
|
||||
$this->assertTrue(FALSE, sprintf('Unexpected hooks were called: %s.', empty($unexpected) ? '(none)' : implode(', ', $unexpected)));
|
||||
}
|
||||
else {
|
||||
$this->assertTrue(TRUE, 'No unexpected hooks were called.');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\image\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\file\Entity\File;
|
||||
|
@ -167,18 +166,13 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
$uuids[$effect->getPluginId()] = $uuid;
|
||||
$effect_configuration = $effect->getConfiguration();
|
||||
foreach ($effect_edits[$effect->getPluginId()] as $field => $value) {
|
||||
$this->assertEquals($effect_configuration['data'][$field], $value, new FormattableMarkup('The %field field in the %effect effect has the correct value of %value.', ['%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value]));
|
||||
$this->assertEquals($effect_configuration['data'][$field], $value, "The $field field in the {$effect->getPluginId()} effect has the correct value of $value.");
|
||||
}
|
||||
}
|
||||
|
||||
// Assert that every effect was saved.
|
||||
foreach (array_keys($effect_edits) as $effect_name) {
|
||||
$this->assertTrue(isset($uuids[$effect_name]), new FormattableMarkup(
|
||||
'A %effect_name effect was saved with ID %uuid',
|
||||
[
|
||||
'%effect_name' => $effect_name,
|
||||
'%uuid' => $uuids[$effect_name],
|
||||
]));
|
||||
$this->assertTrue(isset($uuids[$effect_name]), "A $effect_name effect was saved with ID $uuids[$effect_name]");
|
||||
}
|
||||
|
||||
// Image style overview form (ordering and renaming).
|
||||
|
@ -212,7 +206,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
|
||||
// Create an image to make sure it gets flushed after saving.
|
||||
$image_path = $this->createSampleImage($style);
|
||||
$this->assertEquals(1, $this->getImageCount($style), new FormattableMarkup('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
|
||||
$this->assertEquals(1, $this->getImageCount($style), "Image style {$style->label()} image $image_path successfully generated.");
|
||||
|
||||
$this->drupalGet($style_path);
|
||||
$this->submitForm($edit, 'Save');
|
||||
|
@ -231,7 +225,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
// Check that the image was flushed after updating the style.
|
||||
// This is especially important when renaming the style. Make sure that
|
||||
// the old image directory has been deleted.
|
||||
$this->assertEquals(0, $this->getImageCount($style), new FormattableMarkup('Image style %style was flushed after renaming the style and updating the order of effects.', ['%style' => $style->label()]));
|
||||
$this->assertEquals(0, $this->getImageCount($style), "Image style {$style->label()} was flushed after renaming the style and updating the order of effects.");
|
||||
|
||||
// Load the style by the new name with the new weights.
|
||||
$style = ImageStyle::load($style_name);
|
||||
|
@ -252,7 +246,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
|
||||
// Create an image to make sure it gets flushed after deleting an effect.
|
||||
$image_path = $this->createSampleImage($style);
|
||||
$this->assertEquals(1, $this->getImageCount($style), new FormattableMarkup('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
|
||||
$this->assertEquals(1, $this->getImageCount($style), "Image style {$style->label()} image $image_path successfully generated.");
|
||||
|
||||
// Delete the 'image_crop' effect from the style.
|
||||
$this->drupalGet($style_path . '/effects/' . $uuids['image_crop'] . '/delete');
|
||||
|
@ -267,12 +261,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
// actually deleted.
|
||||
$entity_type_manager = $this->container->get('entity_type.manager');
|
||||
$style = $entity_type_manager->getStorage('image_style')->loadUnchanged($style->id());
|
||||
$this->assertFalse($style->getEffects()->has($uuids['image_crop']), new FormattableMarkup(
|
||||
'Effect with ID %uuid no longer found on image style %style',
|
||||
[
|
||||
'%uuid' => $uuids['image_crop'],
|
||||
'%style' => $style->label(),
|
||||
]));
|
||||
$this->assertFalse($style->getEffects()->has($uuids['image_crop']), "Effect with ID {$uuids['image_crop']} no longer found on image style {$style->label()}");
|
||||
|
||||
// Additional test on Rotate effect, for transparent background.
|
||||
$edit = [
|
||||
|
@ -297,7 +286,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
|
|||
$directory = 'public://styles/' . $style_name;
|
||||
$this->assertDirectoryDoesNotExist($directory);
|
||||
|
||||
$this->assertNull(ImageStyle::load($style_name), new FormattableMarkup('Image style %style successfully deleted.', ['%style' => $style->label()]));
|
||||
$this->assertNull(ImageStyle::load($style_name), "Image style {$style->label()} successfully deleted.");
|
||||
|
||||
// Test empty text when there are no image styles.
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\image\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\File\FileSystemInterface;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
|
@ -145,7 +144,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
// Confirm that the image default is shown for a new article node.
|
||||
$article = $this->drupalCreateNode(['type' => 'article']);
|
||||
$article_built = $this->drupalBuildEntityView($article);
|
||||
$this->assertEquals($default_images['field']->id(), $article_built[$field_name][0]['#item']->target_id, new FormattableMarkup('A new article node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field']->id()]));
|
||||
$this->assertEquals($default_images['field']->id(), $article_built[$field_name][0]['#item']->target_id, "A new article node without an image has the expected default image file ID of {$default_images['field']->id()}.");
|
||||
|
||||
// Also check that the field renders without warnings when the label is
|
||||
// hidden.
|
||||
|
@ -157,7 +156,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
// Confirm that the image default is shown for a new page node.
|
||||
$page = $this->drupalCreateNode(['type' => 'page']);
|
||||
$page_built = $this->drupalBuildEntityView($page);
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, new FormattableMarkup('A new page node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field2']->id()]));
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, "A new page node without an image has the expected default image file ID of {$default_images['field2']->id()}.");
|
||||
|
||||
// Upload a new default for the field storage.
|
||||
$default_image_settings = $field_storage->getSetting('default_image');
|
||||
|
@ -174,8 +173,8 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
$node_storage->resetCache([$article->id(), $page->id()]);
|
||||
$article_built = $this->drupalBuildEntityView($article = $node_storage->load($article->id()));
|
||||
$page_built = $this->drupalBuildEntityView($page = $node_storage->load($page->id()));
|
||||
$this->assertEquals($default_images['field']->id(), $article_built[$field_name][0]['#item']->target_id, new FormattableMarkup('An existing article node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field']->id()]));
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, new FormattableMarkup('An existing page node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field2']->id()]));
|
||||
$this->assertEquals($default_images['field']->id(), $article_built[$field_name][0]['#item']->target_id, "An existing article node without an image has the expected default image file ID of {$default_images['field']->id()}.");
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, "An existing page node without an image has the expected default image file ID of {$default_images['field2']->id()}.");
|
||||
|
||||
// Upload a new default for the article's field.
|
||||
$default_image_settings = $field->getSetting('default_image');
|
||||
|
@ -193,9 +192,9 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
$page_built = $this->drupalBuildEntityView($page = $node_storage->load($page->id()));
|
||||
|
||||
// Confirm the article uses the new default.
|
||||
$this->assertEquals($default_images['field_new']->id(), $article_built[$field_name][0]['#item']->target_id, new FormattableMarkup('An existing article node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field_new']->id()]));
|
||||
$this->assertEquals($default_images['field_new']->id(), $article_built[$field_name][0]['#item']->target_id, "An existing article node without an image has the expected default image file ID of {$default_images['field_new']->id()}.");
|
||||
// Confirm the page remains unchanged.
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, new FormattableMarkup('An existing page node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field2']->id()]));
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, "An existing page node without an image has the expected default image file ID of {$default_images['field2']->id()}.");
|
||||
|
||||
// Confirm the default image is shown on the node form.
|
||||
$file = File::load($default_images['field_new']->id());
|
||||
|
@ -217,9 +216,9 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
|
|||
$article_built = $this->drupalBuildEntityView($article = $node_storage->load($article->id()));
|
||||
$page_built = $this->drupalBuildEntityView($page = $node_storage->load($page->id()));
|
||||
// Confirm the article uses the new field storage (not field) default.
|
||||
$this->assertEquals($default_images['field_storage_new']->id(), $article_built[$field_name][0]['#item']->target_id, new FormattableMarkup('An existing article node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field_storage_new']->id()]));
|
||||
$this->assertEquals($default_images['field_storage_new']->id(), $article_built[$field_name][0]['#item']->target_id, "An existing article node without an image has the expected default image file ID of {$default_images['field_storage_new']->id()}.");
|
||||
// Confirm the page remains unchanged.
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, new FormattableMarkup('An existing page node without an image has the expected default image file ID of @fid.', ['@fid' => $default_images['field2']->id()]));
|
||||
$this->assertEquals($default_images['field2']->id(), $page_built[$field_name][0]['#item']->target_id, "An existing page node without an image has the expected default image file ID of {$default_images['field2']->id()}.");
|
||||
|
||||
$non_image = $this->drupalGetTestFiles('text');
|
||||
$this->submitForm(['files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($non_image[0]->uri)], 'Upload');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\image\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\Tests\TestFileCreationTrait;
|
||||
|
||||
|
@ -100,11 +99,11 @@ class ImageStyleFlushTest extends ImageFieldTestBase {
|
|||
$image_path = $this->createSampleImage($style, 'public');
|
||||
// Expecting to find 2 images, one is the sample.png image shown in
|
||||
// image style preview.
|
||||
$this->assertEquals(2, $this->getImageCount($style, 'public'), new FormattableMarkup('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
|
||||
$this->assertEquals(2, $this->getImageCount($style, 'public'), "Image style {$style->label()} image $image_path successfully generated.");
|
||||
|
||||
// Create an image for the 'private' wrapper.
|
||||
$image_path = $this->createSampleImage($style, 'private');
|
||||
$this->assertEquals(1, $this->getImageCount($style, 'private'), new FormattableMarkup('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path]));
|
||||
$this->assertEquals(1, $this->getImageCount($style, 'private'), "Image style {$style->label()} image $image_path successfully generated.");
|
||||
|
||||
// Remove the 'image_scale' effect and updates the style, which in turn
|
||||
// forces an image style flush.
|
||||
|
@ -121,10 +120,10 @@ class ImageStyleFlushTest extends ImageFieldTestBase {
|
|||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
// Post flush, expected 1 image in the 'public' wrapper (sample.png).
|
||||
$this->assertEquals(1, $this->getImageCount($style, 'public'), new FormattableMarkup('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'public']));
|
||||
$this->assertEquals(1, $this->getImageCount($style, 'public'), "Image style {$style->label()} flushed correctly for public wrapper.");
|
||||
|
||||
// Post flush, expected no image in the 'private' wrapper.
|
||||
$this->assertEquals(0, $this->getImageCount($style, 'private'), new FormattableMarkup('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'private']));
|
||||
$this->assertEquals(0, $this->getImageCount($style, 'private'), "Image style {$style->label()} flushed correctly for private wrapper.");
|
||||
|
||||
$state = \Drupal::state();
|
||||
$state->set('image_module_test_image_style_flush.called', FALSE);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Functional\Database;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
|
||||
/**
|
||||
* Tests the tablesort query extender.
|
||||
*
|
||||
|
@ -67,8 +65,8 @@ class SelectTableSortDefaultTest extends DatabaseTestBase {
|
|||
$first = array_shift($data->tasks);
|
||||
$last = array_pop($data->tasks);
|
||||
|
||||
$this->assertEquals($sort['first'], $first->task, new FormattableMarkup('Items appear in the correct order sorting by @field @sort.', ['@field' => $sort['field'], '@sort' => $sort['sort']]));
|
||||
$this->assertEquals($sort['last'], $last->task, new FormattableMarkup('Items appear in the correct order sorting by @field @sort.', ['@field' => $sort['field'], '@sort' => $sort['sort']]));
|
||||
$this->assertEquals($sort['first'], $first->task, "Items appear in the correct order sorting by {$sort['field']} {$sort['sort']}.");
|
||||
$this->assertEquals($sort['last'], $last->task, "Items appear in the correct order sorting by {$sort['field']} {$sort['sort']}.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -398,11 +398,7 @@ class FormTest extends BrowserTestBase {
|
|||
'zero_checkbox_off' => 0,
|
||||
];
|
||||
foreach ($expected_values as $widget => $expected_value) {
|
||||
$this->assertSame($values[$widget], $expected_value, new FormattableMarkup('Checkbox %widget returns expected value (expected: %expected, got: %value)', [
|
||||
'%widget' => var_export($widget, TRUE),
|
||||
'%expected' => var_export($expected_value, TRUE),
|
||||
'%value' => var_export($values[$widget], TRUE),
|
||||
]));
|
||||
$this->assertSame($values[$widget], $expected_value, sprintf('Checkbox %s returns expected value (expected: %s, got: %s)', var_export($widget, TRUE), var_export($expected_value, TRUE), var_export($values[$widget], TRUE)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,7 +471,7 @@ class FormTest extends BrowserTestBase {
|
|||
'multiple_no_default_required' => ['three' => 'three'],
|
||||
];
|
||||
foreach ($expected as $key => $value) {
|
||||
$this->assertSame($value, $values[$key], new FormattableMarkup('@name: @actual is equal to @expected.', ['@name' => $key, '@actual' => var_export($values[$key], TRUE), '@expected' => var_export($value, TRUE)]));
|
||||
$this->assertSame($value, $values[$key], sprintf('%s: %s is equal to %s.', $key, var_export($values[$key], TRUE), var_export($value, TRUE)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,7 +771,7 @@ class FormTest extends BrowserTestBase {
|
|||
// the disabled container.
|
||||
$actual_count = count($disabled_elements);
|
||||
$expected_count = 44;
|
||||
$this->assertEquals($expected_count, $actual_count, new FormattableMarkup('Found @actual elements with disabled property (expected @expected).', ['@actual' => count($disabled_elements), '@expected' => $expected_count]));
|
||||
$this->assertEquals($expected_count, $actual_count, sprintf('Found %s elements with disabled property (expected %s).', count($disabled_elements), $expected_count));
|
||||
|
||||
// Mink does not "see" hidden elements, so we need to set the value of the
|
||||
// hidden element directly.
|
||||
|
@ -812,7 +808,7 @@ class FormTest extends BrowserTestBase {
|
|||
// Checkboxes values are not filtered out.
|
||||
$values[$key] = array_filter($values[$key]);
|
||||
}
|
||||
$this->assertSame($expected_value, $values[$key], new FormattableMarkup('Default value for %type: expected %expected, returned %returned.', ['%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE)]));
|
||||
$this->assertSame($expected_value, $values[$key], sprintf('Default value for %s: expected %s, returned %s.', $key, var_export($expected_value, TRUE), var_export($values[$key], TRUE)));
|
||||
}
|
||||
|
||||
// Recurse children.
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Functional\Menu;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
|
@ -97,13 +96,13 @@ trait AssertBreadcrumbTrait {
|
|||
// No parts must be left, or an expected "Home" will always pass.
|
||||
$pass = ($pass && empty($parts));
|
||||
|
||||
$this->assertTrue($pass, new FormattableMarkup('Expected breadcrumb %parts on @path but found %found.', [
|
||||
'%parts' => implode(' » ', $trail),
|
||||
'%found' => implode(' » ', array_map(function (array $item) {
|
||||
$this->assertTrue($pass, sprintf('Expected breadcrumb %s on %s but found %s.',
|
||||
implode(' » ', $trail),
|
||||
$this->getUrl(),
|
||||
implode(' » ', array_map(function (array $item) {
|
||||
return $item['text'];
|
||||
}, $found)),
|
||||
'@path' => $this->getUrl(),
|
||||
]));
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Functional\Module;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Config\FileStorage;
|
||||
|
@ -137,12 +136,12 @@ abstract class ModuleTestBase extends BrowserTestBase {
|
|||
$this->rebuildContainer();
|
||||
foreach ($modules as $module) {
|
||||
if ($enabled) {
|
||||
$message = 'Module "@module" is enabled.';
|
||||
$message = 'Module "%s" is enabled.';
|
||||
}
|
||||
else {
|
||||
$message = 'Module "@module" is not enabled.';
|
||||
$message = 'Module "%s" is not enabled.';
|
||||
}
|
||||
$this->assertEquals($enabled, $this->container->get('module_handler')->moduleExists($module), new FormattableMarkup($message, ['@module' => $module]));
|
||||
$this->assertEquals($enabled, $this->container->get('module_handler')->moduleExists($module), sprintf($message, $module));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -82,7 +81,7 @@ class BulkFormTest extends BrowserTestBase {
|
|||
|
||||
foreach ($nodes as $node) {
|
||||
$changed_node = $node_storage->load($node->id());
|
||||
$this->assertTrue($changed_node->isSticky(), new FormattableMarkup('Node @nid got marked as sticky.', ['@nid' => $node->id()]));
|
||||
$this->assertTrue($changed_node->isSticky(), "Node {$node->id()} got marked as sticky.");
|
||||
}
|
||||
|
||||
$this->assertSession()->pageTextContains('Make content sticky was applied to 10 items.');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Functional\Plugin;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views_test_data\Plugin\views\filter\FilterTest as FilterPlugin;
|
||||
|
@ -99,7 +98,7 @@ class FilterTest extends ViewTestBase {
|
|||
|
||||
// Check that we have a single element, as a result of applying the '= John'
|
||||
// filter.
|
||||
$this->assertCount(1, $view->result, new FormattableMarkup('Results were returned. @count results.', ['@count' => count($view->result)]));
|
||||
$this->assertCount(1, $view->result, 'Results were returned. ' . count($view->result) . ' results.');
|
||||
|
||||
$view->destroy();
|
||||
|
||||
|
@ -125,7 +124,7 @@ class FilterTest extends ViewTestBase {
|
|||
|
||||
// Check if we have the other elements in the dataset, as a result of
|
||||
// applying the '<> John' filter.
|
||||
$this->assertCount(4, $view->result, new FormattableMarkup('Results were returned. @count results.', ['@count' => count($view->result)]));
|
||||
$this->assertCount(4, $view->result, 'Results were returned. ' . count($view->result) . ' results.');
|
||||
|
||||
$view->destroy();
|
||||
$view->initDisplay();
|
||||
|
@ -149,7 +148,7 @@ class FilterTest extends ViewTestBase {
|
|||
$this->executeView($view);
|
||||
|
||||
// Check if we have all 5 results.
|
||||
$this->assertCount(5, $view->result, new FormattableMarkup('All @count results returned', ['@count' => count($view->displayHandlers)]));
|
||||
$this->assertCount(5, $view->result, 'All ' . count($view->displayHandlers) . ' results returned');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Functional\Wizard;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +49,7 @@ class MenuTest extends WizardTestBase {
|
|||
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
|
||||
$link = $menu_link_manager->createInstance('views_view:views.' . $view['id'] . '.page_1');
|
||||
$url = $link->getUrlObject();
|
||||
$this->assertEquals('view.' . $view['id'] . '.page_1', $url->getRouteName(), new FormattableMarkup('Found a link to %path in the main menu', ['%path' => $view['page[path]']]));
|
||||
$this->assertEquals('view.' . $view['id'] . '.page_1', $url->getRouteName(), "Found a link to {$view['page[path]']} in the main menu");
|
||||
$metadata = $link->getMetaData();
|
||||
$this->assertEquals(['view_id' => $view['id'], 'display_id' => 'page_1'], $metadata);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
|
@ -104,8 +103,8 @@ class CustomBooleanTest extends UITestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
$this->{$values['test']}($values['true'], (string) $output, new FormattableMarkup('Expected custom boolean TRUE value %value in output for %type', ['%value' => $values['true'], '%type' => $type]));
|
||||
$this->{$values['test']}($values['false'], (string) $output, new FormattableMarkup('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
|
||||
$this->{$values['test']}($values['true'], (string) $output, "Expected custom boolean TRUE value {$values['true']} in output for $type");
|
||||
$this->{$values['test']}($values['false'], (string) $output, "Expected custom boolean FALSE value {$values['false']} in output for $type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,8 +177,8 @@ class CustomBooleanTest extends UITestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
$this->{$values['test']}($values['true'], (string) $output, new FormattableMarkup('Expected custom boolean TRUE value %value in output for %type', ['%value' => $values['true'], '%type' => $type]));
|
||||
$this->{$values['test']}($values['false'], (string) $output, new FormattableMarkup('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
|
||||
$this->{$values['test']}($values['true'], (string) $output, "Expected custom boolean TRUE value {$values['true']} in output for $type");
|
||||
$this->{$values['test']}($values['false'], (string) $output, "Expected custom boolean FALSE value {$values['false']} in output for $type");
|
||||
|
||||
// Assert that we are using the correct template.
|
||||
$this->assertStringContainsString('llama', (string) $output);
|
||||
|
|
|
@ -10,7 +10,6 @@ use Drupal\editor\Entity\Editor;
|
|||
use Drupal\KernelTests\AssertConfigTrait;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
|
||||
|
@ -288,7 +287,7 @@ class DemoUmamiProfileTest extends BrowserTestBase {
|
|||
|
||||
// @see ::drupalUserIsLoggedIn()
|
||||
$account->sessionId = $this->getSession()->getCookie(\Drupal::service('session_configuration')->getOptions(\Drupal::request())['name']);
|
||||
$this->assertTrue($this->drupalUserIsLoggedIn($account), new FormattableMarkup('User %name successfully logged in.', ['%name' => $account->getAccountName()]));
|
||||
$this->assertTrue($this->drupalUserIsLoggedIn($account), "User {$account->getAccountName()} successfully logged in.");
|
||||
|
||||
$this->loggedInUser = $account;
|
||||
$this->container->get('current_user')->setAccount($account);
|
||||
|
|
Loading…
Reference in New Issue