This commit is contained in:
2020-07-13 17:09:59 +02:00
parent 03559a7b76
commit 3a082e23cc
492 changed files with 4129 additions and 982 deletions
@@ -125,7 +125,7 @@ class AggregatorController extends ControllerBase {
$next_update = $this->t('imminently');
}
elseif ($last_checked && $refresh_rate) {
$next_update = $next = $this->t('%time left', ['%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)]);
$next_update = $this->t('%time left', ['%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)]);
}
else {
$next_update = $this->t('never');
@@ -46,7 +46,12 @@ abstract class AggregatorTestBase extends BrowserTestBase {
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
$this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer news feeds',
'access news feeds',
'create article content',
]);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -55,7 +55,13 @@ class FeedLanguageTest extends AggregatorTestBase {
* Tests creation of feeds with a language.
*/
public function testFeedLanguage() {
$admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
$admin_user = $this->drupalCreateUser([
'administer languages',
'access administration pages',
'administer news feeds',
'access news feeds',
'create article content',
]);
$this->drupalLogin($admin_user);
// Enable language selection for feeds.
@@ -29,7 +29,12 @@ class ImportOpmlTest extends AggregatorTestBase {
protected function setUp() {
parent::setUp();
$admin_user = $this->drupalCreateUser(['administer news feeds', 'access news feeds', 'create article content', 'administer blocks']);
$admin_user = $this->drupalCreateUser([
'administer news feeds',
'access news feeds',
'create article content',
'administer blocks',
]);
$this->drupalLogin($admin_user);
}
@@ -128,7 +128,7 @@ class BasicAuth implements AuthenticationProviderInterface, AuthenticationProvid
}
// Always register an IP-based failed login event.
$this->flood->register('basic_auth.failed_login_ip', $flood_config->get('ip_window'));
return [];
return NULL;
}
/**
@@ -76,7 +76,7 @@ class BasicAuthTest extends BrowserTestBase {
// Ensure that a route without basic auth defined doesn't allow login.
$this->basicAuthGet(Url::fromRoute('system.admin'), $account->getAccountName(), $account->pass_raw);
$this->assertNoLink('Log out', 'User is not logged in');
$this->assertSession()->linkNotExists('Log out', 'User is not logged in');
$this->assertSession()->statusCodeEquals(403);
$this->mink->resetSessions();
@@ -192,7 +192,9 @@ class BigPipeTest extends BrowserTestBase {
// Verify that the two expected exceptions are logged as errors.
$this->assertEqual($log_count + 2, $connection->query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), 'Two new watchdog entries.');
$records = $connection->query('SELECT * FROM {watchdog} ORDER BY wid DESC LIMIT 2')->fetchAll();
// Using the method queryRange() allows contrib database drivers the ability
// to insert their own limit and offset functionality.
$records = $connection->queryRange('SELECT * FROM {watchdog} ORDER BY wid DESC', 0, 2)->fetchAll();
$this->assertEqual(RfcLogLevel::ERROR, $records[0]->severity);
$this->assertStringContainsString('Oh noes!', (string) unserialize($records[0]->variables)['@message']);
$this->assertEqual(RfcLogLevel::ERROR, $records[1]->severity);
@@ -28,7 +28,10 @@ class BlockAdminThemeTest extends BrowserTestBase {
*/
public function testAdminTheme() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user);
// Ensure that access to block admin page is denied when theme is not
@@ -56,7 +56,10 @@ class BlockCacheTest extends BrowserTestBase {
parent::setUp();
// Create an admin user, log in and enable test blocks.
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'access administration pages']);
$this->adminUser = $this->drupalCreateUser([
'administer blocks',
'access administration pages',
]);
$this->drupalLogin($this->adminUser);
// Create additional users to test caching modes.
@@ -28,7 +28,10 @@ class BlockDemoTest extends BrowserTestBase {
*/
public function testBlockDemo() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user);
// Confirm we have access to the block demo page for the default theme.
@@ -33,7 +33,10 @@ class BlockLanguageTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages']);
$this->adminUser = $this->drupalCreateUser([
'administer blocks',
'administer languages',
]);
$this->drupalLogin($this->adminUser);
// Add predefined language.
@@ -152,9 +152,9 @@ class BlockUiTest extends BrowserTestBase {
\Drupal::service('theme_installer')->install(['stable', 'stark']);
$this->drupalGet('admin/structure/block');
$theme_handler = \Drupal::service('theme_handler');
$this->assertLink($theme_handler->getName('classy'));
$this->assertLink($theme_handler->getName('stark'));
$this->assertNoLink($theme_handler->getName('stable'));
$this->assertSession()->linkExists($theme_handler->getName('classy'));
$this->assertSession()->linkExists($theme_handler->getName('stark'));
$this->assertSession()->linkNotExists($theme_handler->getName('stable'));
// Ensure that a hidden theme cannot use the block demo page.
$this->drupalGet('admin/structure/block/list/stable');
@@ -166,7 +166,7 @@ class BlockUiTest extends BrowserTestBase {
\Drupal::service('router.builder')->rebuildIfNeeded();
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header', 'theme' => 'stable']);
$this->drupalGet('admin/structure/block');
$this->assertLink($theme_handler->getName('stable'));
$this->assertSession()->linkExists($theme_handler->getName('stable'));
$this->drupalGet('admin/structure/block/list/stable');
$this->assertSession()->statusCodeEquals(200);
}
@@ -32,7 +32,10 @@ class BlockXssTest extends BrowserTestBase {
* Tests that nothing is escaped other than the blocks explicitly tested.
*/
public function testNoUnexpectedEscaping() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages']));
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
]));
$this->drupalGet(Url::fromRoute('block.admin_display'));
$this->clickLink('Place block');
$this->assertNoEscaped('<');
@@ -49,7 +52,10 @@ class BlockXssTest extends BrowserTestBase {
$this->drupalGet('');
$this->assertNoRaw('<script>alert("XSS label");</script>', 'The block title was properly sanitized when rendered.');
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages']));
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
]));
$default_theme = $this->config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/list/' . $default_theme);
$this->assertNoRaw("<script>alert('XSS subject');</script>", 'The block title was properly sanitized in Block Plugin UI Admin page.');
@@ -61,7 +67,10 @@ class BlockXssTest extends BrowserTestBase {
public function testXssInCategory() {
$this->container->get('module_installer')->install(['block_test']);
$this->drupalPlaceBlock('test_xss_title');
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'access administration pages']));
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
]));
$this->drupalGet(Url::fromRoute('block.admin_display'));
$this->clickLink('Place block');
$this->assertNoRaw("<script>alert('XSS category');</script>");
@@ -36,7 +36,10 @@ class NonDefaultBlockAdminTest extends BrowserTestBase {
* Test non-default theme admin.
*/
public function testNonDefaultBlockAdmin() {
$admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']);
$admin_user = $this->drupalCreateUser([
'administer blocks',
'administer themes',
]);
$this->drupalLogin($admin_user);
$new_theme = 'bartik';
\Drupal::service('theme_installer')->install([$new_theme]);
@@ -65,7 +65,10 @@ class DisplayBlockTest extends ViewTestBase {
* Tests default and custom block categories.
*/
public function testBlockCategory() {
$this->drupalLogin($this->drupalCreateUser(['administer views', 'administer blocks']));
$this->drupalLogin($this->drupalCreateUser([
'administer views',
'administer blocks',
]));
// Create a new view in the UI.
$edit = [];
@@ -368,7 +371,11 @@ class DisplayBlockTest extends ViewTestBase {
* Tests the contextual links on a Views block.
*/
public function testBlockContextualLinks() {
$this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links', 'administer blocks']));
$this->drupalLogin($this->drupalCreateUser([
'administer views',
'access contextual links',
'administer blocks',
]));
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1');
$this->drupalGet('test-page');
@@ -11,14 +11,13 @@ use Drupal\block_content\BlockContentTypeInterface;
* @ConfigEntityType(
* id = "block_content_type",
* label = @Translation("Custom block type"),
* label_collection = @Translation("Custom block types"),
* label_collection = @Translation("Custom block library"),
* label_singular = @Translation("custom block type"),
* label_plural = @Translation("custom block types"),
* label_count = @PluralTranslation(
* singular = "@count custom block type",
* plural = "@count custom block types",
* ),
* label_collection = @Translation("Custom block library"),
* handlers = {
* "form" = {
* "default" = "Drupal\block_content\BlockContentTypeForm",
@@ -31,7 +31,10 @@ class BlockContentListTest extends BlockContentTestBase {
* Tests the custom block listing page.
*/
public function testListing() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'translate configuration',
]));
$this->drupalGet('admin/structure/block/block-content');
// Test for the page title.
@@ -55,7 +58,7 @@ class BlockContentListTest extends BlockContentTestBase {
$new_label = 'Albatross';
// Add a new entity using the operations link.
$link_text = t('Add custom block');
$this->assertLink($link_text);
$this->assertSession()->linkExists($link_text);
$this->clickLink($link_text);
$this->assertSession()->statusCodeEquals(200);
$edit = [];
@@ -34,7 +34,10 @@ class BlockContentListViewsTest extends BlockContentTestBase {
* Tests the custom block listing page.
*/
public function testListing() {
$this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'translate configuration',
]));
$this->drupalGet('admin/structure/block/block-content');
// Test for the page title.
@@ -67,7 +70,7 @@ class BlockContentListViewsTest extends BlockContentTestBase {
$new_label = 'Albatross';
// Add a new entity using the operations link.
$link_text = t('Add custom block');
$this->assertLink($link_text);
$this->assertSession()->linkExists($link_text);
$this->clickLink($link_text);
$this->assertSession()->statusCodeEquals(200);
$edit = [];
@@ -123,7 +126,7 @@ class BlockContentListViewsTest extends BlockContentTestBase {
// Confirm that the empty text is displayed.
$this->assertText('There are no custom blocks available.');
$this->assertLink('custom block');
$this->assertSession()->linkExists('custom block');
$block_content = BlockContent::create([
'info' => 'Non-reusable block',
@@ -53,8 +53,24 @@ class BookBreadcrumbTest extends BrowserTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create users.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']);
$this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration']);
$this->bookAuthor = $this->drupalCreateUser([
'create new books',
'create book content',
'edit own book content',
'add content to books',
]);
$this->adminUser = $this->drupalCreateUser([
'create new books',
'create book content',
'edit any book content',
'delete any book content',
'add content to books',
'administer blocks',
'administer permissions',
'administer book outlines',
'administer content types',
'administer site configuration',
]);
}
/**
@@ -46,7 +46,16 @@ class BookContentModerationTest extends BrowserTestBase {
$workflow->save();
// We need a user with additional content moderation permissions.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books', 'access printer-friendly version', 'view any unpublished content', 'use editorial transition create_new_draft', 'use editorial transition publish']);
$this->bookAuthor = $this->drupalCreateUser([
'create new books',
'create book content',
'edit own book content',
'add content to books',
'access printer-friendly version',
'view any unpublished content',
'use editorial transition create_new_draft',
'use editorial transition publish',
]);
}
/**
@@ -61,10 +61,32 @@ class BookTest extends BrowserTestBase {
node_access_rebuild();
// Create users.
$this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']);
$this->webUser = $this->drupalCreateUser(['access printer-friendly version', 'node test view']);
$this->webUserWithoutNodeAccess = $this->drupalCreateUser(['access printer-friendly version']);
$this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration']);
$this->bookAuthor = $this->drupalCreateUser([
'create new books',
'create book content',
'edit own book content',
'add content to books',
]);
$this->webUser = $this->drupalCreateUser([
'access printer-friendly version',
'node test view',
]);
$this->webUserWithoutNodeAccess = $this->drupalCreateUser([
'access printer-friendly version',
]);
$this->adminUser = $this->drupalCreateUser([
'create new books',
'create book content',
'edit any book content',
'delete any book content',
'add content to books',
'administer blocks',
'administer permissions',
'administer book outlines',
'node test view',
'administer content types',
'administer site configuration',
]);
}
/**
@@ -220,7 +242,7 @@ class BookTest extends BrowserTestBase {
// Load the book and verify there is no printer-friendly version link.
$this->drupalGet('node/' . $this->book->id());
$this->assertNoLink(t('Printer-friendly version'), 'Anonymous user is not shown link to printer-friendly version.');
$this->assertSession()->linkNotExists(t('Printer-friendly version'), 'Anonymous user is not shown link to printer-friendly version.');
// Try getting the URL directly, and verify it fails.
$this->drupalGet('book/export/html/' . $this->book->id());
@@ -402,13 +424,13 @@ class BookTest extends BrowserTestBase {
// Create new node not yet a book.
$empty_book = $this->drupalCreateNode(['type' => 'book']);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertNoLink(t('Book outline'), 'Book Author is not allowed to outline');
$this->assertSession()->linkNotExists(t('Book outline'), 'Book Author is not allowed to outline');
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
$this->assertNoLink(t('Remove from book outline'));
$this->assertSession()->linkNotExists(t('Remove from book outline'));
$edit = [];
$edit['book[bid]'] = '1';
@@ -557,7 +579,11 @@ class BookTest extends BrowserTestBase {
$this->createBook();
// Create administrator user.
$administratorUser = $this->drupalCreateUser(['administer blocks', 'administer nodes', 'bypass node access']);
$administratorUser = $this->drupalCreateUser([
'administer blocks',
'administer nodes',
'bypass node access',
]);
$this->drupalLogin($administratorUser);
// Enable the block with "Show block only on book pages" mode.
@@ -153,7 +153,7 @@ class BookRelationshipTest extends ViewTestBase {
$this->drupalGet('test-book/' . $nodes[$i]->id());
for ($j = 0; $j < $i; $j++) {
$this->assertLink($nodes[$j]->label());
$this->assertSession()->linkExists($nodes[$j]->label());
}
}
}
@@ -45,6 +45,7 @@ interface CKEditorPluginInterface extends PluginInspectionInterface {
*
* @param \Drupal\editor\Entity\Editor $editor
* A configured text editor object.
*
* @return array
* An unindexed array of plugin names this plugin requires. Each plugin is
* is identified by its annotated ID.
@@ -59,6 +60,7 @@ interface CKEditorPluginInterface extends PluginInspectionInterface {
*
* @param \Drupal\editor\Entity\Editor $editor
* A configured text editor object.
*
* @return array
* An array of libraries suitable for usage in a render API #attached
* property.
@@ -91,6 +93,7 @@ interface CKEditorPluginInterface extends PluginInspectionInterface {
*
* @param \Drupal\editor\Entity\Editor $editor
* A configured text editor object.
*
* @return array
* A keyed array, whose keys will end up as keys under CKEDITOR.config.
*/
@@ -60,6 +60,7 @@ class CKEditorPluginManager extends DefaultPluginManager {
* @param bool $include_internal_plugins
* Defaults to FALSE. When set to TRUE, plugins whose isInternal() method
* returns TRUE will also be included.
*
* @return array
* A list of the enabled CKEditor plugins, with the plugin IDs as keys and
* the Drupal root-relative plugin files as values.
@@ -117,6 +117,7 @@ class StylesCombo extends CKEditorPluginBase implements CKEditorPluginConfigurab
*
* @param string $styles
* The "styles" setting.
*
* @return array|false
* An array containing the "stylesSet" configuration, or FALSE when the
* syntax is invalid.
@@ -403,6 +403,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
*
* @param \Drupal\editor\Entity\Editor $editor
* A configured text editor object.
*
* @return array
* An array containing the "toolbar" configuration.
*/
@@ -426,6 +427,7 @@ class CKEditor extends EditorBase implements ContainerFactoryPluginInterface {
*
* @param \Drupal\editor\Entity\Editor $editor
* A configured text editor object.
*
* @return array
* An array containing the "contentsCss" configuration.
*/
@@ -72,8 +72,16 @@ class CKEditorLoadingTest extends BrowserTestBase {
'name' => 'Article',
]);
$this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']);
$this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html']);
$this->untrustedUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
]);
$this->normalUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format filtered_html',
'use text format full_html',
]);
}
/**
@@ -57,7 +57,10 @@ class CKEditorStylesComboTranslationTest extends BrowserTestBase {
]);
$editor->save();
$this->adminUser = $this->drupalCreateUser(['administer filters', 'translate configuration']);
$this->adminUser = $this->drupalCreateUser([
'administer filters',
'translate configuration',
]);
ConfigurableLanguage::createFromLangcode('de')->save();
}
@@ -75,6 +75,7 @@ interface CommentStorageInterface extends ContentEntityStorageInterface {
*
* @param \Drupal\comment\CommentInterface[] $comments
* An array of comment entities keyed by their ids.
*
* @return array
* The entity ids of the passed comment entities' children as an array.
*/
@@ -176,7 +176,7 @@ class CommentAnonymousTest extends CommentTestBase {
// "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.');
$this->assertSession()->linkNotExists('Add new comment', 'Link to add comment was found.');
// Attempt to view node-comment form while disallowed.
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
@@ -189,8 +189,8 @@ class CommentAnonymousTest extends CommentTestBase {
]);
$this->drupalGet('node/' . $this->node->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 1, 'Link to login was found.');
$this->assertLink('register', 1, 'Link to register was found.');
$this->assertSession()->linkExists('Log in', 1, 'Link to login was found.');
$this->assertSession()->linkExists('register', 1, 'Link to register was found.');
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => FALSE,
@@ -60,7 +60,11 @@ class CommentBookTest extends BrowserTestBase {
]);
$comment->save();
$commenting_user = $this->drupalCreateUser(['access printer-friendly version', 'access comments', 'post comments']);
$commenting_user = $this->drupalCreateUser([
'access printer-friendly version',
'access comments',
'post comments',
]);
$this->drupalLogin($commenting_user);
$this->drupalGet('node/' . $book_node->id());
@@ -191,7 +191,10 @@ class CommentFieldsTest extends CommentTestBase {
*/
public function testCommentInstallAfterContentModule() {
// Create a user to do module administration.
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer modules',
]);
$this->drupalLogin($this->adminUser);
// Drop default comment field added in CommentTestBase::setup().
@@ -233,7 +236,12 @@ class CommentFieldsTest extends CommentTestBase {
// Try to post a comment on each node. A failure will be triggered if the
// comment body is missing on one of these forms, due to postComment()
// asserting that the body is actually posted correctly.
$this->webUser = $this->drupalCreateUser(['access content', 'access comments', 'post comments', 'skip comment approval']);
$this->webUser = $this->drupalCreateUser([
'access content',
'access comments',
'post comments',
'skip comment approval',
]);
$this->drupalLogin($this->webUser);
$this->postComment($book_node, $this->randomMachineName(), $this->randomMachineName());
}
@@ -45,7 +45,17 @@ class CommentLanguageTest extends BrowserTestBase {
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create and log in user.
$admin_user = $this->drupalCreateUser(['administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval']);
$admin_user = $this->drupalCreateUser([
'administer site configuration',
'administer languages',
'access administration pages',
'administer content types',
'administer comments',
'create article content',
'access comments',
'post comments',
'skip comment approval',
]);
$this->drupalLogin($admin_user);
// Add language.
@@ -34,7 +34,7 @@ class CommentLinksAlterTest extends CommentTestBase {
$this->drupalGet('node/' . $this->node->id());
$this->assertLink(t('Report'));
$this->assertSession()->linkExists(t('Report'));
}
}
@@ -101,9 +101,9 @@ class CommentLinksTest extends CommentTestBase {
// In teaser view, a link containing the comment count is always
// expected.
if ($path == 'node') {
$this->assertLink(t('1 comment'));
$this->assertSession()->linkExists(t('1 comment'));
}
$this->assertLink('Add new comment');
$this->assertSession()->linkExists('Add new comment');
}
$display_repository = $this->container->get('entity_display.repository');
@@ -133,13 +133,13 @@ class CommentLinksTest extends CommentTestBase {
->removeComponent('links')
->save();
$this->drupalGet($this->node->toUrl());
$this->assertNoLink('1 comment');
$this->assertNoLink('Add new comment');
$this->assertSession()->linkNotExists('1 comment');
$this->assertSession()->linkNotExists('Add new comment');
// Visit the full node, make sure there are links for the comment.
$this->drupalGet('node/' . $this->node->id());
$this->assertText($comment->getSubject());
$this->assertLink('Reply');
$this->assertSession()->linkExists('Reply');
// Make sure we can hide comment links.
$display_repository->getViewDisplay('comment', 'comment')
@@ -147,7 +147,7 @@ class CommentLinksTest extends CommentTestBase {
->save();
$this->drupalGet('node/' . $this->node->id());
$this->assertText($comment->getSubject());
$this->assertNoLink('Reply');
$this->assertSession()->linkNotExists('Reply');
}
}
@@ -60,8 +60,8 @@ class CommentNewIndicatorTest extends CommentTestBase {
// node.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node');
$this->assertNoLink(t('@count comments', ['@count' => 0]));
$this->assertLink(t('Read more'));
$this->assertSession()->linkNotExists(t('@count comments', ['@count' => 0]));
$this->assertSession()->linkExists(t('Read more'));
// Verify the data-history-node-last-comment-timestamp attribute, which is
// used by the drupal.node-new-comments-link library to determine whether
// a "x new comments" link might be necessary or not. We do this in
@@ -355,7 +355,7 @@ class CommentNonNodeTest extends BrowserTestBase {
// Attempt to view comments while disallowed.
$this->drupalGet('entity-test/' . $this->entity->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.');
$this->assertSession()->linkNotExists('Add new comment', 'Link to add comment was found.');
// Attempt to view test entity comment form while disallowed.
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
@@ -371,8 +371,8 @@ class CommentNonNodeTest extends BrowserTestBase {
]);
$this->drupalGet('entity_test/' . $this->entity->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 0, 'Link to login was found.');
$this->assertLink('register', 0, 'Link to register was found.');
$this->assertSession()->linkExists('Log in', 0, 'Link to login was found.');
$this->assertSession()->linkExists('register', 0, 'Link to register was found.');
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.');
@@ -128,7 +128,12 @@ class CommentPreviewTest extends CommentTestBase {
* Tests comment edit, preview, and save.
*/
public function testCommentEditPreviewSave() {
$web_user = $this->drupalCreateUser(['access comments', 'post comments', 'skip comment approval', 'edit own comments']);
$web_user = $this->drupalCreateUser([
'access comments',
'post comments',
'skip comment approval',
'edit own comments',
]);
$this->drupalLogin($this->adminUser);
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE);
@@ -35,7 +35,9 @@ class ConfigDependencyWebTest extends BrowserTestBase {
* @see \Drupal\Core\Config\Entity\ConfigDependencyDeleteFormTrait
*/
public function testConfigDependencyDeleteFormTrait() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = $this->container->get('entity_type.manager')->getStorage('config_test');
@@ -25,7 +25,9 @@ class ConfigEntityFormOverrideTest extends BrowserTestBase {
* Tests that overrides do not affect forms or listing screens.
*/
public function testFormsWithOverrides() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$original_label = 'Default';
$overridden_label = 'Overridden label';
@@ -41,7 +41,10 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase {
*/
public function testListUI() {
// Log in as an administrative user to access the full menu trail.
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer site configuration',
]));
// Get the list page.
$this->drupalGet('admin/structure/config_test');
@@ -156,7 +156,10 @@ class ConfigEntityListTest extends BrowserTestBase {
*/
public function testListUI() {
// Log in as an administrative user to access the full menu trail.
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer site configuration',
]));
// Get the list callback page.
$this->drupalGet('admin/structure/config_test');
@@ -190,7 +193,7 @@ class ConfigEntityListTest extends BrowserTestBase {
$this->assertNotEmpty($elements[2]->find('xpath', '//ul'), 'Operations list found.');
// Add a new entity using the operations link.
$this->assertLink('Add test configuration');
$this->assertSession()->linkExists('Add test configuration');
$this->clickLink('Add test configuration');
$this->assertSession()->statusCodeEquals(200);
$edit = [
@@ -254,7 +257,9 @@ class ConfigEntityListTest extends BrowserTestBase {
* Test paging.
*/
public function testPager() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$storage = \Drupal::service('entity_type.manager')->getListBuilder('config_test')->getStorage();
@@ -27,7 +27,9 @@ class ConfigEntityStatusUITest extends BrowserTestBase {
* Tests status operations.
*/
public function testCRUD() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$id = strtolower($this->randomMachineName());
$edit = [
@@ -236,7 +236,9 @@ class ConfigEntityTest extends BrowserTestBase {
* Tests CRUD operations through the UI.
*/
public function testCRUDUI() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$id = strtolower($this->randomMachineName());
$label1 = $this->randomMachineName();
@@ -21,7 +21,10 @@ class ConfigFormOverrideTest extends BrowserTestBase {
* Tests that overrides do not affect forms.
*/
public function testFormsWithOverrides() {
$this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer site configuration',
]));
$overridden_name = 'Site name global conf override';
@@ -34,7 +34,11 @@ class ConfigInstallWebTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['administer modules', 'administer themes', 'administer site configuration']);
$this->adminUser = $this->drupalCreateUser([
'administer modules',
'administer themes',
'administer site configuration',
]);
// Ensure the global variable being asserted by this test does not exist;
// a previous test executed in this request/process might have set it.
@@ -40,7 +40,10 @@ class ConfigLanguageOverrideWebTest extends BrowserTestBase {
* Tests translating the site name.
*/
public function testSiteNameTranslation() {
$adminUser = $this->drupalCreateUser(['administer site configuration', 'administer languages']);
$adminUser = $this->drupalCreateUser([
'administer site configuration',
'administer languages',
]);
$this->drupalLogin($adminUser);
// Add a custom language.
@@ -25,7 +25,9 @@ class ConfigEntityTest extends WebDriverTestBase {
* Tests ajax operations through the UI on 'Add' page.
*/
public function testAjaxOnAddPage() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$this->drupalLogin($this->drupalCreateUser([
'administer site configuration',
]));
$page = $this->getSession()->getPage();
$assert_session = $this->assertSession();
@@ -39,6 +39,7 @@ class ConfigTranslationInstallTest extends InstallerTestBase {
*
* @param string $langcode
* The language code.
*
* @return string
* Contents for the test .po file.
*/
@@ -126,7 +126,7 @@ class ConfigTranslationOverviewTest extends BrowserTestBase {
$this->assertRaw('<th>' . t('Language') . '</th>');
$this->drupalGet($base_url);
$this->assertLink(t('Translate @title', ['@title' => $entity_type->getSingularLabel()]));
$this->assertSession()->linkExists(t('Translate @title', ['@title' => $entity_type->getSingularLabel()]));
}
}
@@ -299,7 +299,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
// While translator can access the translation page, the edit link is not
// present due to lack of permissions.
$this->drupalGet($translation_base_url);
$this->assertNoLink(t('Edit'));
$this->assertSession()->linkNotExists(t('Edit'));
// Check 'Add' link for French.
$this->assertLinkByHref("$translation_base_url/fr/add");
@@ -331,7 +331,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
// Make sure translate tab is present.
$this->drupalGet('admin/structure/contact/manage/feedback');
$this->assertLink(t('Translate @type', ['@type' => 'contact form']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'contact form']));
// Visit the form to confirm the changes.
$this->drupalGet('contact/feedback');
@@ -339,7 +339,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
foreach ($this->langcodes as $langcode) {
$this->drupalGet($translation_base_url);
$this->assertLink(t('Translate @type', ['@type' => 'contact form']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'contact form']));
// 'Add' link should be present for $langcode translation.
$translation_page_url = "$translation_base_url/$langcode/add";
@@ -435,7 +435,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
// While translator can access the translation page, the edit link is not
// present due to lack of permissions.
$this->drupalGet($translation_base_url);
$this->assertNoLink(t('Edit'));
$this->assertSession()->linkNotExists(t('Edit'));
// Check 'Add' link for French.
$this->assertLinkByHref("$translation_base_url/fr/add");
@@ -516,10 +516,10 @@ class ConfigTranslationUiTest extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/people/accounts');
$this->assertLink(t('Translate @type', ['@type' => 'account settings']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'account settings']));
$this->drupalGet('admin/config/people/accounts/translate');
$this->assertLink(t('Translate @type', ['@type' => 'account settings']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'account settings']));
$this->assertLinkByHref('admin/config/people/accounts/translate/fr/add');
// Update account settings fields for French.
@@ -57,11 +57,19 @@ class ContactPersonalTest extends BrowserTestBase {
parent::setUp();
// Create an admin user.
$this->adminUser = $this->drupalCreateUser(['administer contact forms', 'administer users', 'administer account settings', 'access site reports']);
$this->adminUser = $this->drupalCreateUser([
'administer contact forms',
'administer users',
'administer account settings',
'access site reports',
]);
// Create some normal users with their contact forms enabled by default.
$this->config('contact.settings')->set('user_default_enabled', TRUE)->save();
$this->webUser = $this->drupalCreateUser(['access user profiles', 'access user contact forms']);
$this->webUser = $this->drupalCreateUser([
'access user profiles',
'access user contact forms',
]);
$this->contactUser = $this->drupalCreateUser();
}
@@ -59,7 +59,9 @@ class ContactSitewideTest extends BrowserTestBase {
*/
public function testSiteWideContact() {
// Tests name and email fields for authenticated and anonymous users.
$this->drupalLogin($this->drupalCreateUser(['access site-wide contact form']));
$this->drupalLogin($this->drupalCreateUser([
'access site-wide contact form',
]));
$this->drupalGet('contact');
// Ensure that there is no textfield for name.
@@ -321,37 +321,36 @@ class EntityTypeInfo implements ContainerInjectionInterface {
public function formAlter(array &$form, FormStateInterface $form_state, $form_id) {
$form_object = $form_state->getFormObject();
if ($form_object instanceof BundleEntityFormBase) {
$config_entity_type = $form_object->getEntity()->getEntityType();
$bundle_of = $config_entity_type->getBundleOf();
$config_entity = $form_object->getEntity();
$bundle_of = $config_entity->getEntityType()->getBundleOf();
if ($bundle_of
&& ($bundle_of_entity_type = $this->entityTypeManager->getDefinition($bundle_of))
&& $this->moderationInfo->canModerateEntitiesOfEntityType($bundle_of_entity_type)) {
$this->entityTypeManager->getHandler($config_entity_type->getBundleOf(), 'moderation')->enforceRevisionsBundleFormAlter($form, $form_state, $form_id);
&& $this->moderationInfo->shouldModerateEntitiesOfBundle($bundle_of_entity_type, $config_entity->id())) {
$this->entityTypeManager->getHandler($bundle_of, 'moderation')->enforceRevisionsBundleFormAlter($form, $form_state, $form_id);
}
}
elseif ($this->isModeratedEntityEditForm($form_object)) {
/** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $form_object->getEntity();
if ($this->moderationInfo->isModeratedEntity($entity)) {
$this->entityTypeManager
->getHandler($entity->getEntityTypeId(), 'moderation')
->enforceRevisionsEntityFormAlter($form, $form_state, $form_id);
// Submit handler to redirect to the latest version, if available.
$form['actions']['submit']['#submit'][] = [EntityTypeInfo::class, 'bundleFormRedirect'];
$this->entityTypeManager
->getHandler($entity->getEntityTypeId(), 'moderation')
->enforceRevisionsEntityFormAlter($form, $form_state, $form_id);
// Move the 'moderation_state' field widget to the footer region, if
// available.
if (isset($form['footer']) && in_array($form_object->getOperation(), ['edit', 'default'], TRUE)) {
$form['moderation_state']['#group'] = 'footer';
}
// Submit handler to redirect to the latest version, if available.
$form['actions']['submit']['#submit'][] = [EntityTypeInfo::class, 'bundleFormRedirect'];
// If the publishing status exists in the meta region, replace it with
// the current state instead.
if (isset($form['meta']['published'])) {
$form['meta']['published']['#markup'] = $this->moderationInfo->getWorkflowForEntity($entity)->getTypePlugin()->getState($entity->moderation_state->value)->label();
}
// Move the 'moderation_state' field widget to the footer region, if
// available.
if (isset($form['footer']) && in_array($form_object->getOperation(), ['edit', 'default'], TRUE)) {
$form['moderation_state']['#group'] = 'footer';
}
// If the publishing status exists in the meta region, replace it with
// the current state instead.
if (isset($form['meta']['published'])) {
$form['meta']['published']['#markup'] = $this->moderationInfo->getWorkflowForEntity($entity)->getTypePlugin()->getState($entity->moderation_state->value)->label();
}
}
}
@@ -81,6 +81,7 @@ class ModerationStateFieldItemList extends FieldItemList {
// being reverted.
->condition('content_entity_revision_id', $entity->isNewRevision() ? $entity->getLoadedRevisionId() : $entity->getRevisionId())
->condition('workflow', $moderation_info->getWorkflowForEntity($entity)->id())
->condition('langcode', $entity->language()->getId())
->allRevisions()
->sort('revision_id', 'DESC')
->execute();
@@ -54,7 +54,12 @@ class ModeratedContentViewTest extends BrowserTestBase {
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'article');
$workflow->save();
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'view any unpublished content', 'administer nodes', 'bypass node access']);
$this->adminUser = $this->drupalCreateUser([
'access administration pages',
'view any unpublished content',
'administer nodes',
'bypass node access',
]);
}
/**
@@ -67,9 +67,18 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
], t('Save'));
$this->assertText('Not moderated Test has been created.');
// Check that the 'Create new revision' is not disabled.
$this->drupalGet('/admin/structure/types/manage/not_moderated');
$this->assertNull($this->assertSession()->fieldExists('options[revision]')->getAttribute('disabled'));
// Now enable moderation state.
$this->enableModerationThroughUi('not_moderated');
// Check that the 'Create new revision' checkbox is checked and disabled.
$this->drupalGet('/admin/structure/types/manage/not_moderated');
$this->assertSession()->checkboxChecked('options[revision]');
$this->assertSession()->fieldDisabled('options[revision]');
// And make sure it works.
$nodes = \Drupal::entityTypeManager()->getStorage('node')
->loadByProperties(['title' => 'Test']);
@@ -112,10 +112,6 @@ abstract class ModerationStateTestBase extends BrowserTestBase {
$this->drupalGet('admin/structure/types');
$this->clickLink('Add content type');
// Check that the 'Create new revision' checkbox is checked and disabled.
$this->assertSession()->checkboxChecked('options[revision]');
$this->assertSession()->fieldDisabled('options[revision]');
$edit = [
'name' => $content_type_name,
'type' => $content_type_id,
@@ -66,7 +66,10 @@ class ViewsModerationStateFilterTest extends ViewTestBase {
$new_workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example_c');
$new_workflow->save();
$this->drupalLogin($this->drupalCreateUser(['administer workflows', 'administer views']));
$this->drupalLogin($this->drupalCreateUser([
'administer workflows',
'administer views',
]));
$this->container->get('module_installer')->install(['content_moderation_test_views']);
@@ -401,4 +401,33 @@ class ModerationStateFieldItemListTest extends KernelTestBase {
$this->assertEquals('published', $translation->moderation_state->value);
}
/**
* Tests field item list translation support with unmoderated content.
*/
public function testTranslationWithExistingUnmoderatedContent() {
$node = Node::create([
'title' => 'Published en',
'langcode' => 'en',
'type' => 'unmoderated',
]);
$node->setPublished();
$node->save();
$workflow = Workflow::load('editorial');
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'unmoderated');
$workflow->save();
$translation = $node->addTranslation('de');
$translation->moderation_state = 'draft';
$translation->save();
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$node = $node_storage->loadRevision($node_storage->getLatestRevisionId($node->id()));
$this->assertEquals('published', $node->moderation_state->value);
$this->assertEquals('draft', $translation->moderation_state->value);
$this->assertTrue($node->isPublished());
$this->assertFalse($translation->isPublished());
}
}
@@ -99,6 +99,7 @@ class ContentTranslationController extends ControllerBase {
* The route match.
* @param string $entity_type_id
* (optional) The entity type ID.
*
* @return array
* Array of page elements to render.
*/
@@ -26,7 +26,12 @@ class ContentTranslationEntityBundleUITest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$user = $this->drupalCreateUser(['access administration pages', 'administer languages', 'administer content translation', 'administer content types']);
$user = $this->drupalCreateUser([
'access administration pages',
'administer languages',
'administer content translation',
'administer content types',
]);
$this->drupalLogin($user);
}
@@ -64,7 +64,12 @@ class ContentTranslationOperationsTest extends NodeTestBase {
\Drupal::service('router.builder')->rebuild();
$this->baseUser1 = $this->drupalCreateUser(['access content overview']);
$this->baseUser2 = $this->drupalCreateUser(['access content overview', 'create content translations', 'update content translations', 'delete content translations']);
$this->baseUser2 = $this->drupalCreateUser([
'access content overview',
'create content translations',
'update content translations',
'delete content translations',
]);
}
/**
@@ -49,7 +49,17 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
$this->addDefaultCommentField('node', 'article', 'comment_article', CommentItemInterface::OPEN, 'comment_article');
$this->addDefaultCommentField('node', 'page', 'comment_page');
$admin_user = $this->drupalCreateUser(['access administration pages', 'administer languages', 'administer content translation', 'administer content types', 'administer node fields', 'administer comment fields', 'administer comments', 'administer comment types', 'administer account settings']);
$admin_user = $this->drupalCreateUser([
'access administration pages',
'administer languages',
'administer content translation',
'administer content types',
'administer node fields',
'administer comment fields',
'administer comments',
'administer comment types',
'administer account settings',
]);
$this->drupalLogin($admin_user);
}
@@ -59,7 +69,7 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
public function testSettingsUI() {
// Check for the content_translation_menu_links_discovered_alter() changes.
$this->drupalGet('admin/config');
$this->assertLink('Content language and translation');
$this->assertSession()->linkExists('Content language and translation');
$this->assertText('Configure language and translation support for content.');
// Test that the translation settings are ignored if the bundle is marked
// translatable but the entity type is not.
@@ -125,7 +125,11 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
$ops = ['create' => t('Add'), 'update' => t('Edit'), 'delete' => t('Delete')];
$translations_url = $this->entity->toUrl('drupal:content-translation-overview');
foreach ($ops as $current_op => $item) {
$user = $this->drupalCreateUser([$this->getTranslatePermission(), "$current_op content translations", 'view test entity']);
$user = $this->drupalCreateUser([
$this->getTranslatePermission(),
"$current_op content translations",
'view test entity',
]);
$this->drupalLogin($user);
$this->drupalGet($translations_url);
@@ -138,10 +142,10 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
foreach ($ops as $op => $label) {
if ($op != $current_op) {
$this->assertNoLink($label, new FormattableMarkup('No %op link found.', ['%op' => $label]));
$this->assertSession()->linkNotExists($label, new FormattableMarkup('No %op link found.', ['%op' => $label]));
}
else {
$this->assertLink($label, 0, new FormattableMarkup('%op link found.', ['%op' => $label]));
$this->assertSession()->linkExists($label, 0, new FormattableMarkup('%op link found.', ['%op' => $label]));
}
}
}
@@ -66,8 +66,15 @@ class ContextualDynamicContextTest extends BrowserTestBase {
ConfigurableLanguage::createFromLangcode('it')->save();
$this->rebuildContainer();
$this->editorUser = $this->drupalCreateUser(['access content', 'access contextual links', 'edit any article content']);
$this->authenticatedUser = $this->drupalCreateUser(['access content', 'access contextual links']);
$this->editorUser = $this->drupalCreateUser([
'access content',
'access contextual links',
'edit any article content',
]);
$this->authenticatedUser = $this->drupalCreateUser([
'access content',
'access contextual links',
]);
$this->anonymousUser = $this->drupalCreateUser(['access content']);
}
@@ -460,23 +460,23 @@ class DateTimeFieldTest extends DateTestBase {
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-year\"]", NULL, 'Year element found.');
$this->assertOptionSelected("edit-$field_name-0-value-year", '', 'No year selected.');
$this->assertOptionByText("edit-$field_name-0-value-year", t('Year'));
$this->assertSession()->optionExists("edit-$field_name-0-value-year", t('Year'));
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-month\"]", NULL, 'Month element found.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '', 'No month selected.');
$this->assertOptionByText("edit-$field_name-0-value-month", t('Month'));
$this->assertSession()->optionExists("edit-$field_name-0-value-month", t('Month'));
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-day\"]", NULL, 'Day element found.');
$this->assertOptionSelected("edit-$field_name-0-value-day", '', 'No day selected.');
$this->assertOptionByText("edit-$field_name-0-value-day", t('Day'));
$this->assertSession()->optionExists("edit-$field_name-0-value-day", t('Day'));
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-hour\"]", NULL, 'Hour element found.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '', 'No hour selected.');
$this->assertOptionByText("edit-$field_name-0-value-hour", t('Hour'));
$this->assertSession()->optionExists("edit-$field_name-0-value-hour", t('Hour'));
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-minute\"]", NULL, 'Minute element found.');
$this->assertOptionSelected("edit-$field_name-0-value-minute", '', 'No minute selected.');
$this->assertOptionByText("edit-$field_name-0-value-minute", t('Minute'));
$this->assertSession()->optionExists("edit-$field_name-0-value-minute", t('Minute'));
$this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-value-second\"]", NULL, 'Second element not found.');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-ampm\"]", NULL, 'AMPM element found.');
$this->assertOptionSelected("edit-$field_name-0-value-ampm", '', 'No ampm selected.');
$this->assertOptionByText("edit-$field_name-0-value-ampm", t('AM/PM'));
$this->assertSession()->optionExists("edit-$field_name-0-value-ampm", t('AM/PM'));
// Submit a valid date and ensure it is accepted.
$date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15];
@@ -64,7 +64,12 @@ class DbLogTest extends BrowserTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create users with specific permissions.
$this->adminUser = $this->drupalCreateUser(['administer site configuration', 'access administration pages', 'access site reports', 'administer users']);
$this->adminUser = $this->drupalCreateUser([
'administer site configuration',
'access administration pages',
'access site reports',
'administer users',
]);
$this->webUser = $this->drupalCreateUser([]);
}
@@ -228,7 +233,7 @@ class DbLogTest extends BrowserTestBase {
// Verify location is available as plain text.
$this->assertEquals($request_uri, $this->cssSelect('table.dblog-event > tbody > tr:nth-child(4) > td')[0]->getHtml());
$this->assertNoLink($request_uri);
$this->assertSession()->linkNotExists($request_uri);
}
/**
@@ -782,7 +787,7 @@ class DbLogTest extends BrowserTestBase {
*/
protected function assertLogMessage($log_message, $message) {
$message_text = Unicode::truncate(Html::decodeEntities(strip_tags($log_message)), 56, TRUE, TRUE);
$this->assertLink($message_text, 0, $message);
$this->assertSession()->linkExists($message_text, 0, $message);
}
/**
@@ -105,9 +105,23 @@ class EditorLoadingTest extends BrowserTestBase {
->save();
// Create 3 users, each with access to different text formats.
$this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']);
$this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html']);
$this->privilegedUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'create page content', 'edit any page content', 'use text format filtered_html', 'use text format full_html']);
$this->untrustedUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
]);
$this->normalUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'use text format filtered_html',
]);
$this->privilegedUser = $this->drupalCreateUser([
'create article content',
'edit any article content',
'create page content',
'edit any page content',
'use text format filtered_html',
'use text format full_html',
]);
}
/**
@@ -66,7 +66,10 @@ class EditorUploadImageScaleTest extends BrowserTestBase {
])->save();
// Create admin user.
$this->adminUser = $this->drupalCreateUser(['administer filters', 'use text format basic_html']);
$this->adminUser = $this->drupalCreateUser([
'administer filters',
'use text format basic_html',
]);
$this->drupalLogin($this->adminUser);
}
+2 -2
View File
@@ -17,8 +17,8 @@
*
* In the Field API, each field has a type, which determines what kind of data
* (integer, string, date, etc.) the field can hold, which settings it provides,
* and so on. The data type(s) accepted by a field are defined in
* hook_field_schema().
* and so on. The data type(s) accepted by a field are defined in the class
* implementing \Drupal\Core\Field\FieldItemInterface::schema() method.
*
* Field types are plugins annotated with class
* \Drupal\Core\Field\Annotation\FieldType, and implement plugin interface
@@ -175,12 +175,14 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
* The custom storage indexes for the field data storage.
*
* This set of indexes is merged with the "default" indexes specified by the
* field type in hook_field_schema() to determine the actual set of indexes
* that get created.
* field type in the class implementing
* \Drupal\Core\Field\FieldItemInterface::schema() method to determine the
* actual set of indexes that get created.
*
* The indexes are defined using the same definition format as Schema API
* index specifications. Only columns that are part of the field schema, as
* defined by the field type in hook_field_schema(), are allowed.
* defined by the field type in the class implementing
* \Drupal\Core\Field\FieldItemInterface::schema() method, are allowed.
*
* Some storage backends might not support indexes, and discard that
* information.
@@ -24,6 +24,7 @@ abstract class FieldTestBase extends WebTestBase {
*
* @param $cardinality
* Number of values to generate.
*
* @return
* An array of random values, in the format expected for field values.
*/
@@ -58,6 +58,7 @@ require_once __DIR__ . '/field_test.field.inc';
* The key under which to store to $value, or NULL as described above.
* @param $value
* A value to store for $key.
*
* @return
* An array mapping each $key to an array of each $value passed in
* for that key.
@@ -50,7 +50,14 @@ class BooleanFormatterSettingsTest extends BrowserTestBase {
$type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
$this->bundle = $type->id();
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node display', 'bypass node access', 'administer nodes']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node display',
'bypass node access',
'administer nodes',
]);
$this->drupalLogin($admin_user);
$this->fieldName = mb_strtolower($this->randomMachineName(8));
@@ -192,7 +192,7 @@ class EntityReferenceAdminTest extends BrowserTestBase {
'field_test_entity_ref_field[0][target_id]' => $node1->getTitle() . ' (' . $node1->id() . ')',
];
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
$this->assertLink($node1->getTitle());
$this->assertSession()->linkExists($node1->getTitle());
// Tests adding default values to autocomplete widgets.
Vocabulary::create(['vid' => 'tags', 'name' => 'tags'])->save();
@@ -92,7 +92,10 @@ class EntityReferenceAutoCreateTest extends BrowserTestBase {
])
->save();
$account = $this->drupalCreateUser(['access content', "create $this->referencingType content"]);
$account = $this->drupalCreateUser([
'access content',
"create $this->referencingType content",
]);
$this->drupalLogin($account);
}
@@ -44,7 +44,13 @@ class EntityReferenceFieldDefaultValueTest extends BrowserTestBase {
$this->drupalCreateContentType(['type' => 'referenced_content']);
// Create admin user.
$this->adminUser = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'bypass node access']);
$this->adminUser = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node form display',
'bypass node access',
]);
$this->drupalLogin($this->adminUser);
}
@@ -147,7 +147,9 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
$this->setUpEntityReferenceField();
$this->createContent();
$this->webUser = $this->drupalCreateUser(['edit any ' . $this->referrerType->id() . ' content']);
$this->webUser = $this->drupalCreateUser([
'edit any ' . $this->referrerType->id() . ' content',
]);
}
/**
@@ -121,7 +121,10 @@ class EntityReferenceFileUploadTest extends BrowserTestBase {
* Tests that the autocomplete input element does not cause ajax fatal.
*/
public function testFileUpload() {
$user1 = $this->drupalCreateUser(['access content', "create $this->referencingType content"]);
$user1 = $this->drupalCreateUser([
'access content',
"create $this->referencingType content",
]);
$this->drupalLogin($user1);
$test_file = current($this->getTestFiles('text'));
@@ -59,7 +59,11 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
parent::setUp();
// Create a test user.
$web_user = $this->drupalCreateUser(['administer entity_test content', 'administer entity_test fields', 'view test entity']);
$web_user = $this->drupalCreateUser([
'administer entity_test content',
'administer entity_test fields',
'view test entity',
]);
$this->drupalLogin($web_user);
}
@@ -35,7 +35,10 @@ class FieldHelpTest extends BrowserTestBase {
parent::setUp();
// Create the admin user.
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme']);
$this->adminUser = $this->drupalCreateUser([
'access administration pages',
'view the administration theme',
]);
}
/**
@@ -55,10 +58,10 @@ class FieldHelpTest extends BrowserTestBase {
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
$this->drupalGet('admin/help/field');
$this->assertLink('Options', 0, 'Options module is listed on the Field help page.');
$this->assertSession()->linkExists('Options', 0, 'Options module is listed on the Field help page.');
$this->assertText('Field API Test', 'Modules with field types that do not implement hook_help are listed.');
$this->assertNoLink('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
$this->assertNoLink('Link', 'Modules that have not been installed, are not listed.');
$this->assertSession()->linkNotExists('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
$this->assertSession()->linkNotExists('Link', 'Modules that have not been installed, are not listed.');
}
}
@@ -17,6 +17,7 @@ abstract class FieldTestBase extends BrowserTestBase {
*
* @param $cardinality
* Number of values to generate.
*
* @return
* An array of random values, in the format expected for field values.
*/
@@ -69,7 +69,10 @@ class FormTest extends FieldTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
]);
$this->drupalLogin($web_user);
$this->fieldStorageSingle = [
@@ -28,7 +28,10 @@ class NestedFormTest extends FieldTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
]);
$this->drupalLogin($web_user);
$this->fieldStorageSingle = [
@@ -96,7 +96,10 @@ class ReEnableModuleFieldTest extends BrowserTestBase {
// Test that the module can't be uninstalled from the UI while there is data
// for its fields.
$admin_user = $this->drupalCreateUser(['access administration pages', 'administer modules']);
$admin_user = $this->drupalCreateUser([
'access administration pages',
'administer modules',
]);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/modules/uninstall');
$this->assertText("The Telephone number field type is used in the following field: node.field_telephone");
@@ -37,7 +37,11 @@ class StringFieldTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$this->webUser = $this->drupalCreateUser(['view test entity', 'administer entity_test content', 'access content']);
$this->webUser = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
'access content',
]);
$this->drupalLogin($this->webUser);
}
@@ -92,7 +92,10 @@ class TranslationWebTest extends FieldTestBase {
* Tests field translations when creating a new revision.
*/
public function testFieldFormTranslationRevisions() {
$web_user = $this->drupalCreateUser(['view test entity', 'administer entity_test content']);
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
]);
$this->drupalLogin($web_user);
// Prepare the field translations.
@@ -163,6 +163,7 @@ abstract class FieldKernelTestBase extends KernelTestBase {
*
* @param $cardinality
* Number of values to generate.
*
* @return
* An array of random values, in the format expected for field values.
*/
@@ -60,7 +60,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
$this->assertSession()->statusCodeEquals(404);
$this->drupalGet('admin/structure/display-modes/view/add');
$this->assertNoLink(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.');
$this->assertSession()->linkNotExists(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.');
// Test adding a view mode including dots in machine_name.
$this->clickLink(t('Test entity'));
@@ -114,7 +114,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
$this->assertSession()->statusCodeEquals(404);
$this->drupalGet('admin/structure/display-modes/form/add');
$this->assertNoLink(t('Entity Test without label'), 'An entity type with no form cannot have form modes.');
$this->assertSession()->linkNotExists(t('Entity Test without label'), 'An entity type with no form cannot have form modes.');
// Test adding a view mode including dots in machine_name.
$this->clickLink(t('Test entity'));
@@ -54,7 +54,17 @@ class FieldUIDeleteTest extends BrowserTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create a test user.
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node form display',
'administer node display',
'administer users',
'administer account settings',
'administer user display',
'bypass node access',
]);
$this->drupalLogin($admin_user);
}
@@ -30,7 +30,11 @@ class FieldUIIndentationTest extends BrowserTestBase {
parent::setUp();
// Create a test user.
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node display']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node display',
]);
$this->drupalLogin($admin_user);
// Create Basic page node type.
@@ -87,7 +87,7 @@ class FieldUIRouteTest extends BrowserTestBase {
$edit = ['display_modes_custom[test]' => TRUE];
$this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save'));
$this->assertLink('Test');
$this->assertSession()->linkExists('Test');
// Create new form mode and verify it's available on the Manage Form
// Display screen after enabling it.
@@ -100,17 +100,17 @@ class FieldUIRouteTest extends BrowserTestBase {
$edit = ['display_modes_custom[test]' => TRUE];
$this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save'));
$this->assertLink('Test');
$this->assertSession()->linkExists('Test');
}
/**
* Asserts that local tasks exists.
*/
public function assertLocalTasks() {
$this->assertLink('Settings');
$this->assertLink('Manage fields');
$this->assertLink('Manage display');
$this->assertLink('Manage form display');
$this->assertSession()->linkExists('Settings');
$this->assertSession()->linkExists('Manage fields');
$this->assertSession()->linkExists('Manage display');
$this->assertSession()->linkExists('Manage form display');
}
/**
@@ -49,7 +49,20 @@ class ManageDisplayTest extends BrowserTestBase {
$this->drupalPlaceBlock('local_tasks_block');
// Create a test user.
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node form display',
'administer node display',
'administer taxonomy',
'administer taxonomy_term fields',
'administer taxonomy_term display',
'administer users',
'administer account settings',
'administer user display',
'bypass node access',
]);
$this->drupalLogin($admin_user);
// Create content type, with underscores.
@@ -149,12 +162,12 @@ class ManageDisplayTest extends BrowserTestBase {
public function testViewModeLocalTasks() {
$manage_display = 'admin/structure/types/manage/' . $this->type . '/display';
$this->drupalGet($manage_display);
$this->assertNoLink('Full content');
$this->assertLink('Teaser');
$this->assertSession()->linkNotExists('Full content');
$this->assertSession()->linkExists('Teaser');
$this->drupalGet($manage_display . '/teaser');
$this->assertNoLink('Full content');
$this->assertLink('Default');
$this->assertSession()->linkNotExists('Full content');
$this->assertSession()->linkExists('Default');
}
/**
@@ -225,6 +238,7 @@ class ManageDisplayTest extends BrowserTestBase {
* Plain text to look for.
* @param $message
* Message to display.
*
* @return
* TRUE on pass, FALSE on fail.
*/
@@ -81,7 +81,20 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
$this->drupalPlaceBlock('page_title_block');
// Create a test user.
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer taxonomy', 'administer taxonomy_term fields', 'administer taxonomy_term display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node form display',
'administer node display',
'administer taxonomy',
'administer taxonomy_term fields',
'administer taxonomy_term display',
'administer users',
'administer account settings',
'administer user display',
'bypass node access',
]);
$this->drupalLogin($admin_user);
// Create content type, with underscores.
@@ -158,7 +171,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
}
// Test the "Add field" action link.
$this->assertLink('Add field');
$this->assertSession()->linkExists('Add field');
// Assert entity operations for all fields.
$number_of_links = 3;
@@ -278,9 +291,9 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
$this->assertFieldByXPath("//input[@name='cardinality_number']", 6);
// Check that tabs displayed.
$this->assertLink(t('Edit'));
$this->assertSession()->linkExists(t('Edit'));
$this->assertLinkByHref('admin/structure/types/manage/article/fields/node.article.body');
$this->assertLink(t('Field settings'));
$this->assertSession()->linkExists(t('Field settings'));
$this->assertLinkByHref($field_edit_path);
// Add two entries in the body.
@@ -51,7 +51,17 @@ class ManageDisplayTest extends WebDriverTestBase {
$this->drupalPlaceBlock('system_breadcrumb_block');
// Create a test user.
$admin_user = $this->drupalCreateUser(['access content', 'administer content types', 'administer node fields', 'administer node form display', 'administer node display', 'administer users', 'administer account settings', 'administer user display', 'bypass node access']);
$admin_user = $this->drupalCreateUser([
'access content',
'administer content types',
'administer node fields',
'administer node form display',
'administer node display',
'administer users',
'administer account settings',
'administer user display',
'bypass node access',
]);
$this->drupalLogin($admin_user);
// Create content type, with underscores.
@@ -47,7 +47,7 @@ trait FieldUiTestTrait {
$this->drupalPostForm($bundle_path, $initial_edit, t('Save and continue'));
$this->assertRaw(t('These settings apply to the %label field everywhere it is used.', ['%label' => $label]), 'Storage settings page was displayed.');
// Test Breadcrumbs.
$this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
$this->assertSession()->linkExists($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.');
// Second step: 'Storage settings' form.
$this->drupalPostForm(NULL, $storage_edit, t('Save field settings'));
@@ -115,7 +115,7 @@ trait FieldUiTestTrait {
$this->assertRaw(t('Are you sure you want to delete the field %label', ['%label' => $label]), 'Delete confirmation was found.');
// Test Breadcrumbs.
$this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the field delete page.');
$this->assertSession()->linkExists($label, 0, 'Field label is correct in the breadcrumb of the field delete page.');
// Submit confirmation form.
$this->drupalPostForm(NULL, [], t('Delete'));
+1
View File
@@ -18,6 +18,7 @@
*
* @param \Drupal\file\FileInterface $file
* The file entity being validated.
*
* @return array
* An array of error messages. If there are no problems with the file return
* an empty array.
@@ -148,6 +148,7 @@ abstract class FileManagedTestBase extends WebTestBase {
* @param string $scheme
* Optional string indicating the stream scheme to use. Drupal core includes
* public, private, and temporary. The public wrapper is the default.
*
* @return \Drupal\file\FileInterface
* File entity.
*/
@@ -63,14 +63,13 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
// Check that the RSS enclosure appears in the RSS feed.
$this->drupalGet('rss.xml');
$uploaded_filename = str_replace('public://', '', $node_file->getFileUri());
$selector = sprintf(
'enclosure[@url="%s"][@length="%s"][@type="%s"]',
file_create_url("public://$uploaded_filename", ['absolute' => TRUE]),
'//enclosure[@url="%s" and @length="%s" and @type="%s"]',
file_create_url($node_file->getFileUri()),
$node_file->getSize(),
$node_file->getMimeType()
);
$this->assertNotNull($this->getSession()->getDriver()->find('xpath', $selector), 'File field RSS enclosure is displayed when viewing the RSS feed.');
$this->assertNotEmpty($this->getSession()->getDriver()->find($selector), 'File field RSS enclosure is displayed when viewing the RSS feed.');
}
}

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