Issue #3170396 by mondrake, ankithashetty, longwave, catch: [backport] Remove uses of t() and switch to pageTextContains() in assert(No)Raw() calls

merge-requests/181/merge
catch 2021-08-09 08:20:42 +01:00
parent cef0c90065
commit 18ab5c0a2b
119 changed files with 470 additions and 638 deletions

View File

@ -89,7 +89,7 @@ class ConfigurationTest extends BrowserTestBase {
$this->assertSession()->statusCodeEquals(200);
// Make sure that the action was actually deleted.
$this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]));
$this->assertSession()->pageTextContains("The action $new_action_label has been deleted.");
$this->drupalGet('admin/config/system/actions');
$this->assertSession()->statusCodeEquals(200);
// The action label does not appear on the overview page.

View File

@ -48,8 +48,8 @@ class AddFeedTest extends AggregatorTestBase {
];
$this->drupalGet('aggregator/sources/add');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
$this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
$this->assertSession()->pageTextContains('A feed named ' . $feed->label() . ' already exists. Enter a unique title.');
$this->assertSession()->pageTextContains('A feed with this URL ' . $feed->getUrl() . ' already exists. Enter a unique URL.');
// Delete feed.
$this->deleteFeed($feed);

View File

@ -99,7 +99,7 @@ abstract class AggregatorTestBase extends BrowserTestBase {
public function deleteFeed(FeedInterface $feed) {
$this->drupalGet('aggregator/sources/' . $feed->id() . '/delete');
$this->submitForm([], 'Delete');
$this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]));
$this->assertSession()->pageTextContains('The feed ' . $feed->label() . ' has been deleted.');
}
/**
@ -222,7 +222,7 @@ abstract class AggregatorTestBase extends BrowserTestBase {
public function deleteFeedItems(FeedInterface $feed) {
$this->drupalGet('admin/config/services/aggregator/delete/' . $feed->id());
$this->submitForm([], 'Delete items');
$this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]));
$this->assertSession()->pageTextContains('The news items from ' . $feed->label() . ' have been deleted.');
}
/**

View File

@ -119,7 +119,7 @@ class FeedParserTest extends AggregatorTestBase {
// Update the feed. Use the UI to be able to check the message easily.
$this->drupalGet('admin/config/services/aggregator');
$this->clickLink('Update items');
$this->assertRaw(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()]));
$this->assertSession()->pageTextContains('The feed from ' . $feed->label() . ' seems to be broken because of error');
}
}

View File

@ -63,7 +63,7 @@ class ImportOpmlTest extends AggregatorTestBase {
$edit = [];
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$this->assertSession()->pageTextContains('Either upload a file or enter a URL.');
$path = $this->getEmptyOpml();
$edit = [
@ -72,7 +72,7 @@ class ImportOpmlTest extends AggregatorTestBase {
];
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));
$this->assertSession()->pageTextContains('Either upload a file or enter a URL.');
// Error if the URL is invalid.
$edit = ['remote' => 'invalidUrl://empty'];
@ -120,9 +120,9 @@ class ImportOpmlTest extends AggregatorTestBase {
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->submitForm($edit, 'Import');
// Verify that a duplicate URL was identified.
$this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]));
$this->assertSession()->pageTextContains('A feed with the URL ' . $feeds[0]['url[0][value]'] . ' already exists.');
// Verify that a duplicate title was identified.
$this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]));
$this->assertSession()->pageTextContains('A feed named ' . $feeds[1]['title[0][value]'] . ' already exists.');
$after = $count_query->execute();
$this->assertEquals(2, $after, 'Verifying that two distinct feeds were added.');

View File

@ -42,7 +42,7 @@ class IpAddressBlockingTest extends BrowserTestBase {
$this->submitForm($edit, 'Add');
$ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $edit['ip'])->execute()->fetchField();
$this->assertNotEmpty($ip, 'IP address found in database.');
$this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]));
$this->assertSession()->pageTextContains('The IP address 1.2.3.3 has been banned.');
// Try to block an IP address that's already blocked.
$edit = [];
@ -78,7 +78,7 @@ class IpAddressBlockingTest extends BrowserTestBase {
$this->submitForm([], 'Add');
$ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $submit_ip)->execute()->fetchField();
$this->assertNotEmpty($ip, 'IP address found in database');
$this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]));
$this->assertSession()->pageTextContains("The IP address $submit_ip has been banned.");
// Submit your own IP address. This fails, although it works when testing
// manually.

View File

@ -45,17 +45,17 @@ class BlockInvalidRegionTest extends BrowserTestBase {
\Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
$block = Block::load($block->id());
$warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block->id(), '%region' => 'invalid_region']);
$warning_message = 'The block ' . $block->id() . ' was assigned to the invalid region invalid_region and has been disabled.';
// Clearing the cache should disable the test block placed in the invalid region.
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
$this->assertRaw($warning_message);
$this->assertSession()->pageTextContains($warning_message);
// Clear the cache to check if the warning message is not triggered.
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
$this->assertNoRaw($warning_message);
$this->assertSession()->pageTextNotContains($warning_message);
// Place disabled test block in the invalid region of the default theme.
\Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
@ -64,7 +64,7 @@ class BlockInvalidRegionTest extends BrowserTestBase {
// Clear the cache to check if the warning message is not triggered.
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
$this->assertNoRaw($warning_message);
$this->assertSession()->pageTextNotContains($warning_message);
}
}

View File

@ -244,17 +244,17 @@ class BlockTest extends BlockTestBase {
// Test deleting the block from the edit form.
$this->drupalGet('admin/structure/block/manage/' . $block['id']);
$this->clickLink('Remove block');
$this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block['settings[label]']]));
$this->assertSession()->pageTextContains('Are you sure you want to remove the block ' . $block['settings[label]'] . '?');
$this->submitForm([], 'Remove');
$this->assertRaw(t('The block %name has been removed.', ['%name' => $block['settings[label]']]));
$this->assertSession()->pageTextContains('The block ' . $block['settings[label]'] . ' has been removed.');
// Test deleting a block via "Configure block" link.
$block = $this->drupalPlaceBlock('system_powered_by_block');
$this->drupalGet('admin/structure/block/manage/' . $block->id(), ['query' => ['destination' => 'admin']]);
$this->clickLink('Remove block');
$this->assertRaw(t('Are you sure you want to remove the block @name?', ['@name' => $block->label()]));
$this->assertSession()->pageTextContains('Are you sure you want to remove the block ' . $block->label() . '?');
$this->submitForm([], 'Remove');
$this->assertRaw(t('The block %name has been removed.', ['%name' => $block->label()]));
$this->assertSession()->pageTextContains('The block ' . $block->label() . ' has been removed.');
$this->assertSession()->addressEquals('admin');
$this->assertSession()->responseNotContains($block->id());
}

View File

@ -2,7 +2,6 @@
namespace Drupal\Tests\block_content\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Core\Database\Database;
@ -60,10 +59,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->submitForm($edit, 'Save');
// Check that the Basic block has been created.
$this->assertRaw(new FormattableMarkup('@block %name has been created.', [
'@block' => 'basic',
'%name' => $edit['info[0][value]'],
]));
$this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
// Check that the view mode setting is hidden because only one exists.
$this->assertSession()->fieldNotExists('settings[view_mode]');
@ -81,9 +77,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->submitForm($edit, 'Save');
// Check that the Basic block has been created.
$this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [
'%value' => $edit['info[0][value]'],
]));
$this->assertSession()->pageTextContains('A custom block with block description ' . $edit['info[0][value]'] . ' already exists.');
$this->assertSession()->statusCodeEquals(200);
}
@ -99,7 +93,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
'label' => 'Test View Mode',
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains('Saved the ' . $edit['label'] . ' view mode.');
$this->drupalLogin($this->adminUser);
@ -111,10 +105,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->submitForm($edit, 'Save');
// Check that the Basic block has been created.
$this->assertRaw(new FormattableMarkup('@block %name has been created.', [
'@block' => 'basic',
'%name' => $edit['info[0][value]'],
]));
$this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
// Save our block permanently
$this->submitForm(['region' => 'content'], 'Save block');
@ -167,9 +158,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->submitForm($edit, 'Save');
// Check that the Basic block has been created.
$this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [
'%value' => $edit['info[0][value]'],
]));
$this->assertSession()->pageTextContains('A custom block with block description ' . $edit['info[0][value]'] . ' already exists.');
$this->assertSession()->statusCodeEquals(200);
}
@ -188,10 +177,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->submitForm($edit, 'Save');
// Check that the block has been created and that it is a basic block.
$this->assertRaw(new FormattableMarkup('@block %name has been created.', [
'@block' => 'basic',
'%name' => $edit['info[0][value]'],
]));
$this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
// Check that the block exists in the database.
$blocks = \Drupal::entityTypeManager()
@ -262,7 +248,7 @@ class BlockContentCreationTest extends BlockContentTestBase {
$this->assertSession()->pageTextContains('This will also remove 1 placed block instance.');
$this->submitForm([], 'Delete');
$this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']]));
$this->assertSession()->pageTextContains('The custom block ' . $edit['info[0][value]'] . ' has been deleted.');
// Create another block and force the plugin cache to flush.
$edit2 = [];

View File

@ -34,7 +34,7 @@ class BlockContentPageViewTest extends BlockContentTestBase {
// Ensure user was able to view the block.
$this->assertSession()->statusCodeEquals(200);
$this->drupalGet('<front>');
$this->assertRaw(t('This block is broken or missing. You may be missing content or you might need to enable the original module.'));
$this->assertSession()->pageTextContains('This block is broken or missing. You may be missing content or you might need to enable the original module.');
}
}

View File

@ -145,13 +145,7 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase {
$options = ['language' => $languages[$langcode]];
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('<em>Edit @type</em> @title [%language translation]', [
'@type' => $entity->bundle(),
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
]);
$this->assertRaw($title);
$this->assertSession()->pageTextContains("Edit {$entity->bundle()} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
}
}
}

View File

@ -175,18 +175,14 @@ class BlockContentTypeTest extends BlockContentTestBase {
$block = $this->createBlockContent(FALSE, 'foo');
// Attempt to delete the block type, which should not be allowed.
$this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
$this->assertRaw(
t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', ['%label' => $type->label()])
);
$this->assertSession()->pageTextContains($type->label() . ' is used by 1 custom block on your site. You can not remove this block type until you have removed all of the ' . $type->label() . ' blocks.');
$this->assertSession()->pageTextNotContains('This action cannot be undone.');
// Delete the block.
$block->delete();
// Attempt to delete the block type, which should now be allowed.
$this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete');
$this->assertRaw(
t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()])
);
$this->assertSession()->pageTextContains('Are you sure you want to delete the custom block type ' . $type->id() . '?');
$this->assertSession()->pageTextContains('This action cannot be undone.');
}

View File

@ -459,7 +459,7 @@ class BookTest extends BrowserTestBase {
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$this->drupalGet($this->book->toUrl('delete-form'));
$this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
$this->assertSession()->pageTextContains($this->book->label() . ' is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.');
// Delete parent, and visit a child page.
$this->drupalGet($this->book->toUrl('delete-form'));
$this->submitForm([], 'Delete');
@ -489,7 +489,7 @@ class BookTest extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertSession()->pageTextContains('Book outline');
// Verify that the node does not belong to a book.
$this->assertTrue($this->assertSession()->optionExists('edit-book-bid', 0)->isSelected());
$this->assertSession()->linkNotExists('Remove from book outline');
@ -512,9 +512,9 @@ class BookTest extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertSession()->pageTextContains('Book outline');
$this->clickLink('Remove from book outline');
$this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()]));
$this->assertSession()->pageTextContains('Are you sure you want to remove ' . $book->label() . ' from the book hierarchy?');
// Create a new node and set the book after the node was created.
$node = $this->drupalCreateNode(['type' => 'book']);

View File

@ -77,7 +77,7 @@ class CKEditorAdminTest extends BrowserTestBase {
'editor[editor]' => 'ckeditor',
];
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('You must configure the selected text editor.'));
$this->assertSession()->pageTextContains('You must configure the selected text editor.');
// Ensure the CKEditor editor returns the expected default settings.
$expected_default_settings = [

View File

@ -95,7 +95,7 @@ class CKEditorStylesComboAdminTest extends BrowserTestBase {
'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Title\n\n",
];
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('Each style must have a unique label.'));
$this->assertSession()->pageTextContains('Each style must have a unique label.');
$editor = Editor::load($this->format);
$this->assertEquals($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
}

View File

@ -80,9 +80,7 @@ class CommentAnonymousTest extends CommentTestBase {
];
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
'%name' => $this->adminUser->getAccountName(),
]));
$this->assertSession()->pageTextContains('The name you used (' . $this->adminUser->getAccountName() . ') belongs to a registered user.');
// Allow contact info.
$this->drupalLogin($this->adminUser);
@ -114,9 +112,7 @@ class CommentAnonymousTest extends CommentTestBase {
];
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('The name you used (%name) belongs to a registered user.', [
'%name' => $this->adminUser->getAccountName(),
]));
$this->assertSession()->pageTextContains('The name you used (' . $this->adminUser->getAccountName() . ') belongs to a registered user.');
// Require contact info.
$this->drupalLogin($this->adminUser);

View File

@ -239,7 +239,7 @@ class CommentNonNodeTest extends BrowserTestBase {
if ($operation == 'delete') {
$this->submitForm([], 'Delete');
$this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'));
$this->assertSession()->pageTextContains('Deleted 1 comment.');
}
else {
$this->assertSession()->pageTextContains('The update has been performed.');

View File

@ -45,7 +45,7 @@ class CommentPagerTest extends CommentTestBase {
// Check the first page of the node, and confirm the correct comments are
// shown.
$this->drupalGet('node/' . $node->id());
$this->assertRaw(t('next'));
$this->assertSession()->pageTextContains('next');
$this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page 1.');
$this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 1.');
$this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 1.');
@ -382,7 +382,7 @@ class CommentPagerTest extends CommentTestBase {
// Check the first page of the node, and confirm the correct comments are
// shown.
$this->drupalGet('node/' . $node->id());
$this->assertRaw(t('next'));
$this->assertSession()->pageTextContains('next');
$this->assertRaw('Comment 1 on field comment');
$this->assertRaw('Comment 1 on field comment_2');
// Navigate to next page of field 1.

View File

@ -367,7 +367,7 @@ abstract class CommentTestBase extends BrowserTestBase {
if ($operation == 'delete') {
$this->submitForm([], 'Delete');
$this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'));
$this->assertSession()->pageTextContains('Deleted 1 comment.');
}
else {
$this->assertSession()->pageTextContains('The update has been performed.');

View File

@ -229,13 +229,7 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
$options = ['language' => $languages[$langcode]];
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('Edit @type @title [%language translation]', [
'@type' => $this->entityTypeId,
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
]);
$this->assertRaw($title);
$this->assertSession()->pageTextContains("Edit {$this->entityTypeId} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
}
}
}

View File

@ -161,15 +161,8 @@ class CommentTypeTest extends CommentTestBase {
// Attempt to delete the comment type, which should not be allowed.
$this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
$this->assertRaw(
t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', ['%label' => $type->label()])
);
$this->assertRaw(
t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [
'%label' => 'foo',
'%field' => 'node.foo',
])
);
$this->assertSession()->pageTextContains($type->label() . ' is used by 1 comment on your site. You can not remove this comment type until you have removed all of the ' . $type->label() . ' comments.');
$this->assertSession()->pageTextContains('foo is used by the node.foo field on your site. You can not remove this comment type until you have removed the field.');
$this->assertSession()->pageTextNotContains('This action cannot be undone.');
// Delete the comment and the field.
@ -177,9 +170,7 @@ class CommentTypeTest extends CommentTestBase {
$field_storage->delete();
// Attempt to delete the comment type, which should now be allowed.
$this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
$this->assertRaw(
t('Are you sure you want to delete the comment type %type?', ['%type' => $type->id()])
);
$this->assertSession()->pageTextContains('Are you sure you want to delete the comment type ' . $type->id() . '?');
$this->assertSession()->pageTextContains('This action cannot be undone.');
// Test exception thrown when re-using an existing comment type.
@ -195,7 +186,7 @@ class CommentTypeTest extends CommentTestBase {
$this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete');
$this->submitForm([], 'Delete');
$this->assertNull(CommentType::load($type->id()), 'Comment type deleted.');
$this->assertRaw(t('The comment type %label has been deleted.', ['%label' => $type->label()]));
$this->assertSession()->pageTextContains('The comment type ' . $type->label() . ' has been deleted.');
}
}

View File

@ -234,9 +234,9 @@ class ConfigEntityTest extends BrowserTestBase {
$label1 = $this->randomMachineName();
$label2 = $this->randomMachineName();
$label3 = $this->randomMachineName();
$message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $label1]);
$message_update = new FormattableMarkup('%label configuration has been updated.', ['%label' => $label2]);
$message_delete = new FormattableMarkup('The test configuration %label has been deleted.', ['%label' => $label2]);
$message_insert = "$label1 configuration has been created.";
$message_update = "$label2 configuration has been updated.";
$message_delete = "The test configuration $label2 has been deleted.";
// Create a configuration entity.
$edit = [
@ -247,8 +247,8 @@ class ConfigEntityTest extends BrowserTestBase {
$this->submitForm($edit, 'Save');
$this->assertSession()->addressEquals('admin/structure/config_test');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw($message_insert);
$this->assertNoRaw($message_update);
$this->assertSession()->pageTextContains($message_insert);
$this->assertSession()->pageTextNotContains($message_update);
$this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id");
// Update the configuration entity.
@ -259,8 +259,8 @@ class ConfigEntityTest extends BrowserTestBase {
$this->submitForm($edit, 'Save');
$this->assertSession()->addressEquals('admin/structure/config_test');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw($message_insert);
$this->assertRaw($message_update);
$this->assertSession()->pageTextNotContains($message_insert);
$this->assertSession()->pageTextContains($message_update);
$this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id");
$this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id/delete");
@ -271,8 +271,8 @@ class ConfigEntityTest extends BrowserTestBase {
$this->submitForm([], 'Delete');
$this->assertSession()->addressEquals('admin/structure/config_test');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw($message_update);
$this->assertRaw($message_delete);
$this->assertSession()->pageTextNotContains($message_update);
$this->assertSession()->pageTextContains($message_delete);
$this->assertSession()->pageTextNotContains($label1);
$this->assertSession()->linkByHrefNotExists("admin/structure/config_test/manage/$id");
@ -312,8 +312,7 @@ class ConfigEntityTest extends BrowserTestBase {
$this->drupalGet('admin/structure/config_test/add');
$this->submitForm($edit, 'Save');
$this->assertSession()->statusCodeEquals(200);
$message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $edit['label']]);
$this->assertRaw($message_insert);
$this->assertSession()->pageTextContains('0 configuration has been created.');
$this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/0');
$this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/0/delete');
$this->drupalGet('admin/structure/config_test/manage/0/delete');

View File

@ -471,8 +471,8 @@ class ConfigImportUITest extends BrowserTestBase {
// and the node type, body field and entity displays are still scheduled for
// removal.
$this->submitForm([], 'Import all');
$validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]);
$this->assertRaw($validation_message);
$validation_message = "Entities exist of type {$node->getEntityType()->getLabel()} and {$node->getEntityType()->getBundleLabel()} {$node_type->label()}. These entities need to be deleted before importing.";
$this->assertSession()->pageTextContains($validation_message);
$this->assertSession()->pageTextContains('node.type.' . $node_type->id());
$this->assertSession()->pageTextContains('field.field.node.' . $node_type->id() . '.body');
$this->assertSession()->pageTextContains('core.entity_view_display.node.' . $node_type->id() . '.teaser');
@ -482,7 +482,7 @@ class ConfigImportUITest extends BrowserTestBase {
// Delete the node and try to import again.
$node->delete();
$this->submitForm([], 'Import all');
$this->assertNoRaw($validation_message);
$this->assertSession()->pageTextNotContains($validation_message);
$this->assertSession()->pageTextContains('There are no configuration changes to import.');
$this->assertSession()->pageTextNotContains('node.type.' . $node_type->id());
$this->assertSession()->pageTextNotContains('field.field.node.' . $node_type->id() . '.body');

View File

@ -60,7 +60,7 @@ class ConfigImportUploadTest extends BrowserTestBase {
$directory = Settings::get('config_sync_directory');
\Drupal::service('file_system')->chmod($directory, 0555);
$this->drupalGet('admin/config/development/configuration/full/import');
$this->assertRaw(t('The directory %directory is not writable.', ['%directory' => $directory]));
$this->assertSession()->pageTextContains("The directory $directory is not writable.");
// Ensure submit button for \Drupal\config\Form\ConfigImportForm is
// disabled.
$submit_is_disabled = $this->cssSelect('form.config-import-form input[type="submit"]:disabled');

View File

@ -234,7 +234,7 @@ class ConfigInstallWebTest extends BrowserTestBase {
// Ignore failed deletes.
}
$this->drupalGet('/admin/reports/status');
$this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory]));
$this->assertSession()->pageTextContains("The directory $directory does not exist.");
}
}

View File

@ -77,13 +77,13 @@ EOD;
$edit['import'] = "id: first\n" . $edit['import'];
$this->drupalGet('admin/config/development/configuration/single/import');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration']));
$this->assertSession()->pageTextContains('Are you sure you want to create a new first test configuration?');
$this->submitForm([], 'Confirm');
$entity = $storage->load('first');
$this->assertSame('First', $entity->label());
$this->assertSame('first', $entity->id());
$this->assertTrue($entity->status());
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertSession()->pageTextContains('The configuration was imported successfully.');
// Attempt an import with an existing ID but missing UUID.
$this->drupalGet('admin/config/development/configuration/single/import');
@ -100,9 +100,9 @@ EOD;
$edit['custom_entity_id'] = 'custom_id';
$this->drupalGet('admin/config/development/configuration/single/import');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration']));
$this->assertSession()->pageTextContains('Are you sure you want to create a new custom_id test configuration?');
$this->submitForm([], 'Confirm');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertSession()->pageTextContains('The configuration was imported successfully.');
// Perform an import with a unique ID and UUID.
$import = <<<EOD
@ -120,10 +120,10 @@ EOD;
$edit['import'] .= "\nuuid: " . $second_uuid;
$this->drupalGet('admin/config/development/configuration/single/import');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
$this->assertSession()->pageTextContains('Are you sure you want to create a new second test configuration?');
$this->submitForm([], 'Confirm');
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertSession()->pageTextContains('The configuration was imported successfully.');
$this->assertSame('Second', $entity->label());
$this->assertSame('second', $entity->id());
$this->assertFalse($entity->status());
@ -144,10 +144,10 @@ EOD;
];
$this->drupalGet('admin/config/development/configuration/single/import');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration']));
$this->assertSession()->pageTextContains('Are you sure you want to update the second test configuration?');
$this->submitForm([], 'Confirm');
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertSession()->pageTextContains('The configuration was imported successfully.');
$this->assertSame('Second updated', $entity->label());
// Try to perform an update which adds missing dependencies.
@ -168,7 +168,7 @@ EOD;
];
$this->drupalGet('admin/config/development/configuration/single/import');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist']));
$this->assertSession()->pageTextContains('Configuration config_test.dynamic.second depends on the does_not_exist module that will not be installed after import.');
// Try to preform an update which would create a PHP object if Yaml parsing
// not securely set up.
@ -190,13 +190,10 @@ EOD;
if (extension_loaded('yaml')) {
// If the yaml extension is loaded it will work but not create the PHP
// object.
$this->assertRaw(t('Are you sure you want to update the %name @type?', [
'%name' => 'second',
'@type' => 'test configuration',
]));
$this->assertSession()->pageTextContains('Are you sure you want to update the second test configuration?');
$this->submitForm([], 'Confirm');
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertSession()->pageTextContains('The configuration was imported successfully.');
$this->assertIsString($entity->label());
$this->assertStringContainsString('ObjectSerialization', $entity->label(), 'Label contains serialized object');
}
@ -224,7 +221,7 @@ EOD;
];
$this->drupalGet('admin/config/development/configuration/single/import');
$this->submitForm($edit, 'Import');
$this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration']));
$this->assertSession()->pageTextContains('Are you sure you want to update the ' . $config->getName() . ' simple configuration?');
$this->submitForm([], 'Confirm');
$this->drupalGet('');
$this->assertSession()->pageTextContains('Test simple import');

View File

@ -374,7 +374,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
$this->drupalGet('admin/config/media/responsive-image-style/add');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("Responsive image style {$edit['label']} saved.");
// Get the responsive image style listing.
$this->drupalGet('admin/config/media/responsive-image-style');

View File

@ -172,7 +172,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
$this->drupalGet("{$translation_base_url}/fr/add");
$this->submitForm($edit, 'Save translation');
$this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
$this->assertSession()->pageTextContains('Successfully saved French translation.');
// Check for edit, delete links (and no 'add' link) for French language.
$this->assertSession()->linkByHrefNotExists("$translation_base_url/fr/add");
@ -274,7 +274,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
];
$this->submitForm($edit, 'Save translation');
$this->assertRaw(t('Successfully updated @language translation.', ['@language' => 'French']));
$this->assertSession()->pageTextContains('Successfully updated French translation.');
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
// Expect only slogan in language specific file.
@ -417,12 +417,12 @@ class ConfigTranslationUiTest extends BrowserTestBase {
$replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => mb_strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()];
$this->drupalGet("$translation_base_url/$langcode/delete");
$this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
$this->assertSession()->responseContains(t('Are you sure you want to delete the @language translation of %label?', $replacements));
// Assert link back to list page to cancel delete is present.
$this->assertSession()->linkByHrefExists($translation_base_url);
$this->submitForm([], 'Delete');
$this->assertRaw(t('@language translation of %label was deleted', $replacements));
$this->assertSession()->responseContains(t('@language translation of %label was deleted', $replacements));
$this->assertSession()->linkByHrefExists("$translation_base_url/$langcode/add");
$this->assertSession()->linkByHrefNotExists("translation_base_url/$langcode/edit");
$this->assertSession()->linkByHrefNotExists("$translation_base_url/$langcode/delete");
@ -628,7 +628,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
];
$this->drupalGet("{$translation_base_url}/fr/add");
$this->submitForm($edit, 'Save translation');
$this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
$this->assertSession()->pageTextContains('Successfully saved French translation.');
// Check for edit, delete links (and no 'add' link) for French language.
$this->assertSession()->linkByHrefNotExists("$translation_base_url/fr/add");
@ -878,7 +878,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
// Delete French language
$this->drupalGet('admin/config/regional/language/delete/fr');
$this->submitForm([], 'Delete');
$this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr']));
$this->assertSession()->pageTextContains('The French (fr) language has been removed.');
// Change default language to Tamil.
$edit = [
@ -886,12 +886,12 @@ class ConfigTranslationUiTest extends BrowserTestBase {
];
$this->drupalGet('admin/config/regional/language');
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('Configuration saved.'));
$this->assertSession()->pageTextContains('Configuration saved.');
// Delete English language
$this->drupalGet('admin/config/regional/language/delete/en');
$this->submitForm([], 'Delete');
$this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
$this->assertSession()->pageTextContains('The English (en) language has been removed.');
// Visit account setting translation page, this should not
// throw any notices.
@ -1156,7 +1156,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
];
$this->drupalGet('admin/config/system/site-information');
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('The configuration options have been saved.'));
$this->assertSession()->pageTextContains('The configuration options have been saved.');
}
/**

View File

@ -110,7 +110,7 @@ class ContactPersonalTest extends BrowserTestBase {
// Verify that the correct watchdog message has been logged.
$this->drupalGet('/admin/reports/dblog');
$placeholders = [
'@sender_name' => $this->webUser->username,
'@sender_name' => $this->webUser->getAccountName(),
'@sender_email' => $this->webUser->getEmail(),
'@recipient_name' => $this->contactUser->getAccountName(),
];
@ -142,7 +142,7 @@ class ContactPersonalTest extends BrowserTestBase {
$this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertSession()->statusCodeEquals(200);
// Check the page title is properly displayed.
$this->assertRaw(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()]));
$this->assertSession()->pageTextContains('Contact ' . $this->adminUser->getDisplayName());
// Test denied access to admin user's own contact form.
$this->drupalLogout();
@ -272,7 +272,8 @@ class ContactPersonalTest extends BrowserTestBase {
// Submit contact form one over limit.
$this->submitPersonalContact($this->contactUser);
// Normal user should be denied access to flooded contact form.
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', ['%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))]));
$interval = \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'));
$this->assertSession()->pageTextContains("You cannot send more than 3 messages in {$interval}. Try again later.");
// Test that the admin user can still access the contact form even though
// the flood limit was reached.

View File

@ -154,7 +154,7 @@ class ContactSitewideTest extends BrowserTestBase {
$invalid_recipients = ['invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'];
foreach ($invalid_recipients as $invalid_recipient) {
$this->addContactForm($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE);
$this->assertRaw(t('%recipient is an invalid email address.', ['%recipient' => $invalid_recipient]));
$this->assertSession()->pageTextContains($invalid_recipient . ' is an invalid email address.');
}
// Test validation of empty form and recipients fields.
@ -227,7 +227,7 @@ class ContactSitewideTest extends BrowserTestBase {
// Try adding a form that already exists.
$this->addContactForm($name, $label, '', '', FALSE);
$this->assertSession()->pageTextNotContains("Contact form $label has been added.");
$this->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
$this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
$this->drupalLogout();
@ -249,7 +249,7 @@ class ContactSitewideTest extends BrowserTestBase {
$this->assertSession()->pageTextContains('Your email address field is required.');
$this->submitContact($this->randomMachineName(16), $invalid_recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
$this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
$this->assertSession()->pageTextContains('The email address invalid is not valid.');
$this->submitContact($this->randomMachineName(16), $recipients[0], '', $id, $this->randomMachineName(64));
$this->assertSession()->pageTextContains('Subject field is required.');
@ -277,7 +277,7 @@ class ContactSitewideTest extends BrowserTestBase {
}
// Submit contact form one over limit.
$this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64));
$this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', ['%number' => $this->config('contact.settings')->get('flood.limit')]));
$this->assertSession()->pageTextContains('You cannot send more than ' . $this->config('contact.settings')->get('flood.limit') . ' messages in 10 min. Try again later.');
// Test listing controller.
$this->drupalLogin($admin_user);
@ -606,7 +606,7 @@ class ContactSitewideTest extends BrowserTestBase {
else {
$this->drupalGet("admin/structure/contact/manage/{$id}/delete");
$this->submitForm([], 'Delete');
$this->assertRaw(t('The contact form %label has been deleted.', ['%label' => $contact_form->label()]));
$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()]));
}
}

View File

@ -128,7 +128,7 @@ class ContentTranslationContextualLinksTest extends BrowserTestBase {
$this->drupalLogin($this->translator);
$translate_link = 'node/' . $node->id() . '/translations';
$this->drupalGet($translate_link);
$this->assertRaw(t('Translations of %label', ['%label' => $node->label()]));
$this->assertSession()->pageTextContains('Translations of ' . $node->label());
}
}

View File

@ -474,7 +474,7 @@ class DbLogTest extends BrowserTestBase {
$link = mb_substr($value, strpos($value, 'admin/reports/dblog/event/'));
$this->drupalGet($link);
// Check for full message text on the details page.
$this->assertRaw($message);
$this->assertSession()->responseContains($message);
}
$this->assertNotEmpty($link, 'DBLog event was recorded: [delete user]');
// Visit random URL (to generate page not found event).

View File

@ -138,7 +138,7 @@ class FormTest extends FieldTestBase {
"{$field_name}[0][value]" => -1,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name does not accept the value -1.', ['%name' => $this->field['label']]));
$this->assertSession()->pageTextContains("{$this->field['label']} does not accept the value -1.");
// TODO : check that the correct field is flagged for error.
// Create an entity
@ -233,7 +233,7 @@ class FormTest extends FieldTestBase {
$edit = [];
$this->drupalGet('entity_test/add');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]));
$this->assertSession()->pageTextContains("{$this->field['label']} field is required.");
// Create an entity
$value = mt_rand(1, 127);
@ -254,7 +254,7 @@ class FormTest extends FieldTestBase {
];
$this->drupalGet('entity_test/manage/' . $id . '/edit');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('@name field is required.', ['@name' => $this->field['label']]));
$this->assertSession()->pageTextContains("{$this->field['label']} field is required.");
}
public function testFieldFormUnlimited() {
@ -465,7 +465,7 @@ class FormTest extends FieldTestBase {
// Submit the form with more values than the field accepts.
$edit = [$field_name => '1, 2, 3, 4, 5'];
$this->submitForm($edit, 'Save');
$this->assertRaw('this field cannot hold more than 4 values');
$this->assertSession()->pageTextContains('this field cannot hold more than 4 values');
// Check that the field values were not submitted.
$this->assertFieldValues($entity_init, $field_name, [1, 2, 3]);

View File

@ -129,7 +129,7 @@ class NestedFormTest extends FieldTestBase {
];
$this->drupalGet('test-entity/nested/1/2');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']));
$this->assertSession()->pageTextContains("Unlimited field does not accept the value -1.");
// Entity 1: check that the error was flagged on the correct element.
$error_field = $this->assertSession()->fieldExists('edit-field-unlimited-1-value');
$this->assertTrue($error_field->hasClass('error'));
@ -138,7 +138,7 @@ class NestedFormTest extends FieldTestBase {
];
$this->drupalGet('test-entity/nested/1/2');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%label does not accept the value -1', ['%label' => 'Unlimited field']));
$this->assertSession()->pageTextContains("Unlimited field does not accept the value -1.");
// Entity 2: check that the error was flagged on the correct element.
$error_field = $this->assertSession()->fieldExists('edit-entity-2-field-unlimited-1-value');
$this->assertTrue($error_field->hasClass('error'));

View File

@ -104,7 +104,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => $wrong_entry,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
$this->assertSession()->pageTextContains("{$field_name} must be a number.");
}
// Try to create entries with minus sign not in the first position.
@ -122,7 +122,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => $wrong_entry,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
$this->assertSession()->pageTextContains("{$field_name} must be a number.");
}
}
@ -209,7 +209,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => $minimum - 1,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be higher than or equal to %minimum.', ['%name' => $field_name, '%minimum' => $minimum]));
$this->assertSession()->pageTextContains("{$field_name} must be higher than or equal to {$minimum}.");
// Try to set a decimal value
$this->drupalGet('entity_test/add');
@ -217,7 +217,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => 1.5,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name is not a valid number.', ['%name' => $field_name]));
$this->assertSession()->pageTextContains("{$field_name} is not a valid number.");
// Try to set a value above the maximum value
$this->drupalGet('entity_test/add');
@ -225,7 +225,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => $maximum + 1,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be lower than or equal to %maximum.', ['%name' => $field_name, '%maximum' => $maximum]));
$this->assertSession()->pageTextContains("{$field_name} must be lower than or equal to {$maximum}.");
// Try to set a wrong integer value.
$this->drupalGet('entity_test/add');
@ -233,7 +233,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => '20-40',
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
$this->assertSession()->pageTextContains("{$field_name} must be a number.");
// Test with valid entries.
$valid_entries = [
@ -352,7 +352,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => $wrong_entry,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
$this->assertSession()->pageTextContains("{$field_name} must be a number.");
}
// Try to create entries with minus sign not in the first position.
@ -370,7 +370,7 @@ class NumberFieldTest extends BrowserTestBase {
"{$field_name}[0][value]" => $wrong_entry,
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('%name must be a number.', ['%name' => $field_name]));
$this->assertSession()->pageTextContains("{$field_name} must be a number.");
}
}
@ -437,9 +437,9 @@ class NumberFieldTest extends BrowserTestBase {
$this->drupalGet($field_configuration_url);
$this->submitForm($edit, 'Save settings');
// Check if an error message is shown.
$this->assertNoRaw(t('%name is not a valid number.', ['%name' => t('Minimum')]));
$this->assertSession()->pageTextNotContains("Minimum is not a valid number.");
// Check if a success message is shown.
$this->assertRaw(t('Saved %label configuration.', ['%label' => $field->getLabel()]));
$this->assertSession()->pageTextContains("Saved {$field->getLabel()} configuration.");
// Check if the minimum value was actually set.
$this->drupalGet($field_configuration_url);
$this->assertSession()->fieldValueEquals('edit-settings-min', $minimum_value);

View File

@ -77,7 +77,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
'label' => $this->randomString(),
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("Saved the {$edit['label']} view mode.");
// Test editing the view mode.
$this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']);
@ -92,9 +92,9 @@ class EntityDisplayModeTest extends BrowserTestBase {
// Test deleting the view mode.
$this->clickLink('Delete');
$this->assertRaw(t('Are you sure you want to delete the view mode %label?', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the view mode {$edit['label']}?");
$this->submitForm([], 'Delete');
$this->assertRaw(t('The view mode %label has been deleted.', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("The view mode {$edit['label']} has been deleted.");
}
/**
@ -131,7 +131,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
'label' => $this->randomString(),
];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('Saved the %label form mode.', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("Saved the {$edit['label']} form mode.");
// Test editing the form mode.
$this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']);
@ -146,9 +146,9 @@ class EntityDisplayModeTest extends BrowserTestBase {
// Test deleting the form mode.
$this->clickLink('Delete');
$this->assertRaw(t('Are you sure you want to delete the form mode %label?', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the form mode {$edit['label']}?");
$this->submitForm([], 'Delete');
$this->assertRaw(t('The form mode %label has been deleted.', ['%label' => $edit['label']]));
$this->assertSession()->pageTextContains("The form mode {$edit['label']} has been deleted.");
}
/**

View File

@ -211,7 +211,8 @@ class ManageDisplayTest extends BrowserTestBase {
])->save();
$this->drupalGet('admin/structure/types/manage/no_fields/display');
$this->assertRaw(t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => Url::fromRoute('entity.node.field_ui_fields', ['node_type' => 'no_fields'])->toString()]));
$this->assertSession()->pageTextContains("There are no fields yet added. You can add new fields on the Manage fields page.");
$this->assertSession()->linkByHrefExists(Url::fromRoute('entity.node.field_ui_fields', ['node_type' => 'no_fields'])->toString());
}
/**

View File

@ -255,7 +255,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
public function addExistingField() {
// Check "Re-use existing field" appears.
$this->drupalGet('admin/structure/types/manage/page/fields/add-field');
$this->assertRaw(t('Re-use an existing field'));
$this->assertSession()->pageTextContains('Re-use an existing field');
// Check that fields of other entity types (here, the 'comment_body' field)
// do not show up in the "Re-use existing field" list.
@ -317,7 +317,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
];
$this->drupalGet($field_edit_path);
$this->submitForm($edit, 'Save field settings');
$this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 2]));
$this->assertSession()->pageTextContains("There is 1 entity with 2 or more values in this field.");
// Create a second entity with three values.
$edit = ['title[0][value]' => 'Cardinality 3', 'body[0][value]' => 'Body 1', 'body[1][value]' => 'Body 2', 'body[2][value]' => 'Body 3'];
@ -343,7 +343,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
];
$this->drupalGet($field_edit_path);
$this->submitForm($edit, 'Save field settings');
$this->assertRaw(t('There are @count entities with @delta or more values in this field.', ['@count' => 2, '@delta' => 2]));
$this->assertSession()->pageTextContains("There are 2 entities with 2 or more values in this field.");
$edit = [
'cardinality' => 'number',
@ -351,7 +351,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
];
$this->drupalGet($field_edit_path);
$this->submitForm($edit, 'Save field settings');
$this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 3]));
$this->assertSession()->pageTextContains("There is 1 entity with 3 or more values in this field.");
$edit = [
'cardinality' => 'number',
@ -389,14 +389,14 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
];
$this->drupalGet($field_edit_path);
$this->submitForm($edit, 'Save field settings');
$this->assertRaw(t('There are @count entities with @delta or more values in this field.', ['@count' => 2, '@delta' => 3]));
$this->assertSession()->pageTextContains("There are 2 entities with 3 or more values in this field.");
$edit = [
'cardinality' => 'number',
'cardinality_number' => 3,
];
$this->drupalGet($field_edit_path);
$this->submitForm($edit, 'Save field settings');
$this->assertRaw(t('There is @count entity with @delta or more values in this field.', ['@count' => 1, '@delta' => 4]));
$this->assertSession()->pageTextContains("There is 1 entity with 4 or more values in this field.");
$edit = [
'cardinality' => 'number',
'cardinality_number' => 4,
@ -432,7 +432,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
}
// Check "Re-use existing field" appears.
$this->drupalGet('admin/structure/types/manage/page/fields/add-field');
$this->assertRaw(t('Re-use an existing field'));
$this->assertSession()->pageTextContains("Re-use an existing field");
// Ensure that we test with a label that contains HTML.
$label = $this->randomString(4) . '<br/>' . $this->randomString(4);

View File

@ -48,17 +48,17 @@ trait FieldUiTestTrait {
$this->drupalGet($bundle_path);
}
$this->submitForm($initial_edit, 'Save and continue');
$this->assertRaw(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label]));
$this->assertSession()->pageTextContains("These settings apply to the $label field everywhere it is used.");
// Test Breadcrumbs.
$this->assertSession()->linkExists($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
// Second step: 'Storage settings' form.
$this->submitForm($storage_edit, 'Save field settings');
$this->assertRaw(t('Updated field %label field settings.', ['%label' => $label]));
$this->assertSession()->pageTextContains("Updated field $label field settings.");
// Third step: 'Field settings' form.
$this->submitForm($field_edit, 'Save settings');
$this->assertRaw(t('Saved %label configuration.', ['%label' => $label]));
$this->assertSession()->pageTextContains("Saved $label configuration.");
// Check that the field appears in the overview form.
$xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [
@ -99,7 +99,7 @@ trait FieldUiTestTrait {
// Second step: 'Field settings' form.
$this->submitForm($field_edit, 'Save settings');
$this->assertRaw(t('Saved %label configuration.', ['%label' => $label]));
$this->assertSession()->pageTextContains("Saved $label configuration.");
// Check that the field appears in the overview form.
$xpath = $this->assertSession()->buildXPathQuery("//table[@id=\"field-overview\"]//tr/td[1 and text() = :label]", [
@ -123,14 +123,14 @@ trait FieldUiTestTrait {
public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) {
// Display confirmation form.
$this->drupalGet("$bundle_path/fields/$field_name/delete");
$this->assertRaw(t('Are you sure you want to delete the field %label', ['%label' => $label]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the field $label");
// Test Breadcrumbs.
$this->assertSession()->linkExists($label, 0, 'Field label is correct in the breadcrumb of the field delete page.');
// Submit confirmation form.
$this->submitForm([], 'Delete');
$this->assertRaw(t('The field %label has been deleted from the %type content type.', ['%label' => $label, '%type' => $bundle_label]));
$this->assertSession()->pageTextContains("The field $label has been deleted from the $bundle_label content type.");
// Check that the field does not appear in the overview form.
$xpath = $this->assertSession()->buildXPathQuery('//table[@id="field-overview"]//span[@class="label-field" and text()= :label]', [

View File

@ -37,7 +37,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalGet('node/add/' . $type_name);
$this->submitForm($edit, 'Save');
$this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]));
$this->assertSession()->pageTextContains("{$field->getLabel()} field is required.");
// Create a new node with the uploaded file.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@ -59,7 +59,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalGet('node/add/' . $type_name);
$this->submitForm($edit, 'Save');
$this->assertRaw(t('@title field is required.', ['@title' => $field->getLabel()]));
$this->assertSession()->pageTextContains("{$field->getLabel()} field is required.");
// Create a new node with the uploaded file into the multivalue field.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@ -105,8 +105,9 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Check that uploading the large file fails (1M limit).
$this->uploadNodeFile($large_file, $field_name, $type_name);
$error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', ['%filesize' => format_size($large_file->getSize()), '%maxsize' => format_size($file_limit)]);
$this->assertRaw($error_message);
$filesize = format_size($large_file->getSize());
$maxsize = format_size($file_limit);
$this->assertSession()->pageTextContains("The file is {$filesize} exceeding the maximum file size of {$maxsize}.");
}
// Turn off the max filesize.
@ -149,8 +150,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Check that the file with the wrong extension cannot be uploaded.
$this->uploadNodeFile($test_file, $field_name, $type_name);
$error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
$this->assertRaw($error_message);
$this->assertSession()->pageTextContains("Only files with the following extensions are allowed: txt.");
// Enable extension checking for text and image files.
$this->updateFileField($field_name, $type_name, ['file_extensions' => "txt $test_file_extension"]);

View File

@ -377,13 +377,12 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$edit[$name] = \Drupal::service('file_system')->realpath($test_file_image->getFileUri());
$this->submitForm($edit, 'Upload');
$error_message = t('Only files with the following extensions are allowed: %files-allowed.', ['%files-allowed' => 'txt']);
$this->assertRaw($error_message);
$this->assertSession()->pageTextContains("Only files with the following extensions are allowed: txt.");
// Upload file with correct extension, check that error message is removed.
$edit[$name] = \Drupal::service('file_system')->realpath($test_file_text->getFileUri());
$this->submitForm($edit, 'Upload');
$this->assertNoRaw($error_message);
$this->assertSession()->pageTextNotContains("Only files with the following extensions are allowed: txt.");
}
/**

View File

@ -40,7 +40,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
// Submit without a file.
$this->drupalGet($path);
$this->submitForm([], 'Save');
$this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [])]));
$this->assertSession()->pageTextContains("The file ids are .");
// Submit with a file, but with an invalid form token. Ensure the file
// was not saved.
@ -63,12 +63,12 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$this->submitForm($edit, 'Save');
$last_fid = $this->getLastFileId();
$this->assertGreaterThan($last_fid_prior, $last_fid, 'New file got saved.');
$this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]));
$this->assertSession()->pageTextContains("The file ids are $last_fid.");
// Submit no new input, but with a default file.
$this->drupalGet($path . '/' . $last_fid);
$this->submitForm([], 'Save');
$this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]));
$this->assertSession()->pageTextContains("The file ids are $last_fid.");
// Upload, then Submit.
$last_fid_prior = $this->getLastFileId();
@ -78,7 +78,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$last_fid = $this->getLastFileId();
$this->assertGreaterThan($last_fid_prior, $last_fid, 'New file got uploaded.');
$this->submitForm([], 'Save');
$this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', [$last_fid])]));
$this->assertSession()->pageTextContains("The file ids are $last_fid.");
// Remove, then Submit.
$remove_button_title = $multiple ? 'Remove selected' : 'Remove';
@ -90,7 +90,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$this->drupalGet($path . '/' . $last_fid);
$this->submitForm($remove_edit, $remove_button_title);
$this->submitForm([], 'Save');
$this->assertRaw(t('The file ids are %fids.', ['%fids' => '']));
$this->assertSession()->pageTextContains("The file ids are .");
// Upload, then Remove, then Submit.
$this->drupalGet($path);
@ -104,7 +104,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
$this->submitForm($remove_edit, $remove_button_title);
$this->submitForm([], 'Save');
$this->assertRaw(t('The file ids are %fids.', ['%fids' => '']));
$this->assertSession()->pageTextContains("The file ids are .");
}
}
}
@ -129,7 +129,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
// Save the entire form.
$this->submitForm([], 'Save');
// Check that two files are saved into a single multiple file element.
$this->assertRaw(t('The file ids are %fids.', ['%fids' => implode(',', $fid_list)]));
$this->assertSession()->pageTextContains("The file ids are " . implode(',', $fid_list) . ".");
// Delete only the first file.
$edit = [

View File

@ -91,7 +91,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called then clean out the hook
// counters.
@ -125,7 +125,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')
->accessCheck(FALSE)
->aggregate('fid', 'max')
@ -155,7 +155,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
$this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
}
@ -180,7 +180,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $extensions . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate']);
@ -199,8 +199,8 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains('Only files with the following extensions are allowed:');
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'load', 'update']);
@ -217,8 +217,8 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains('Only files with the following extensions are allowed:');
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'load', 'update']);
@ -244,8 +244,8 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
$this->assertRaw(t('File MIME type is text/plain.'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('File MIME type is text/plain.');
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -259,9 +259,9 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $this->phpfile->filename]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is {$this->phpfile->filename}");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -316,9 +316,9 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is {$munged_filename}");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -340,9 +340,9 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is {$munged_filename}");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -360,9 +360,9 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is {$this->image->getFilename()}");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -380,8 +380,8 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate']);
@ -400,7 +400,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -419,7 +419,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'load', 'update']);
@ -438,7 +438,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the no hooks were called while failing.
$this->assertFileHooksCalled([]);
@ -450,7 +450,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
public function testNoUpload() {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm([], 'Submit');
$this->assertNoRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextNotContains("Epic upload FAIL!");
}
/**
@ -473,16 +473,16 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('File upload error. Could not move uploaded file.'));
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains('File upload error. Could not move uploaded file.');
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Uploading failed. Now check the log.
$this->drupalGet('admin/reports/dblog');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
'@file' => $this->image->getFilename(),
'@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(),
]));
// The full log message is in the title attribute of the link, so we cannot
// use ::pageTextContains() here.
$destination = 'temporary://' . $test_directory . '/' . $this->image->getFilename();
$this->assertSession()->responseContains("Upload error. Could not move uploaded file {$this->image->getFilename()} to destination {$destination}.");
}
/**
@ -500,7 +500,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Ensure the expected error message is present and the counts before and
// after calling _file_save_upload_from_form() are correct.
@ -517,7 +517,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Ensure the expected error message is present and the counts before and
// after calling _file_save_upload_from_form() are correct.
@ -532,7 +532,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Ensure the error message is not present and the counts before and after
// calling _file_save_upload_from_form() are correct.
@ -565,7 +565,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$files['files']['file_test_upload'][1] = $file_system->realpath($textfile->uri);
$client->request($form->getMethod(), $form->getUri(), $edit, $files);
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Search for combined error message followed by a formatted list of messages.
$this->assertSession()->responseContains('One or more files could not be uploaded.<div class="item-list">');
@ -586,7 +586,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
$this->assertCount(1, $this->cssSelect('input[name="files[file_test_upload][]"].error'), 'File upload field has error.');
}

View File

@ -87,7 +87,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
// Check that the success message is present.
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called then clean out the hook
// counters.
@ -119,7 +119,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')
->accessCheck(FALSE)
->aggregate('fid', 'max')
@ -149,7 +149,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
$this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
}
@ -180,8 +180,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
// Received a 200 response for posted test file.
$this->assertSession()->statusCodeEquals(200);
$message = t('The file %file already exists. Enter a unique file URI.', ['%file' => $file1->getFileUri()]);
$this->assertRaw($message);
$this->assertSession()->pageTextContains("The file {$file1->getFileUri()} already exists. Enter a unique file URI.");
$max_fid_before_duplicate = $max_fid_after;
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')
->accessCheck(FALSE)
@ -209,7 +208,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $extensions . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate']);
@ -228,8 +227,8 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains("Only files with the following extensions are allowed:");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'load', 'update']);
@ -246,8 +245,8 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains("Only files with the following extensions are allowed:");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'load', 'update']);
@ -268,8 +267,8 @@ class SaveUploadTest extends FileManagedTestBase {
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
$this->assertSession()->pageTextContains('File name is php-2.php_.txt.');
$this->assertRaw(t('File MIME type is text/plain.'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('File MIME type is text/plain.');
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
}
@ -293,8 +292,8 @@ class SaveUploadTest extends FileManagedTestBase {
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('For security reasons, your upload has been renamed to <em class="placeholder">' . $this->phpfile->filename . '_.txt' . '</em>');
$this->assertSession()->pageTextContains('File name is php-2.php_.txt.');
$this->assertRaw(t('File MIME type is text/plain.'));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('File MIME type is text/plain.');
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -308,9 +307,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains('File name is php-2.php.');
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -325,7 +324,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $edit['extensions'] . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate']);
@ -341,7 +340,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->responseContains('Only files with the following extensions are allowed: <em class="placeholder">' . $edit['extensions'] . '</em>');
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate']);
@ -448,9 +447,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is $munged_filename");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -469,9 +468,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is {$this->image->getFilename()}");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -489,9 +488,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is {$this->image->getFilename()}");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -511,9 +510,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename', ['@filename' => 'image-test.png_.php_.png']));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is image-test.png_.php_.png");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -530,9 +529,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename.', ['@filename' => 'image-test.png_.php__0.png']));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is image-test.png_.php__0.png");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -551,9 +550,9 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('File name is @filename.', ['@filename' => 'image-test.png_.cgi_.png_.txt']));
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("File name is image-test.png_.cgi_.png_.txt");
$this->assertSession()->pageTextContains("You WIN!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate', 'insert']);
@ -571,8 +570,8 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/save_upload_from_form_test');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'));
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextNotContains('For security reasons, your upload has been renamed');
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the correct hooks were called.
$this->assertFileHooksCalled(['validate']);
@ -589,7 +588,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
$this->assertSession()->pageTextContains('File name is image-test_0.png.');
// Check that the correct hooks were called.
@ -607,7 +606,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
$this->assertSession()->pageTextContains('File name is image-test.png.');
// Check that the correct hooks were called.
@ -625,7 +624,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Check that the no hooks were called while failing.
$this->assertFileHooksCalled([]);
@ -637,7 +636,7 @@ class SaveUploadTest extends FileManagedTestBase {
public function testNoUpload() {
$this->drupalGet('file-test/upload');
$this->submitForm([], 'Submit');
$this->assertNoRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextNotContains("Epic upload FAIL!");
}
/**
@ -660,16 +659,16 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalGet('file-test/upload');
$this->submitForm($edit, 'Submit');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('File upload error. Could not move uploaded file.'));
$this->assertRaw(t('Epic upload FAIL!'));
$this->assertSession()->pageTextContains('File upload error. Could not move uploaded file.');
$this->assertSession()->pageTextContains("Epic upload FAIL!");
// Uploading failed. Now check the log.
$this->drupalGet('admin/reports/dblog');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [
'@file' => $this->image->getFilename(),
'@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(),
]));
// The full log message is in the title attribute of the link, so we cannot
// use ::pageTextContains() here.
$destination = 'temporary://' . $test_directory . '/' . $this->image->getFilename();
$this->assertSession()->responseContains("Upload error. Could not move uploaded file {$this->image->getFilename()} to destination {$destination}.");
}
/**

View File

@ -210,13 +210,7 @@ class FileFieldWidgetTest extends WebDriverTestBase {
$multiple_field = $this->getSession()->getPage()->findField('files[test_file_field_1_0][]');
$multiple_field->setValue(implode("\n", $remote_paths));
$this->assertSession()->assertWaitOnAjaxRequest();
$args = [
'%field' => $field_name,
'@max' => $cardinality,
'@count' => 3,
'%list' => 'text-2.txt',
];
$this->assertRaw(t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args));
$this->assertSession()->pageTextContains("Field {$field_name} can only hold {$cardinality} values but there were 3 uploaded. The following files have been omitted as a result: text-2.txt.");
}
/**

View File

@ -187,9 +187,7 @@ class FilterAdminTest extends BrowserTestBase {
];
$this->drupalGet('admin/config/content/formats/add');
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('Text format names must be unique. A format named %name already exists.', [
'%name' => $name,
]));
$this->assertSession()->pageTextContains("Text format names must be unique. A format named $name already exists.");
}
/**
@ -267,7 +265,7 @@ class FilterAdminTest extends BrowserTestBase {
$this->drupalGet('admin/config/content/formats/add');
$this->submitForm($edit, 'Save configuration');
$this->assertSession()->addressEquals('admin/config/content/formats');
$this->assertRaw(t('Added text format %format.', ['%format' => $edit['name']]));
$this->assertSession()->pageTextContains("Added text format {$edit['name']}.");
filter_formats_reset();
$format = FilterFormat::load($edit['format']);
@ -281,7 +279,7 @@ class FilterAdminTest extends BrowserTestBase {
$this->drupalGet('admin/config/content/formats/manage/' . $format->id() . '/disable');
$this->submitForm([], 'Disable');
$this->assertSession()->addressEquals('admin/config/content/formats');
$this->assertRaw(t('Disabled text format %format.', ['%format' => $edit['name']]));
$this->assertSession()->pageTextContains("Disabled text format {$edit['name']}.");
// Allow authenticated users on full HTML.
$format = FilterFormat::load($full);
@ -291,7 +289,7 @@ class FilterAdminTest extends BrowserTestBase {
$this->drupalGet('admin/config/content/formats/manage/' . $full);
$this->submitForm($edit, 'Save configuration');
$this->assertSession()->addressEquals('admin/config/content/formats/manage/' . $full);
$this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]));
$this->assertSession()->pageTextContains("The text format {$format->label()} has been updated.");
// Switch user.
$this->drupalLogin($this->webUser);
@ -357,7 +355,7 @@ class FilterAdminTest extends BrowserTestBase {
$this->drupalGet('admin/config/content/formats/manage/' . $full);
$this->submitForm($edit, 'Save configuration');
$this->assertSession()->addressEquals('admin/config/content/formats/manage/' . $full);
$this->assertRaw(t('The text format %format has been updated.', ['%format' => $format->label()]));
$this->assertSession()->pageTextContains("The text format {$format->label()} has been updated.");
$this->drupalGet('admin/config/content/formats/manage/' . $full);
$this->assertSession()->fieldValueEquals('roles[' . RoleInterface::AUTHENTICATED_ID . ']', $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']']);
@ -383,7 +381,7 @@ class FilterAdminTest extends BrowserTestBase {
];
$this->drupalGet('admin/config/content/formats/manage/basic_html');
$this->submitForm($edit, 'Save configuration');
$this->assertNoRaw(t('The text format %format has been updated.', ['%format' => 'Basic HTML']));
$this->assertSession()->pageTextNotContains("The text format Basic HTML has been updated.");
}
/**

View File

@ -51,7 +51,7 @@ class FilterHooksTest extends BrowserTestBase {
$edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 1;
$this->drupalGet('admin/config/content/formats/add');
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('Added text format %format.', ['%format' => $name]));
$this->assertSession()->pageTextContains("Added text format {$name}.");
$this->assertSession()->pageTextContains('hook_filter_format_insert invoked.');
$format_id = $edit['format'];
@ -61,7 +61,7 @@ class FilterHooksTest extends BrowserTestBase {
$edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1;
$this->drupalGet('admin/config/content/formats/manage/' . $format_id);
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('The text format %format has been updated.', ['%format' => $name]));
$this->assertSession()->pageTextContains("The text format {$name} has been updated.");
$this->assertSession()->pageTextContains('hook_filter_format_update invoked.');
// Use the format created.
@ -77,7 +77,7 @@ class FilterHooksTest extends BrowserTestBase {
// Disable the text format.
$this->drupalGet('admin/config/content/formats/manage/' . $format_id . '/disable');
$this->submitForm([], 'Disable');
$this->assertRaw(t('Disabled text format %format.', ['%format' => $name]));
$this->assertSession()->pageTextContains("Disabled text format {$name}.");
$this->assertSession()->pageTextContains('hook_filter_format_disable invoked.');
}

View File

@ -346,7 +346,7 @@ class ForumTest extends BrowserTestBase {
// Save forum overview.
$this->drupalGet('admin/structure/forum/');
$this->submitForm([], 'Save');
$this->assertRaw(t('The configuration options have been saved.'));
$this->assertSession()->pageTextContains('The configuration options have been saved.');
// Delete this second forum.
$this->deleteForum($delete_forum['tid']);
// Create forum at the top (root) level.
@ -403,7 +403,7 @@ class ForumTest extends BrowserTestBase {
$this->drupalGet('admin/structure/taxonomy/manage/' . $original_vocabulary->id());
$this->submitForm($edit, 'Save');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Updated vocabulary %name.', ['%name' => $edit['name']]));
$this->assertSession()->pageTextContains("Updated vocabulary {$edit['name']}.");
// Grab the newly edited vocabulary.
$current_vocabulary = Vocabulary::load($vid);
@ -586,12 +586,12 @@ class ForumTest extends BrowserTestBase {
$type = t('Forum topic');
if ($container) {
$this->assertSession()->pageTextNotContains("$type $title has been created.");
$this->assertRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]));
$this->assertSession()->pageTextContains("The item {$forum['name']} is a forum container, not a forum.");
return;
}
else {
$this->assertSession()->pageTextContains($type . ' ' . $title . ' has been created.');
$this->assertNoRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']]));
$this->assertSession()->pageTextNotContains("The item {$forum['name']} is a forum container, not a forum.");
// Verify that the creation message contains a link to a node.
$this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]');
@ -688,7 +688,7 @@ class ForumTest extends BrowserTestBase {
$this->drupalGet('node/' . $node->id() . '/delete');
$this->submitForm([], 'Delete');
$this->assertSession()->statusCodeEquals($response);
$this->assertRaw(t('Forum topic %title has been deleted.', ['%title' => $edit['title[0][value]']]));
$this->assertSession()->pageTextContains("Forum topic {$edit['title[0][value]']} has been deleted.");
}
}

View File

@ -73,7 +73,7 @@ class HelpTest extends BrowserTestBase {
// Verify that introductory help text exists, goes for 100% module coverage.
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/help');
$this->assertRaw(t('For more information, refer to the help listed on this page or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']));
$this->assertSession()->responseContains('For more information, refer to the help listed on this page or to the <a href="https://www.drupal.org/documentation">online documentation</a> and <a href="https://www.drupal.org/support">support</a> pages at <a href="https://www.drupal.org">drupal.org</a>.');
// Verify that hook_help() section title and description appear.
$this->assertSession()->responseContains('<h2>Module overviews</h2>');
@ -92,7 +92,7 @@ class HelpTest extends BrowserTestBase {
// Ensure a module which does not provide a module overview page is handled
// correctly.
$this->clickLink(\Drupal::moduleHandler()->getName('help_test'));
$this->assertRaw(t('No help is available for module %module.', ['%module' => \Drupal::moduleHandler()->getName('help_test')]));
$this->assertSession()->pageTextContains('No help is available for module ' . \Drupal::moduleHandler()->getName('help_test'));
// Verify that the order of topics is alphabetical by displayed module
// name, by checking the order of some modules, including some that would

View File

@ -68,7 +68,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
];
$this->drupalGet('admin/config/media/image-styles/add');
$this->submitForm($edit, 'Create new style');
$this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
$this->assertSession()->pageTextContains("Style {$style_label} was created.");
$options = image_style_options();
$this->assertArrayHasKey($style_name, $options);
}
@ -120,7 +120,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
];
$this->drupalGet($admin_path . '/add');
$this->submitForm($edit, 'Create new style');
$this->assertRaw(t('Style %name was created.', ['%name' => $style_label]));
$this->assertSession()->pageTextContains("Style {$style_label} was created.");
// Ensure that the expected entity operations are there.
$this->drupalGet($admin_path);
@ -257,7 +257,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Confirm that the form submission was successful.
$this->assertSession()->statusCodeEquals(200);
$image_crop_effect = $style->getEffect($uuids['image_crop']);
$this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()]));
$this->assertSession()->pageTextContains("The image effect {$image_crop_effect->label()} has been deleted.");
// Confirm that there is no longer a link to the effect.
$this->assertSession()->linkByHrefNotExists($style_path . '/effects/' . $uuids['image_crop'] . '/delete');
// Refresh the image style information and verify that the effect was
@ -305,9 +305,8 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Confirm that the empty text is correct on the image styles page.
$this->drupalGet($admin_path);
$this->assertRaw(t('There are currently no styles. <a href=":url">Add a new one</a>.', [
':url' => Url::fromRoute('image.style_add')->toString(),
]));
$this->assertSession()->pageTextContains("There are currently no styles. Add a new one.");
$this->assertSession()->linkByHrefExists(Url::fromRoute('image.style_add')->toString());
}
@ -368,8 +367,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
];
$this->drupalGet($style_path . $new_style_name . '/delete');
$this->submitForm($edit, 'Delete');
$message = t('The image style %name has been deleted.', ['%name' => $new_style_label]);
$this->assertRaw($message);
$this->assertSession()->pageTextContains("The image style {$new_style_label} has been deleted.");
$replacement_style = ImageStyle::load('thumbnail');
$this->drupalGet('node/' . $nid);
@ -520,7 +518,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$this->drupalGet('admin/config/media/image-styles');
$this->clickLink('Edit');
$this->assertRaw(t('Select a new effect'));
$this->assertSession()->pageTextContains("Select a new effect");
}
}

View File

@ -315,14 +315,8 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->drupalGet('node/' . $nid . '/edit');
$this->submitForm($edit, 'Save');
$schema = $field->getFieldStorageDefinition()->getSchema();
$this->assertRaw(t('Alternative text cannot be longer than %max characters but is currently %length characters long.', [
'%max' => $schema['columns']['alt']['length'],
'%length' => $test_size,
]));
$this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', [
'%max' => $schema['columns']['title']['length'],
'%length' => $test_size,
]));
$this->assertSession()->pageTextContains("Alternative text cannot be longer than {$schema['columns']['alt']['length']} characters but is currently {$test_size} characters long.");
$this->assertSession()->pageTextContains("Title cannot be longer than {$schema['columns']['title']['length']} characters but is currently {$test_size} characters long.");
// Set cardinality to unlimited and add upload a second image.
// The image widget is extending on the file widget, but the image field

View File

@ -145,20 +145,16 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
}
}
$this->uploadNodeImage($image_that_is_too_small, $field_names[0], 'article');
$this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
$this->assertRaw(t('The image is too small. The minimum dimensions are %dimensions pixels and the image size is %widthx%height pixels.', [
'%dimensions' => '50x50',
'%width' => $image_that_is_too_small_file->getWidth(),
'%height' => $image_that_is_too_small_file->getHeight(),
]));
$this->assertSession()->pageTextContains("The specified file {$image_that_is_too_small->filename} could not be uploaded.");
$this->assertSession()->pageTextContains("The image is too small. The minimum dimensions are 50x50 pixels and the image size is {$image_that_is_too_small_file->getWidth()}x{$image_that_is_too_small_file->getHeight()} pixels.");
$this->uploadNodeImage($image_that_is_too_big, $field_names[0], 'article');
$this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.');
$this->uploadNodeImage($image_that_is_too_small, $field_names[1], 'article');
$this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
$this->assertSession()->pageTextContains("The specified file {$image_that_is_too_small->filename} could not be uploaded.");
$this->uploadNodeImage($image_that_is_too_big, $field_names[1], 'article');
$this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed width of 100 pixels.');
$this->uploadNodeImage($image_that_is_too_small, $field_names[2], 'article');
$this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename]));
$this->assertSession()->pageTextContains("The specified file {$image_that_is_too_small->filename} could not be uploaded.");
$this->uploadNodeImage($image_that_is_too_big, $field_names[2], 'article');
$this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed height of 100 pixels.');
}

View File

@ -35,8 +35,8 @@ class ImageStyleDeleteTest extends ImageFieldTestBase {
// Checks that the 'replacement' select element is displayed.
$this->assertSession()->fieldExists('replacement');
// Checks that UI messages are correct.
$this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
$this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
$this->assertSession()->pageTextContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
$this->assertSession()->pageTextNotContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
// Delete 'medium' image style but replace it with 'thumbnail'. This style
// is involved in 'node.page.default' display view and form.
@ -58,8 +58,8 @@ class ImageStyleDeleteTest extends ImageFieldTestBase {
// Checks that the 'replacement' select element is displayed.
$this->assertSession()->fieldExists('replacement');
// Checks that UI messages are correct.
$this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
$this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
$this->assertSession()->pageTextContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
$this->assertSession()->pageTextNotContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
// Delete 'thumbnail' image style. Provide no replacement.
$this->submitForm([], 'Delete');
@ -77,8 +77,8 @@ class ImageStyleDeleteTest extends ImageFieldTestBase {
// Checks that the 'replacement' select element is displayed.
$this->assertSession()->fieldExists('replacement');
// Checks that UI messages are correct.
$this->assertRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
$this->assertNoRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
$this->assertSession()->pageTextContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
$this->assertSession()->pageTextNotContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
// Delete 'wide' image style. Provide no replacement.
$this->submitForm([], 'Delete');
@ -87,8 +87,8 @@ class ImageStyleDeleteTest extends ImageFieldTestBase {
// Checks that the 'replacement' select element is not displayed.
$this->assertSession()->fieldNotExists('replacement');
// Checks that UI messages are correct.
$this->assertNoRaw(t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.'));
$this->assertRaw(t('All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.'));
$this->assertSession()->pageTextNotContains("If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted. If no replacement style is selected, the dependent configurations might need manual reconfiguration.");
$this->assertSession()->pageTextContains("All images that have been generated for this style will be permanently deleted. The dependent configurations might need manual reconfiguration.");
}
}

View File

@ -39,12 +39,12 @@ class AdminPathEntityConverterLanguageTest extends BrowserTestBase {
->save();
$this->drupalGet('es/admin/language_test/entity_using_current_language/es');
$this->assertNoRaw(t('Loaded %label.', ['%label' => 'Spanish']));
$this->assertRaw(t('Loaded %label.', ['%label' => 'Español']));
$this->assertSession()->responseNotContains(t('Loaded %label.', ['%label' => 'Spanish']));
$this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Español']));
$this->drupalGet('es/admin/language_test/entity_using_original_language/es');
$this->assertRaw(t('Loaded %label.', ['%label' => 'Spanish']));
$this->assertNoRaw(t('Loaded %label.', ['%label' => 'Español']));
$this->assertSession()->responseContains(t('Loaded %label.', ['%label' => 'Spanish']));
$this->assertSession()->responseNotContains(t('Loaded %label.', ['%label' => 'Español']));
}
}

View File

@ -43,21 +43,14 @@ class LanguageBrowserDetectionTest extends BrowserTestBase {
// Delete zh-cn language code.
$browser_langcode = 'zh-cn';
$this->drupalGet('admin/config/regional/language/detection/browser/delete/' . $browser_langcode);
$message = t('Are you sure you want to delete @browser_langcode?', [
'@browser_langcode' => $browser_langcode,
]);
$this->assertRaw($message);
$this->assertSession()->pageTextContains("Are you sure you want to delete {$browser_langcode}?");
// Confirm the delete.
$edit = [];
$this->drupalGet('admin/config/regional/language/detection/browser/delete/' . $browser_langcode);
$this->submitForm($edit, 'Confirm');
// We need raw here because %browser will add HTML.
$t_args = [
'%browser' => $browser_langcode,
];
$this->assertRaw(t('The mapping for the %browser browser language code has been deleted.', $t_args));
$this->assertSession()->pageTextContains("The mapping for the {$browser_langcode} browser language code has been deleted.");
// Check we went back to the browser negotiation mapping overview.
$this->assertSession()->addressEquals(Url::fromRoute('language.negotiation_browser'));

View File

@ -125,7 +125,7 @@ class LanguageConfigurationTest extends BrowserTestBase {
$this->drupalGet('admin/config/regional/language/delete/en');
$this->submitForm([], 'Delete');
$this->rebuildContainer();
$this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
$this->assertSession()->pageTextContains("The English (en) language has been removed.");
// Ensure that French language has a weight of 1 after being created through
// the UI.

View File

@ -61,12 +61,10 @@ class LanguageCustomLanguageConfigurationTest extends BrowserTestBase {
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add custom language');
$this->assertRaw(t('%field must be a valid language tag as <a href=":url">defined by the W3C</a>.', [
'%field' => t('Language code'),
':url' => 'http://www.w3.org/International/articles/language-tags/',
]));
$this->assertRaw(t('%field cannot contain any markup.', ['%field' => t('Language name')]));
$this->assertSession()->pageTextContains("Language code must be a valid language tag as defined by the W3C.");
$this->assertSession()->linkExists("defined by the W3C");
$this->assertSession()->linkByHrefExists("http://www.w3.org/International/articles/language-tags/");
$this->assertSession()->pageTextContains("Language name cannot contain any markup.");
$this->assertSession()->addressEquals(Url::fromRoute('language.add'));
// Test adding a custom language with a numeric region code.
@ -79,10 +77,7 @@ class LanguageCustomLanguageConfigurationTest extends BrowserTestBase {
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add custom language');
$this->assertRaw(t(
'The language %language has been created and can now be used.',
['%language' => $edit['label']]
));
$this->assertSession()->pageTextContains("The language {$edit['label']} has been created and can now be used.");
$this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
// Test validation of existing language values.
@ -96,19 +91,13 @@ class LanguageCustomLanguageConfigurationTest extends BrowserTestBase {
// Add the language the first time.
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add custom language');
$this->assertRaw(t(
'The language %language has been created and can now be used.',
['%language' => $edit['label']]
));
$this->assertSession()->pageTextContains("The language {$edit['label']} has been created and can now be used.");
$this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
// Add the language a second time and confirm that this is not allowed.
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, 'Add custom language');
$this->assertRaw(t(
'The language %language (%langcode) already exists.',
['%language' => $edit['label'], '%langcode' => $edit['langcode']]
));
$this->assertSession()->pageTextContains("The language {$edit['label']} ({$edit['langcode']}) already exists.");
$this->assertSession()->addressEquals(Url::fromRoute('language.add'));
}

View File

@ -130,9 +130,7 @@ class LanguageListTest extends BrowserTestBase {
// fields changed.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
$this->submitForm([], 'Delete');
// We need raw here because %language and %langcode will add HTML.
$t_args = ['%language' => $name, '%langcode' => $langcode];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
$this->assertSession()->pageTextContains("The {$name} ({$langcode}) language has been removed.");
$this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection', [], ['language' => $english]));
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
@ -143,9 +141,7 @@ class LanguageListTest extends BrowserTestBase {
$this->submitForm([], 'Delete');
// Make sure the "language_count" state has been updated correctly.
$this->rebuildContainer();
// We need raw here because %language and %langcode will add HTML.
$t_args = ['%language' => 'French', '%langcode' => 'fr'];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
$this->assertSession()->pageTextContains("The French (fr) language has been removed.");
$this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/fr');
@ -183,9 +179,7 @@ class LanguageListTest extends BrowserTestBase {
$this->drupalGet('admin/config/regional/language/delete/en');
$this->submitForm([], 'Delete');
// We need raw here because %language and %langcode will add HTML.
$t_args = ['%language' => 'English', '%langcode' => 'en'];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
$this->assertSession()->pageTextContains("The English (en) language has been removed.");
$this->rebuildContainer();
// Ensure we can't delete a locked language.

View File

@ -162,8 +162,8 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
$this->assertFalse(isset($negotiation[$test_method_id]), 'The disabled test language negotiation method is not part of the content language negotiation settings.');
// Check that configuration page presents the correct options and settings.
$this->assertNoRaw(t('Test language detection'));
$this->assertNoRaw(t('This is a test language negotiation method'));
$this->assertSession()->pageTextNotContains("Test language detection");
$this->assertSession()->pageTextNotContains("This is a test language negotiation method");
}
/**

View File

@ -529,7 +529,7 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase {
];
$this->drupalGet('admin/config/regional/language/detection/url');
$this->submitForm($edit, 'Save configuration');
$this->assertRaw(t('The domain for %language may only contain the domain name, not a trailing slash, protocol and/or port.', ['%language' => 'Italian']));
$this->assertSession()->pageTextContains("The domain for Italian may only contain the domain name, not a trailing slash, protocol and/or port.");
// Build the link we're going to test.
$link = 'it.example.com' . rtrim(base_path(), '/') . '/admin';

View File

@ -107,7 +107,7 @@ class LocaleContentTest extends BrowserTestBase {
];
$this->drupalGet("admin/structure/types/manage/{$type2->id()}");
$this->submitForm($edit, 'Save content type');
$this->assertRaw(t('The content type %type has been updated.', ['%type' => $type2->label()]));
$this->assertSession()->pageTextContains("The content type {$type2->label()} has been updated.");
$this->drupalLogout();
\Drupal::languageManager()->reset();
@ -196,7 +196,7 @@ class LocaleContentTest extends BrowserTestBase {
];
$this->drupalGet("admin/structure/types/manage/{$type->id()}");
$this->submitForm($edit, 'Save content type');
$this->assertRaw(t('The content type %type has been updated.', ['%type' => $type->label()]));
$this->assertSession()->pageTextContains("The content type {$type->label()} has been updated.");
$this->drupalLogout();
// Log in as web user to add new node.

View File

@ -85,10 +85,10 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
$this->config('locale.settings');
// The import should automatically create the corresponding language.
$this->assertRaw(t('The language %language has been created.', ['%language' => 'French']));
$this->assertSession()->pageTextContains("The language French has been created.");
// The import should have created 8 strings.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 8, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 8 translations were added, 0 translations were updated and 0 translations were removed.");
// This import should have saved plural forms to have 2 variants.
$locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
@ -103,10 +103,8 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
// The import should have created 1 string and rejected 2.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
$skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]);
$this->assertRaw($skip_message);
$this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
$this->assertSession()->pageTextContains("2 translation strings were skipped because of disallowed or malformed HTML. See the log for details.");
// Repeat the process with a user that can access site reports, and this
// time the different warnings must contain links to the log.
@ -117,8 +115,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
'langcode' => 'fr',
]);
$skip_message = \Drupal::translation()->formatPlural(2, 'One translation string was skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]);
$this->assertRaw($skip_message);
$this->assertSession()->pageTextContains("2 translation strings were skipped because of disallowed or malformed HTML. See the log for details.");
// Check empty files import with a user that cannot access site reports..
$this->drupalLogin($this->adminUser);
@ -127,7 +124,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
'langcode' => 'fr',
]);
// The import should have created 0 string and rejected 0.
$this->assertRaw(t('One translation file could not be imported. See the log for details.'));
$this->assertSession()->pageTextContains("One translation file could not be imported. See the log for details.");
// Repeat the process with a user that can access site reports, and this
// time the different warnings must contain links to the log.
@ -137,7 +134,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
'langcode' => 'fr',
]);
// The import should have created 0 string and rejected 0.
$this->assertRaw(t('One translation file could not be imported. <a href=":url">See the log</a> for details.', [':url' => Url::fromRoute('dblog.overview')->toString()]));
$this->assertSession()->pageTextContains("One translation file could not be imported. See the log for details.");
// Try importing a .po file which doesn't exist.
$name = $this->randomMachineName(16);
@ -156,7 +153,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
// The import should have created 1 string.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
// Ensure string wasn't overwritten.
$search = [
'string' => 'Montag',
@ -179,7 +176,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
// The import should have updated 2 strings.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 0 translations were added, 2 translations were updated and 0 translations were removed.");
// Ensure string was overwritten.
$search = [
'string' => 'Montag',
@ -200,7 +197,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
// The import should have created 6 strings.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 6, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 6 translations were added, 0 translations were updated and 0 translations were removed.");
// The database should now contain 6 customized strings (two imported
// strings are not translated).
@ -220,7 +217,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
// The import should have created 1 string.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
// Ensure string wasn't overwritten.
$search = [
'string' => 'januari',
@ -240,7 +237,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
]);
// The import should have updated 2 strings.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 2, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 0 translations were added, 2 translations were updated and 0 translations were removed.");
// Ensure string was overwritten.
$search = [
'string' => 'januari',
@ -279,7 +276,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
'langcode' => $langcode,
]);
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 1, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
$this->assertSame('Műveletek', (string) t('Operations', [], ['langcode' => $langcode]), 'String imported and translated.');
// Try importing a .po file.
@ -287,7 +284,7 @@ class LocaleImportFunctionalTest extends BrowserTestBase {
'langcode' => $langcode,
'overwrite_options[not_customized]' => TRUE,
]);
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', ['%number' => 0, '%update' => 0, '%delete' => 1]));
$this->assertSession()->pageTextContains("One translation file imported. 0 translations were added, 0 translations were updated and 1 translations were removed.");
$str = "Operations";
$search = [

View File

@ -208,9 +208,7 @@ class LocaleTranslationUiTest extends BrowserTestBase {
// This a confirm form, we do not need any fields changed.
$this->drupalGet($path);
$this->submitForm([], 'Delete');
// We need raw here because %language and %langcode will add HTML.
$t_args = ['%language' => $name, '%langcode' => $langcode];
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args));
$this->assertSession()->pageTextContains("The {$name} ({$langcode}) language has been removed.");
// Reload to remove $name.
$this->drupalGet($path);
// Verify that language is no longer found.

View File

@ -52,7 +52,8 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
$this->assertSession()->pageTextNotContains('Translation update status');
$this->drupalGet('admin/reports/translations');
$this->assertRaw(t('No translatable languages available. <a href=":add_language">Add a language</a> first.', [':add_language' => Url::fromRoute('entity.configurable_language.collection')->toString()]));
$this->assertSession()->pageTextContains("No translatable languages available. Add a language first.");
$this->assertSession()->linkByHrefExists(Url::fromRoute('entity.configurable_language.collection')->toString());
// Add German language.
$this->addLanguage('de');
@ -77,7 +78,8 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if updates are available for German.
$this->drupalGet('admin/reports/status');
$this->assertSession()->pageTextContains('Translation update status');
$this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]));
$this->assertSession()->pageTextContains("Updates available for: German. See the Available translation updates page for more information.");
$this->assertSession()->linkByHrefExists(Url::fromRoute('locale.translate_status')->toString());
$this->drupalGet('admin/reports/translations');
$this->assertSession()->pageTextContains('Updates for: Locale test translate');
@ -91,7 +93,8 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase {
// Check if no updates were found.
$this->drupalGet('admin/reports/status');
$this->assertSession()->pageTextContains('Translation update status');
$this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()]));
$this->assertSession()->pageTextContains("Missing translations for: German. See the Available translation updates page for more information.");
$this->assertSession()->linkByHrefExists(Url::fromRoute('locale.translate_status')->toString());
$this->drupalGet('admin/reports/translations');
$this->assertSession()->pageTextContains('Missing translations for one project');
$release_details = new FormattableMarkup('@module (@version). @info', [

View File

@ -332,8 +332,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->submitForm($edit, 'Install');
// Check if translations have been imported.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
['%number' => 7, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 7 translations were added, 0 translations were updated and 0 translations were removed.");
// cSpell:disable-next-line
$this->assertTranslation('Tuesday', 'Dienstag', 'de');
@ -382,8 +381,7 @@ class LocaleUpdateTest extends LocaleUpdateBase {
$this->submitForm($edit, 'Add language');
// Check if the right number of translations are added.
$this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.',
['%number' => 8, '%update' => 0, '%delete' => 0]));
$this->assertSession()->pageTextContains("One translation file imported. 8 translations were added, 0 translations were updated and 0 translations were removed.");
// cSpell:disable-next-line
$this->assertTranslation('Extraday', 'extra dag', 'nl');

View File

@ -48,7 +48,7 @@ class MenuLinkContentDeleteFormTest extends BrowserTestBase {
$menu_link = MenuLinkContent::load(1);
$this->drupalGet($menu_link->toUrl('delete-form'));
$this->assertRaw(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the custom menu link {$menu_link->label()}?");
$this->assertSession()->linkExists('Cancel');
// Make sure cancel link points to link edit
$this->assertSession()->linkByHrefExists($menu_link->toUrl('edit-form')->toString());
@ -60,7 +60,7 @@ class MenuLinkContentDeleteFormTest extends BrowserTestBase {
$menu = Menu::load($menu_link->getMenuName());
$this->assertSession()->linkByHrefExists($menu->toUrl('edit-form')->toString());
$this->submitForm([], 'Delete');
$this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()]));
$this->assertSession()->pageTextContains("The menu link {$menu_link->label()} has been deleted.");
}
}

View File

@ -122,12 +122,7 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
$options = ['language' => $languages[$langcode]];
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
]);
$this->assertRaw($title);
$this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
}
}
}

View File

@ -114,7 +114,7 @@ class MenuUiNodeTest extends BrowserTestBase {
$this->drupalGet('admin/structure/types/manage/page');
$this->submitForm($edit, 'Save content type');
$this->assertSession()->pageTextContains('The selected menu link is not under one of the selected menus.');
$this->assertNoRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
$this->assertSession()->pageTextNotContains("The content type Basic page has been updated.");
// Enable Tools menu as available menu.
$edit = [
@ -124,7 +124,7 @@ class MenuUiNodeTest extends BrowserTestBase {
];
$this->drupalGet('admin/structure/types/manage/page');
$this->submitForm($edit, 'Save content type');
$this->assertRaw(t('The content type %name has been updated.', ['%name' => 'Basic page']));
$this->assertSession()->pageTextContains("The content type Basic page has been updated.");
// Test that we can preview a node that will create a menu item.
$edit = [

View File

@ -218,11 +218,7 @@ class MenuUiTest extends BrowserTestBase {
// Verify that using a menu_name that is too long results in a validation
// message.
$this->assertRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
'@name' => t('Menu name'),
'%max' => MenuStorage::MAX_ID_LENGTH,
'%length' => mb_strlen($menu_name),
]));
$this->assertSession()->pageTextContains("Menu name cannot be longer than " . MenuStorage::MAX_ID_LENGTH . " characters but is currently " . mb_strlen($menu_name) . " characters long.");
// Change the menu_name so it no longer exceeds the maximum length.
$menu_name = strtolower($this->randomMachineName(MenuStorage::MAX_ID_LENGTH));
@ -231,13 +227,10 @@ class MenuUiTest extends BrowserTestBase {
$this->submitForm($edit, 'Save');
// Verify that no validation error is given for menu_name length.
$this->assertNoRaw(t('@name cannot be longer than %max characters but is currently %length characters long.', [
'@name' => t('Menu name'),
'%max' => MenuStorage::MAX_ID_LENGTH,
'%length' => mb_strlen($menu_name),
]));
$this->assertSession()->pageTextNotContains("Menu name cannot be longer than " . MenuStorage::MAX_ID_LENGTH . " characters but is currently " . mb_strlen($menu_name) . " characters long.");
// Verify that the confirmation message is displayed.
$this->assertRaw(t('Menu %label has been added.', ['%label' => $label]));
$this->assertSession()->pageTextContains("Menu $label has been added.");
$this->drupalGet('admin/structure/menu');
$this->assertSession()->pageTextContains($label);
@ -266,7 +259,7 @@ class MenuUiTest extends BrowserTestBase {
$this->drupalGet("admin/structure/menu/manage/{$menu_name}/delete");
$this->submitForm([], 'Delete');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('The menu %title has been deleted.', ['%title' => $label]));
$this->assertSession()->pageTextContains("The menu $label has been deleted.");
$this->assertNull(Menu::load($menu_name), 'Custom menu was deleted');
// Test if all menu links associated with the menu were removed from
// database.
@ -303,7 +296,7 @@ class MenuUiTest extends BrowserTestBase {
$this->assertSession()->addressEquals(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
// Test the 'Delete' operation.
$this->clickLink('Delete');
$this->assertRaw(t('Are you sure you want to delete the custom menu link %item?', ['%item' => $link_title]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the custom menu link {$link_title}?");
$this->submitForm([], 'Delete');
$this->assertSession()->addressEquals(Url::fromRoute('entity.menu.edit_form', ['menu' => $menu_name]));
@ -681,7 +674,7 @@ class MenuUiTest extends BrowserTestBase {
];
$this->drupalGet("admin/structure/menu/manage/{$this->menu->id()}/add");
$this->submitForm($edit, 'Save');
$this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => $link_path]));
$this->assertSession()->pageTextContains("The path '{$link_path}' is inaccessible.");
}
}
@ -825,7 +818,7 @@ class MenuUiTest extends BrowserTestBase {
$this->drupalGet("admin/structure/menu/link/{$menu_link->getPluginId()}/reset");
$this->submitForm([], 'Reset');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('The menu link was reset to its default settings.'));
$this->assertSession()->pageTextContains('The menu link was reset to its default settings.');
// Verify menu link.
$instance = \Drupal::service('plugin.manager.menu.link')->createInstance($menu_link->getPluginId());
@ -846,7 +839,7 @@ class MenuUiTest extends BrowserTestBase {
$this->drupalGet("admin/structure/menu/item/{$mlid}/delete");
$this->submitForm([], 'Delete');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $title]));
$this->assertSession()->pageTextContains("The menu link $title has been deleted.");
// Verify deletion.
$this->drupalGet('');

View File

@ -86,7 +86,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase {
$this->assertSession()->statusCodeEquals(200);
// Make sure that the action was actually deleted.
$this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]));
$this->assertSession()->pageTextContains("The action {$new_action_label} has been deleted.");
$this->drupalGet('admin/config/system/actions');
$this->assertSession()->statusCodeEquals(200);
// Check that the label for the node_assign_owner_action action does not

View File

@ -269,7 +269,7 @@ class NodeEditFormTest extends NodeTestBase {
];
$this->drupalGet('node/' . $node->id() . '/edit');
$this->submitForm($edit, 'Save');
$this->assertRaw(t('There are no users matching "%name".', ['%name' => 'invalid-name']));
$this->assertSession()->pageTextContains('There are no users matching "invalid-name".');
// Change the authored by field to an empty string, which should assign
// authorship to the anonymous user (uid 0).

View File

@ -57,7 +57,7 @@ class NodeFieldMultilingualTest extends BrowserTestBase {
];
$this->drupalGet('admin/structure/types/manage/page');
$this->submitForm($edit, 'Save content type');
$this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']));
$this->assertSession()->pageTextContains("The content type Basic page has been updated.");
// Make node body translatable.
$field_storage = FieldStorageConfig::loadByName('node', 'body');

View File

@ -150,12 +150,7 @@ class NodeRevisionsAllTest extends NodeTestBase {
// Confirm that revisions revert properly.
$this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/revert");
$this->submitForm([], 'Revert');
$this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.',
[
'@type' => 'Basic page',
'%title' => $nodes[1]->getTitle(),
'%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
]));
$this->assertSession()->pageTextContains("Basic page {$nodes[1]->getTitle()} has been reverted to the revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())}.");
$node_storage->resetCache([$node->id()]);
$reverted_node = $node_storage->load($node->id());
$this->assertSame($nodes[1]->body->value, $reverted_node->body->value, 'Node reverted correctly.');
@ -178,12 +173,7 @@ class NodeRevisionsAllTest extends NodeTestBase {
// Confirm revisions delete properly.
$this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete");
$this->submitForm([], 'Delete');
$this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
[
'%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
'@type' => 'Basic page',
'%title' => $nodes[1]->getTitle(),
]));
$this->assertSession()->pageTextContains("Revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())} of Basic page {$nodes[1]->getTitle()} has been deleted.");
$nids = \Drupal::entityQuery('node')
->allRevisions()
->accessCheck(FALSE)
@ -203,11 +193,7 @@ class NodeRevisionsAllTest extends NodeTestBase {
->execute();
$this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert");
$this->submitForm([], 'Revert');
$this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
'@type' => 'Basic page',
'%title' => $nodes[2]->getTitle(),
'%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
]));
$this->assertSession()->pageTextContains("Basic page {$nodes[2]->getTitle()} has been reverted to the revision from {$this->container->get('date.formatter')->format($old_revision_date)}.");
// Create 50 more revisions in order to trigger paging on the revisions
// overview screen.

View File

@ -173,11 +173,7 @@ class NodeRevisionsTest extends NodeTestBase {
// Confirm that revisions revert properly.
$this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionid() . "/revert");
$this->submitForm([], 'Revert');
$this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
'@type' => 'Basic page',
'%title' => $nodes[1]->label(),
'%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
]));
$this->assertSession()->pageTextContains("Basic page {$nodes[1]->label()} has been reverted to the revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())}.");
$node_storage->resetCache([$node->id()]);
$reverted_node = $node_storage->load($node->id());
$this->assertSame($nodes[1]->body->value, $reverted_node->body->value, 'Node reverted correctly.');
@ -193,11 +189,7 @@ class NodeRevisionsTest extends NodeTestBase {
// Confirm revisions delete properly.
$this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete");
$this->submitForm([], 'Delete');
$this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', [
'%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
'@type' => 'Basic page',
'%title' => $nodes[1]->label(),
]));
$this->assertSession()->pageTextContains("Revision from {$this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime())} of Basic page {$nodes[1]->label()} has been deleted.");
$connection = Database::getConnection();
$nids = \Drupal::entityQuery('node')
->accessCheck(FALSE)
@ -218,11 +210,7 @@ class NodeRevisionsTest extends NodeTestBase {
->execute();
$this->drupalGet("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert");
$this->submitForm([], 'Revert');
$this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
'@type' => 'Basic page',
'%title' => $nodes[2]->label(),
'%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
]));
$this->assertSession()->pageTextContains("Basic page {$nodes[2]->label()} has been reverted to the revision from {$this->container->get('date.formatter')->format($old_revision_date)}.");
// Make a new revision and set it to not be default.
// This will create a new revision that is not "front facing".

View File

@ -494,13 +494,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$options = ['language' => $languages[$langcode]];
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('<em>Edit @type</em> @title [%language translation]', [
'@type' => $type_name,
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
]);
$this->assertRaw($title);
$this->assertSession()->pageTextContains("Edit {$type_name} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
}
}
}

View File

@ -190,18 +190,14 @@ class NodeTypeTest extends NodeTestBase {
$node = $this->drupalCreateNode(['type' => $type->id()]);
// Attempt to delete the content type, which should not be allowed.
$this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
$this->assertRaw(
t('%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', ['%type' => $type->label()])
);
$this->assertSession()->pageTextContains("{$type->label()} is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the {$type->label()} content.");
$this->assertSession()->pageTextNotContains('This action cannot be undone.');
// Delete the node.
$node->delete();
// Attempt to delete the content type, which should now be allowed.
$this->drupalGet('admin/structure/types/manage/' . $type->label() . '/delete');
$this->assertRaw(
t('Are you sure you want to delete the content type %type?', ['%type' => $type->label()])
);
$this->assertSession()->pageTextContains("Are you sure you want to delete the content type {$type->label()}?");
$this->assertSession()->pageTextContains('This action cannot be undone.');
// Test that a locked node type could not be deleted.
@ -276,9 +272,9 @@ class NodeTypeTest extends NodeTestBase {
// Navigate to content type administration screen
$this->drupalGet('admin/structure/types');
$this->assertRaw(t('No content types available. <a href=":link">Add content type</a>.', [
':link' => Url::fromRoute('node.type_add')->toString(),
]));
$this->assertSession()->pageTextContains("No content types available. Add content type.");
$this->assertSession()->linkExists("Add content type");
$this->assertSession()->linkByHrefExists(Url::fromRoute('node.type_add')->toString());
$bundle_info->clearCachedBundles();
$this->assertCount(0, $bundle_info->getBundleInfo('node'), 'The bundle information service has 0 bundles for the Node entity type.');

View File

@ -121,7 +121,7 @@ class NodeTypeTranslationTest extends BrowserTestBase {
$this->drupalGet("$langcode/node/add/$type");
// This is a Spanish page, so ensure the text asserted is translated in
// Spanish and not French by adding the langcode option.
$this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
$this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
// Check the name is translated with admin theme for editing.
$this->drupalGet('admin/appearance');
@ -129,7 +129,7 @@ class NodeTypeTranslationTest extends BrowserTestBase {
$this->drupalGet("$langcode/node/add/$type");
// This is a Spanish page, so ensure the text asserted is translated in
// Spanish and not French by adding the langcode option.
$this->assertRaw(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
$this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
}
/**

View File

@ -308,7 +308,7 @@ class OptionsWidgetsTest extends FieldTestBase {
// Submit form: select invalid 'none' option.
$edit = ['card_1' => '_none'];
$this->submitForm($edit, 'Save');
$this->assertRaw(t('@title field is required.', ['@title' => $field->getName()]));
$this->assertSession()->pageTextContains("{$field->getName()} field is required.");
// Submit form: select first option.
$edit = ['card_1' => 0];

View File

@ -148,21 +148,18 @@ class PathAliasTest extends PathTestBase {
$this->submitForm($edit, 'Save');
// Confirm no duplicate was created.
$this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]));
$this->assertSession()->pageTextContains("The alias {$edit['alias[0][value]']} is already in use in this language.");
$edit_upper = $edit;
$edit_upper['alias[0][value]'] = mb_strtoupper($edit['alias[0][value]']);
$this->drupalGet('admin/config/search/path/add');
$this->submitForm($edit_upper, 'Save');
$this->assertRaw(t('The alias %alias could not be added because it is already in use in this language with different capitalization: %stored_alias.', [
'%alias' => $edit_upper['alias[0][value]'],
'%stored_alias' => $edit['alias[0][value]'],
]));
$this->assertSession()->pageTextContains("The alias {$edit_upper['alias[0][value]']} could not be added because it is already in use in this language with different capitalization: {$edit['alias[0][value]']}.");
// Delete alias.
$this->drupalGet('admin/config/search/path/edit/' . $pid);
$this->clickLink('Delete');
$this->assertRaw(t('Are you sure you want to delete the URL alias %name?', ['%name' => $edit['alias[0][value]']]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the URL alias {$edit['alias[0][value]']}?");
$this->submitForm([], 'Delete');
// Confirm that the alias no longer works.
@ -233,7 +230,7 @@ class PathAliasTest extends PathTestBase {
$edit['path[0][value]'] = '/node/' . $node3->id();
$this->drupalGet('admin/config/search/path/edit/' . $pid);
$this->submitForm($edit, 'Save');
$this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias[0][value]']]));
$this->assertSession()->pageTextContains("The alias {$edit['alias[0][value]']} is already in use in this language.");
// Create an alias without a starting slash.
$node5 = $this->drupalCreateNode();

View File

@ -178,7 +178,7 @@ class SearchCommentTest extends BrowserTestBase {
// Verify that comment is rendered using proper format.
$this->assertSession()->pageTextContains($comment_body);
// Verify that HTML in comment body is not hidden.
$this->assertNoRaw(t('n/a'));
$this->assertSession()->pageTextNotContains('n/a');
$this->assertSession()->assertNoEscaped($edit_comment['comment_body[0][value]']);
// Search for the evil script comment subject.

View File

@ -149,7 +149,7 @@ class SearchConfigSettingsFormTest extends BrowserTestBase {
$this->submitForm($edit, 'Save search page');
// Ensure that the modifications took effect.
$this->assertRaw(t('The %label search page has been updated.', ['%label' => 'Dummy search type']));
$this->assertSession()->pageTextContains("The Dummy search type search page has been updated.");
$this->drupalGet('admin/config/search/pages/manage/dummy_search_type');
$this->assertTrue($this->assertSession()->optionExists('edit-extra-type-settings-boost', 'ii')->isSelected());
}
@ -280,7 +280,7 @@ class SearchConfigSettingsFormTest extends BrowserTestBase {
$first['path'] = strtolower($this->randomMachineName(8));
$this->submitForm($first, 'Save');
$this->assertDefaultSearch($first_id, 'The default page matches the only search page.');
$this->assertRaw(t('The %label search page has been added.', ['%label' => $first['label']]));
$this->assertSession()->pageTextContains("The {$first['label']} search page has been added.");
// Attempt to add a search page with an existing path.
$edit = [];
@ -326,7 +326,7 @@ class SearchConfigSettingsFormTest extends BrowserTestBase {
// Change the default search page.
$this->clickLink('Set as default');
$this->assertRaw(t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $second['label']]));
$this->assertSession()->pageTextContains("The default search page is now {$second['label']}. Be sure to check the ordering of your search pages.");
$this->verifySearchPageOperations($first_id, TRUE, TRUE, TRUE, FALSE);
$this->verifySearchPageOperations($second_id, TRUE, FALSE, FALSE, FALSE);
@ -345,9 +345,9 @@ class SearchConfigSettingsFormTest extends BrowserTestBase {
// Test deleting.
$this->clickLink('Delete');
$this->assertRaw(t('Are you sure you want to delete the search page %label?', ['%label' => $first['label']]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the search page {$first['label']}?");
$this->submitForm([], 'Delete');
$this->assertRaw(t('The search page %label has been deleted.', ['%label' => $first['label']]));
$this->assertSession()->pageTextContains("The search page {$first['label']} has been deleted.");
$this->verifySearchPageOperations($first_id, FALSE, FALSE, FALSE, FALSE);
}

View File

@ -138,7 +138,7 @@ class SearchPageTextTest extends BrowserTestBase {
$edit['keys'] = implode(' ', $keys);
$this->drupalGet('search/node');
$this->submitForm($edit, 'Search');
$this->assertRaw(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', ['@count' => $limit]));
$this->assertSession()->pageTextContains("Your search used too many AND/OR expressions. Only the first {$limit} terms were included in this search.");
// Test that a search on Node or User with no keywords entered generates
// the "Please enter some keywords" message.

View File

@ -116,7 +116,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$this->drupalGet('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link');
$this->submitForm($form_data, 'Save');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => '/admin']));
$this->assertSession()->pageTextContains("The path '/admin' is inaccessible.");
$form_data = [
'title[0][value]' => $title,

View File

@ -93,7 +93,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
}
$this->submitForm($edit, 'Save');
$this->assertRaw(t('The shortcut set has been updated.'));
$this->assertSession()->pageTextContains("The shortcut set has been updated.");
\Drupal::entityTypeManager()->getStorage('shortcut')->resetCache();
// Check to ensure that the shortcut weights have changed and that

View File

@ -105,12 +105,7 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
$options = ['language' => $languages[$langcode]];
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
]);
$this->assertRaw($title);
$this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
}
}
}

View File

@ -32,7 +32,7 @@ class DrupalMessengerServiceTest extends BrowserTestBase {
// then removes the first before it is displayed.
$this->drupalGet(Url::fromRoute('system_test.messenger_service'));
$this->assertSession()->pageTextNotContains('First message (removed).');
$this->assertRaw(t('Second message with <em>markup!</em> (not removed).'));
$this->assertSession()->responseContains('Second message with <em>markup!</em> (not removed).');
// Ensure duplicate messages are handled as expected.
$this->assertSession()->pageTextMatchesCount(1, '/Non Duplicated message/');

View File

@ -88,7 +88,7 @@ class EntityTranslationFormTest extends BrowserTestBase {
$edit = ['language_configuration[language_alterable]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED];
$this->drupalGet('admin/structure/types/manage/page');
$this->submitForm($edit, 'Save content type');
$this->assertRaw(t('The content type %type has been updated.', ['%type' => 'Basic page']));
$this->assertSession()->pageTextContains("The content type Basic page has been updated.");
// Create a node with language.
$edit = [];

View File

@ -33,8 +33,8 @@ class EmailTest extends BrowserTestBase {
$edit['email_required'] = ' ';
$this->drupalGet('form-test/email');
$this->submitForm($edit, 'Submit');
$this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid']));
$this->assertRaw(t('@name field is required.', ['@name' => 'Address']));
$this->assertSession()->pageTextContains("The email address invalid is not valid.");
$this->assertSession()->pageTextContains("Address field is required.");
$edit = [];
$edit['email_required'] = ' foo.bar@example.com ';

View File

@ -380,7 +380,7 @@ class FormTest extends BrowserTestBase {
$edit = [];
$this->drupalGet('form-test/checkbox');
$this->submitForm($edit, 'Submit');
$this->assertRaw(t('@name field is required.', ['@name' => 'required_checkbox']));
$this->assertSession()->pageTextContains("required_checkbox field is required.");
// Now try to submit the form correctly.
$this->submitForm(['required_checkbox' => 1], 'Submit');
@ -721,7 +721,7 @@ class FormTest extends BrowserTestBase {
];
$this->drupalGet('form-test/color');
$this->submitForm($edit, 'Submit');
$this->assertRaw(t('%name must be a valid color.', ['%name' => 'Color']));
$this->assertSession()->pageTextContains("Color must be a valid color.");
}
}

View File

@ -58,7 +58,7 @@ class StateValuesCleanAdvancedTest extends BrowserTestBase {
// Expecting a 200 HTTP code.
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('You WIN!'));
$this->assertSession()->pageTextContains("You WIN!");
}
}

View File

@ -35,8 +35,8 @@ class UrlTest extends BrowserTestBase {
$edit['url_required'] = ' ';
$this->drupalGet('form-test/url');
$this->submitForm($edit, 'Submit');
$this->assertRaw(t('The URL %url is not valid.', ['%url' => 'http://']));
$this->assertRaw(t('@name field is required.', ['@name' => 'Required URL']));
$this->assertSession()->pageTextContains("The URL http:// is not valid.");
$this->assertSession()->pageTextContains("Required URL field is required.");
$edit = [];
$edit['url'] = "\n";

View File

@ -152,9 +152,9 @@ class ValidationTest extends BrowserTestBase {
* Tests #pattern validation.
*/
public function testPatternValidation() {
$textfield_error = t('%name field is not in the right format.', ['%name' => 'One digit followed by lowercase letters']);
$tel_error = t('%name field is not in the right format.', ['%name' => 'Everything except numbers']);
$password_error = t('%name field is not in the right format.', ['%name' => 'Password']);
$textfield_error = 'One digit followed by lowercase letters field is not in the right format.';
$tel_error = 'Everything except numbers field is not in the right format.';
$password_error = 'Password field is not in the right format.';
// Invalid textfield, valid tel.
$edit = [
@ -163,9 +163,9 @@ class ValidationTest extends BrowserTestBase {
];
$this->drupalGet('form-test/pattern');
$this->submitForm($edit, 'Submit');
$this->assertRaw($textfield_error);
$this->assertNoRaw($tel_error);
$this->assertNoRaw($password_error);
$this->assertSession()->pageTextContains($textfield_error);
$this->assertSession()->pageTextNotContains($tel_error);
$this->assertSession()->pageTextNotContains($password_error);
// Valid textfield, invalid tel, valid password.
$edit = [
@ -175,9 +175,9 @@ class ValidationTest extends BrowserTestBase {
];
$this->drupalGet('form-test/pattern');
$this->submitForm($edit, 'Submit');
$this->assertNoRaw($textfield_error);
$this->assertRaw($tel_error);
$this->assertNoRaw($password_error);
$this->assertSession()->pageTextNotContains($textfield_error);
$this->assertSession()->pageTextContains($tel_error);
$this->assertSession()->pageTextNotContains($password_error);
// Non required fields are not validated if empty.
$edit = [
@ -186,9 +186,9 @@ class ValidationTest extends BrowserTestBase {
];
$this->drupalGet('form-test/pattern');
$this->submitForm($edit, 'Submit');
$this->assertNoRaw($textfield_error);
$this->assertNoRaw($tel_error);
$this->assertNoRaw($password_error);
$this->assertSession()->pageTextNotContains($textfield_error);
$this->assertSession()->pageTextNotContains($tel_error);
$this->assertSession()->pageTextNotContains($password_error);
// Invalid password.
$edit = [
@ -196,9 +196,9 @@ class ValidationTest extends BrowserTestBase {
];
$this->drupalGet('form-test/pattern');
$this->submitForm($edit, 'Submit');
$this->assertNoRaw($textfield_error);
$this->assertNoRaw($tel_error);
$this->assertRaw($password_error);
$this->assertSession()->pageTextNotContains($textfield_error);
$this->assertSession()->pageTextNotContains($tel_error);
$this->assertSession()->pageTextContains($password_error);
// The pattern attribute overrides #pattern and is not validated on the
// server side.
@ -209,7 +209,7 @@ class ValidationTest extends BrowserTestBase {
];
$this->drupalGet('form-test/pattern');
$this->submitForm($edit, 'Submit');
$this->assertNoRaw(t('%name field is not in the right format.', ['%name' => 'Client side validation']));
$this->assertSession()->pageTextNotContains('Client side validation field is not in the right format.');
}
/**

View File

@ -66,7 +66,8 @@ class DependencyTest extends ModuleTestBase {
// Test that the system_dependencies_test module is marked
// as missing a dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]));
$this->assertSession()->pageTextContains(Unicode::ucfirst('_missing_dependency') . ' (missing)');
$this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-dependencies-test"]//span[@class="admin-missing"]', 'missing');
$this->assertSession()->checkboxNotChecked('modules[system_dependencies_test][enable]');
}
@ -78,10 +79,8 @@ class DependencyTest extends ModuleTestBase {
// Test that the system_incompatible_module_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
'@module' => 'System incompatible module version test (>2.0)',
'@version' => '1.0',
]));
$this->assertSession()->pageTextContains('System incompatible module version test (>2.0) (incompatible with version 1.0)');
$this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-incompatible-module-version-dependencies-test"]//span[@class="admin-missing"]', 'incompatible with');
$this->assertSession()->fieldDisabled('modules[system_incompatible_module_version_dependencies_test][enable]');
}
@ -92,9 +91,8 @@ class DependencyTest extends ModuleTestBase {
// Test that the system_incompatible_core_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
'@module' => 'System core incompatible semver test',
]));
$this->assertSession()->pageTextContains('System core incompatible semver test (incompatible with this version of Drupal core)');
$this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-incompatible-core-version-dependencies-test"]//span[@class="admin-missing"]', 'incompatible with');
$this->assertSession()->fieldDisabled('modules[system_incompatible_core_version_dependencies_test][enable]');
}

View File

@ -33,7 +33,7 @@ class RenderArrayNonHtmlSubscriberTest extends BrowserTestBase {
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Controller response successfully rendered.'));
$this->assertSession()->pageTextContains("Controller response successfully rendered.");
// Test that correct response code is returned for any non-HTML format.
foreach (['json', 'hal+json', 'xml', 'foo'] as $format) {
@ -43,7 +43,7 @@ class RenderArrayNonHtmlSubscriberTest extends BrowserTestBase {
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(406);
$this->assertNoRaw(t('Controller response successfully rendered.'));
$this->assertSession()->pageTextNotContains("Controller response successfully rendered.");
}
// Test that event subscriber does not interfere with raw string responses.
@ -53,7 +53,7 @@ class RenderArrayNonHtmlSubscriberTest extends BrowserTestBase {
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Raw controller response.'));
$this->assertSession()->responseContains("Raw controller response.");
}
}

View File

@ -144,7 +144,7 @@ class DateTimeTest extends BrowserTestBase {
$this->submitForm([], 'Delete');
// Verify that the user is redirected to the correct page.
$this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection'));
$this->assertRaw(t('The date format %format has been deleted.', ['%format' => $name]));
$this->assertSession()->pageTextContains("The date format {$name} has been deleted.");
// Make sure the date does not exist in config.
$date_format = DateFormat::load($date_format_id);

View File

@ -59,7 +59,7 @@ class SiteMaintenanceTest extends BrowserTestBase {
$permission_label = $permissions['access site in maintenance mode']['title'];
$permission_message = t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', ['@permission-label' => $permission_label, ':permissions-url' => Url::fromRoute('user.admin_permissions')->toString(), ':user-login' => Url::fromRoute('user.login')->toString()]);
$this->drupalGet(Url::fromRoute('system.site_maintenance_mode'));
$this->assertRaw($permission_message);
$this->assertSession()->responseContains($permission_message);
$this->drupalGet(Url::fromRoute('user.page'));
// JS should be aggregated, so drupal.js is not in the page source.
@ -80,7 +80,7 @@ class SiteMaintenanceTest extends BrowserTestBase {
// JS should not be aggregated, so drupal.js is expected in the page source.
$links = $this->xpath('//script[contains(@src, :href)]', [':href' => '/core/misc/drupal.js']);
$this->assertTrue(isset($links[0]), 'script /core/misc/drupal.js in page');
$this->assertRaw($admin_message);
$this->assertSession()->responseContains($admin_message);
// Logout and verify that offline message is displayed.
$this->drupalLogout();
@ -113,7 +113,7 @@ class SiteMaintenanceTest extends BrowserTestBase {
$this->drupalLogout();
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/development/maintenance');
$this->assertNoRaw($admin_message);
$this->assertSession()->responseNotContains($admin_message);
$offline_message = 'Sorry, not online.';
$edit = [
@ -125,7 +125,7 @@ class SiteMaintenanceTest extends BrowserTestBase {
$this->drupalLogout();
$this->drupalGet('');
$this->assertEquals('Site under maintenance', $this->cssSelect('main h1')[0]->getText());
$this->assertRaw($offline_message);
$this->assertSession()->pageTextContains($offline_message);
// Verify that custom site offline message is not displayed on user/password.
$this->drupalGet('user/password');

View File

@ -63,7 +63,7 @@ class StatusTest extends BrowserTestBase {
$this->assertSession()->pageTextNotContains('Out of date');
// The setting config_sync_directory is not properly formed.
$this->assertRaw(t("Your %file file must define the %setting setting", ['%file' => $this->siteDirectory . '/settings.php', '%setting' => "\$settings['config_sync_directory']"]));
$this->assertSession()->pageTextContains("Your {$this->siteDirectory}/settings.php file must define the \$settings['config_sync_directory'] setting");
// Set the schema version of update_test_postupdate to a lower version, so
// update_test_postupdate_update_8001() needs to be executed.

View File

@ -38,8 +38,8 @@ class TrustedHostsTest extends BrowserTestBase {
$this->drupalGet('admin/reports/status');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Trusted Host Settings'));
$this->assertRaw(t('The trusted_host_patterns setting is not configured in settings.php.'));
$this->assertSession()->pageTextContains("Trusted Host Settings");
$this->assertSession()->pageTextContains("The trusted_host_patterns setting is not configured in settings.php.");
}
/**
@ -56,8 +56,8 @@ class TrustedHostsTest extends BrowserTestBase {
$this->drupalGet('admin/reports/status');
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw(t('Trusted Host Settings'));
$this->assertRaw(t('The trusted_host_patterns setting is set to allow'));
$this->assertSession()->pageTextContains("Trusted Host Settings");
$this->assertSession()->pageTextContains("The trusted_host_patterns setting is set to allow");
}
/**

View File

@ -162,12 +162,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
$options = ['language' => $languages[$langcode]];
$url = $entity->toUrl('edit-form', $options);
$this->drupalGet($url);
$title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
]);
$this->assertRaw($title);
$this->assertSession()->pageTextContains("{$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
}
}
}

View File

@ -264,11 +264,11 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
// Delete the vocabulary.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
$this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $edit['name[0][value]']]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the taxonomy term {$edit['name[0][value]']}?");
// Confirm deletion.
$this->submitForm([], 'Delete');
$this->assertRaw(t('Deleted term %name.', ['%name' => $edit['name[0][value]']]));
$this->assertSession()->pageTextContains("Deleted term {$edit['name[0][value]']}.");
// Test as user with "create" permissions.
$user = $this->drupalCreateUser(["create terms in {$vocabulary->id()}"]);
@ -343,11 +343,11 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
// Delete the vocabulary.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
$this->assertRaw(t('Are you sure you want to delete the @entity-type %label?', ['@entity-type' => 'taxonomy term', '%label' => $term->getName()]));
$this->assertSession()->pageTextContains("Are you sure you want to delete the taxonomy term {$term->getName()}?");
// Confirm deletion.
$this->submitForm([], 'Delete');
$this->assertRaw(t('Deleted term %name.', ['%name' => $term->getName()]));
$this->assertSession()->pageTextContains("Deleted term {$term->getName()}.");
// Test as user without proper permissions.
$user = $this->drupalCreateUser();

Some files were not shown because too many files have changed in this diff Show More