Issue #3138078 by mondrake, larowlan, longwave, xjm: [D9.3 beta - w/c Nov 8, 2021] Add a 'void' return typehint to custom assert* methods
(cherry picked from commit 92836c436b
)
merge-requests/1436/head
parent
2eec3dc4cb
commit
37a54000b8
|
@ -57,8 +57,10 @@ class MigrateActionsTest extends MigrateDrupal6TestBase {
|
|||
* The expected Action type.
|
||||
* @param array $configuration
|
||||
* The expected Action configuration.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $label, $type, $configuration) {
|
||||
protected function assertEntity(string $id, string $label, string $type, array $configuration): void {
|
||||
$action = Action::load($id);
|
||||
|
||||
$this->assertInstanceOf(Action::class, $action);
|
||||
|
|
|
@ -57,8 +57,10 @@ class MigrateActionsTest extends MigrateDrupal7TestBase {
|
|||
* The expected Action type.
|
||||
* @param array $configuration
|
||||
* The expected Action configuration.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $label, $type, $configuration) {
|
||||
protected function assertEntity(string $id, string $label, string $type, array $configuration): void {
|
||||
$action = Action::load($id);
|
||||
|
||||
$this->assertInstanceOf(Action::class, $action);
|
||||
|
|
|
@ -327,7 +327,10 @@ class BigPipeTest extends BrowserTestBase {
|
|||
$this->assertSession()->responseNotContains('The count is 3.');
|
||||
}
|
||||
|
||||
protected function assertBigPipeResponseHeadersPresent() {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBigPipeResponseHeadersPresent(): void {
|
||||
// Check that Cache-Control header set to "private".
|
||||
$this->assertSession()->responseHeaderContains('Cache-Control', 'private');
|
||||
$this->assertSession()->responseHeaderEquals('Surrogate-Control', 'no-store, content="BigPipe/1.0"');
|
||||
|
@ -340,8 +343,10 @@ class BigPipeTest extends BrowserTestBase {
|
|||
* @param array $expected_big_pipe_nojs_placeholders
|
||||
* Keys: BigPipe no-JS placeholder markup. Values: expected replacement
|
||||
* markup.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_placeholders) {
|
||||
protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_placeholders): void {
|
||||
$this->assertSetsEqual(array_keys($expected_big_pipe_nojs_placeholders), array_map('rawurldecode', explode(' ', $this->getSession()->getResponseHeader('BigPipe-Test-No-Js-Placeholders'))));
|
||||
foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
|
||||
// Checking whether the replacement for the BigPipe no-JS placeholder
|
||||
|
@ -361,8 +366,10 @@ class BigPipeTest extends BrowserTestBase {
|
|||
* @param array $expected_big_pipe_placeholder_stream_order
|
||||
* Keys: BigPipe placeholder IDs. Values: expected AJAX response. Keys are
|
||||
* defined in the order that they are expected to be rendered & streamed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholders, array $expected_big_pipe_placeholder_stream_order) {
|
||||
protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholders, array $expected_big_pipe_placeholder_stream_order): void {
|
||||
$this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->getSession()->getResponseHeader('BigPipe-Test-Placeholders')));
|
||||
$placeholder_positions = [];
|
||||
$placeholder_replacement_positions = [];
|
||||
|
@ -437,36 +444,49 @@ class BigPipeTest extends BrowserTestBase {
|
|||
|
||||
/**
|
||||
* Asserts whether arrays A and B are equal, when treated as sets.
|
||||
*
|
||||
* @todo This method is broken. Fix it in
|
||||
* https://www.drupal.org/project/drupal/issues/3144926
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSetsEqual(array $a, array $b) {
|
||||
return count($a) == count($b) && !array_diff_assoc($a, $b);
|
||||
protected function assertSetsEqual(array $a, array $b): void {
|
||||
$result = count($a) == count($b) && !array_diff_assoc($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts whether a BigPipe no-JS cookie exists or not.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBigPipeNoJsCookieExists($expected) {
|
||||
protected function assertBigPipeNoJsCookieExists(string $expected): void {
|
||||
$this->assertCookieExists('big_pipe_nojs', $expected, 'BigPipe no-JS');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts whether a session cookie exists or not.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSessionCookieExists($expected) {
|
||||
protected function assertSessionCookieExists(string $expected): void {
|
||||
$this->assertCookieExists($this->getSessionName(), $expected, 'Session');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts whether a cookie exists on the client or not.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCookieExists($cookie_name, $expected, $cookie_label) {
|
||||
protected function assertCookieExists(string $cookie_name, string $expected, string $cookie_label): void {
|
||||
$this->assertEquals($expected, !empty($this->getSession()->getCookie($cookie_name)), $expected ? "$cookie_label cookie exists." : "$cookie_label cookie does not exist.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls ::performMetaRefresh() and asserts the responses.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBigPipeNoJsMetaRefreshRedirect() {
|
||||
protected function assertBigPipeNoJsMetaRefreshRedirect(): void {
|
||||
$original_url = $this->getSession()->getCurrentUrl();
|
||||
|
||||
// Disable automatic following of redirects by the HTTP client, so that this
|
||||
|
|
|
@ -288,8 +288,10 @@ class BlockViewBuilderTest extends KernelTestBase {
|
|||
* The expected cache tags.
|
||||
* @param int $expected_max_age
|
||||
* The expected max-age.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBlockRenderedWithExpectedCacheability(array $expected_keys, array $expected_contexts, array $expected_tags, $expected_max_age) {
|
||||
protected function assertBlockRenderedWithExpectedCacheability(array $expected_keys, array $expected_contexts, array $expected_tags, int $expected_max_age): void {
|
||||
$required_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions'];
|
||||
|
||||
// Check that the expected cacheability metadata is present in:
|
||||
|
|
|
@ -69,14 +69,16 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
|
|||
* The display region.
|
||||
* @param string $theme
|
||||
* The theme.
|
||||
* @param string $weight
|
||||
* @param int $weight
|
||||
* The block weight.
|
||||
* @param array $settings
|
||||
* (optional) The block settings.
|
||||
* @param bool $status
|
||||
* Whether the block is expected to be enabled or disabled.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertEntity($id, $visibility, $region, $theme, $weight, array $settings = NULL, $status = TRUE) {
|
||||
public function assertEntity(string $id, array $visibility, string $region, string $theme, int $weight, array $settings = NULL, bool $status = TRUE): void {
|
||||
$block = Block::load($id);
|
||||
$this->assertInstanceOf(Block::class, $block);
|
||||
$this->assertSame($visibility, $block->getVisibility());
|
||||
|
|
|
@ -73,7 +73,7 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
|
|||
* The display region.
|
||||
* @param string $theme
|
||||
* The theme.
|
||||
* @param string $weight
|
||||
* @param int $weight
|
||||
* The block weight.
|
||||
* @param string $label
|
||||
* The block label.
|
||||
|
@ -81,8 +81,10 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
|
|||
* The block label display setting.
|
||||
* @param bool $status
|
||||
* Whether the block is expected to be enabled or disabled.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight, $label, $label_display, $status = TRUE) {
|
||||
public function assertEntity(string $id, string $plugin_id, array $roles, string $pages, string $region, string $theme, int $weight, string $label, string $label_display, bool $status = TRUE): void {
|
||||
$block = Block::load($id);
|
||||
$this->assertInstanceOf(Block::class, $block);
|
||||
/** @var \Drupal\block\BlockInterface $block */
|
||||
|
|
|
@ -99,8 +99,10 @@ class BlockContentFieldFilterTest extends BlockContentTestBase {
|
|||
* that translation should be shown on the given page.
|
||||
* @param string $message
|
||||
* Message suffix to display.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertPageCounts($path, $counts, $message) {
|
||||
protected function assertPageCounts(string $path, array $counts, string $message): void {
|
||||
// Get the text of the page.
|
||||
$this->drupalGet($path);
|
||||
$text = $this->getTextContent();
|
||||
|
|
|
@ -59,8 +59,10 @@ class BlockContentIntegrationTest extends BlockContentTestBase {
|
|||
*
|
||||
* @param array $expected_ids
|
||||
* An array of block_content IDs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertIds(array $expected_ids = []) {
|
||||
protected function assertIds(array $expected_ids = []): void {
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$ids = [];
|
||||
foreach ($result as $element) {
|
||||
|
|
|
@ -38,8 +38,10 @@ class MigrateBlockContentEntityDisplayTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID.
|
||||
* @param string $component_id
|
||||
* The ID of the display component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisplay($id, $component_id) {
|
||||
protected function assertDisplay(string $id, string $component_id): void {
|
||||
$component = EntityViewDisplay::load($id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('hidden', $component['label']);
|
||||
|
|
|
@ -38,8 +38,10 @@ class MigrateBlockContentEntityFormDisplayTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID.
|
||||
* @param string $component_id
|
||||
* The ID of the form component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisplay($id, $component_id) {
|
||||
protected function assertDisplay(string $id, string $component_id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('text_textarea_with_summary', $component['type']);
|
||||
|
|
|
@ -143,9 +143,11 @@ class BookJavascriptTest extends WebDriverTestBase {
|
|||
* @throws \Behat\Mink\Exception\ExpectationException
|
||||
* When any of the given string is not found.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @todo Remove this once https://www.drupal.org/node/2817657 is committed.
|
||||
*/
|
||||
protected function assertOrderInPage(array $items) {
|
||||
protected function assertOrderInPage(array $items): void {
|
||||
$session = $this->getSession();
|
||||
$text = $session->getPage()->getHtml();
|
||||
$strings = [];
|
||||
|
|
|
@ -289,6 +289,8 @@ class BookMultilingualTest extends KernelTestBase {
|
|||
* A book tree item.
|
||||
* @param string $langcode
|
||||
* The language code for the requested translation.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertBookItemIsCorrectlyTranslated(array $item, string $langcode): void {
|
||||
$this->assertNodeLinkIsCorrectlyTranslated($item['original_link']['nid'], $item['title'], $item['url'], $langcode);
|
||||
|
@ -305,6 +307,8 @@ class BookMultilingualTest extends KernelTestBase {
|
|||
* The URL being tested.
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNodeLinkIsCorrectlyTranslated(int $nid, string $title, Url $url, string $langcode): void {
|
||||
$node = Node::load($nid);
|
||||
|
@ -324,8 +328,10 @@ class BookMultilingualTest extends KernelTestBase {
|
|||
* The node ID.
|
||||
* @param string $indent
|
||||
* The indentation before the actual table of contents label.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertToCEntryIsCorrectlyTranslated(array $toc, string $langcode, int $nid, string $indent) {
|
||||
protected function assertToCEntryIsCorrectlyTranslated(array $toc, string $langcode, int $nid, string $indent): void {
|
||||
$node = Node::load($nid);
|
||||
$node_label = $node->getTranslation($langcode)->label();
|
||||
$this->assertSame($indent . ' ' . $node_label, $toc[$nid]);
|
||||
|
|
|
@ -473,8 +473,10 @@ class CKEditorTest extends KernelTestBase {
|
|||
* @param string $langcode
|
||||
* Language code to assert for. Defaults to French. That is the default
|
||||
* language set in this assertion.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCKEditorLanguage($langcode = 'fr') {
|
||||
protected function assertCKEditorLanguage(string $langcode = 'fr'): void {
|
||||
// Set French as the site default language.
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
$this->config('system.site')->set('default_langcode', 'fr')->save();
|
||||
|
|
|
@ -664,11 +664,13 @@ class MediaTest extends WebDriverTestBase {
|
|||
*
|
||||
* @param string $attribute
|
||||
* The attribute to check.
|
||||
* @param mixed $value
|
||||
* @param string|null $value
|
||||
* Either a string value or if NULL, asserts that <drupal-media> element
|
||||
* doesn't have the attribute.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSourceAttributeSame($attribute, $value) {
|
||||
protected function assertSourceAttributeSame(string $attribute, ?string $value): void {
|
||||
$dom = $this->getEditorDataAsDom();
|
||||
$drupal_media = (new \DOMXPath($dom))->query('//drupal-media');
|
||||
$this->assertNotEmpty($drupal_media);
|
||||
|
|
|
@ -210,8 +210,10 @@ class CommentPagerTest extends CommentTestBase {
|
|||
* An array of comments, must be of the type CommentInterface.
|
||||
* @param array $expected_order
|
||||
* An array of keys from $comments describing the expected order.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertCommentOrder(array $comments, array $expected_order) {
|
||||
public function assertCommentOrder(array $comments, array $expected_order): void {
|
||||
$expected_cids = [];
|
||||
|
||||
// First, rekey the expected order by cid.
|
||||
|
|
|
@ -131,8 +131,10 @@ class CommentThreadingTest extends CommentTestBase {
|
|||
* The comment ID to check.
|
||||
* @param int $pid
|
||||
* The expected parent comment ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertParentLink($cid, $pid) {
|
||||
protected function assertParentLink(int $cid, int $pid): void {
|
||||
// This pattern matches a markup structure like:
|
||||
// @code
|
||||
// <a id="comment-2"></a>
|
||||
|
@ -152,8 +154,10 @@ class CommentThreadingTest extends CommentTestBase {
|
|||
*
|
||||
* @param int $cid
|
||||
* The comment ID to check.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNoParentLink($cid) {
|
||||
protected function assertNoParentLink(int $cid): void {
|
||||
// This pattern matches a markup structure like:
|
||||
// @code
|
||||
// <a id="comment-2"></a>
|
||||
|
|
|
@ -108,8 +108,10 @@ class CommentFieldFilterTest extends CommentTestBase {
|
|||
* that translation should be shown on the given page.
|
||||
* @param string $message
|
||||
* Message suffix to display.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertPageCounts($path, $counts, $message) {
|
||||
protected function assertPageCounts(string $path, array $counts, string $message): void {
|
||||
// Get the text of the page.
|
||||
$this->drupalGet($path);
|
||||
$text = $this->getTextContent();
|
||||
|
|
|
@ -189,8 +189,10 @@ class CommentValidationTest extends EntityKernelTestBase {
|
|||
* The field that violates the maximum length.
|
||||
* @param int $length
|
||||
* Number of characters that was exceeded.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertLengthViolation(CommentInterface $comment, $field_name, $length) {
|
||||
protected function assertLengthViolation(CommentInterface $comment, string $field_name, int $length): void {
|
||||
$violations = $comment->validate();
|
||||
$this->assertCount(1, $violations, "Violation found when $field_name is too long.");
|
||||
$this->assertEquals("{$field_name}.0.value", $violations[0]->getPropertyPath());
|
||||
|
|
|
@ -41,8 +41,10 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal6TestBase {
|
|||
* The entity ID.
|
||||
* @param string $component_id
|
||||
* The ID of the display component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisplay($id, $component_id) {
|
||||
protected function assertDisplay(string $id, string $component_id): void {
|
||||
$component = EntityViewDisplay::load($id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('hidden', $component['label']);
|
||||
|
|
|
@ -35,8 +35,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase
|
|||
*
|
||||
* @param string $id
|
||||
* The entity form display ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSubjectVisible($id) {
|
||||
protected function assertSubjectVisible(string $id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent('subject');
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('string_textfield', $component['type']);
|
||||
|
@ -48,8 +50,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase
|
|||
*
|
||||
* @param string $id
|
||||
* The entity form display ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSubjectNotVisible($id) {
|
||||
protected function assertSubjectNotVisible(string $id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent('subject');
|
||||
$this->assertNull($component);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,10 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal6TestBase {
|
|||
* The entity ID.
|
||||
* @param string $component_id
|
||||
* The ID of the form component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisplay($id, $component_id) {
|
||||
protected function assertDisplay(string $id, string $component_id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('comment_default', $component['type']);
|
||||
|
|
|
@ -45,14 +45,16 @@ class MigrateCommentFieldInstanceTest extends MigrateDrupal6TestBase {
|
|||
* The field's default_mode setting.
|
||||
* @param int $per_page
|
||||
* The field's per_page setting.
|
||||
* @param bool $anonymous
|
||||
* @param int $anonymous
|
||||
* The field's anonymous setting.
|
||||
* @param int $form_location
|
||||
* @param bool $form_location
|
||||
* The field's form_location setting.
|
||||
* @param bool $preview
|
||||
* @param int $preview
|
||||
* The field's preview setting.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($bundle, $field_name, $default_value, $default_mode, $per_page, $anonymous, $form_location, $preview) {
|
||||
protected function assertEntity(string $bundle, string $field_name, int $default_value, int $default_mode, int $per_page, int $anonymous, bool $form_location, int $preview): void {
|
||||
$entity = FieldConfig::load("node.$bundle.$field_name");
|
||||
$this->assertInstanceOf(FieldConfig::class, $entity);
|
||||
$this->assertSame('node', $entity->getTargetEntityTypeId());
|
||||
|
|
|
@ -35,8 +35,10 @@ class MigrateCommentFieldTest extends MigrateDrupal6TestBase {
|
|||
*
|
||||
* @param string $comment_type
|
||||
* The comment type.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($comment_type) {
|
||||
protected function assertEntity(string $comment_type): void {
|
||||
$entity = FieldStorageConfig::load('node.' . $comment_type);
|
||||
$this->assertInstanceOf(FieldStorageConfig::class, $entity);
|
||||
$this->assertSame('node', $entity->getTargetEntityTypeId());
|
||||
|
|
|
@ -25,8 +25,10 @@ class MigrateCommentTypeTest extends MigrateDrupal6TestBase {
|
|||
* The entity ID.
|
||||
* @param string $label
|
||||
* The entity label.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $label) {
|
||||
protected function assertEntity(string $id, string $label): void {
|
||||
$entity = CommentType::load($id);
|
||||
$this->assertInstanceOf(CommentType::class, $entity);
|
||||
$this->assertSame($label, $entity->label());
|
||||
|
|
|
@ -39,8 +39,10 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID.
|
||||
* @param string $component_id
|
||||
* The ID of the display component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisplay($id, $component_id) {
|
||||
protected function assertDisplay(string $id, string $component_id): void {
|
||||
$component = EntityViewDisplay::load($id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('hidden', $component['label']);
|
||||
|
|
|
@ -32,8 +32,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase
|
|||
*
|
||||
* @param string $id
|
||||
* The entity form display ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSubjectVisible($id) {
|
||||
protected function assertSubjectVisible(string $id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent('subject');
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('string_textfield', $component['type']);
|
||||
|
@ -45,8 +47,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase
|
|||
*
|
||||
* @param string $id
|
||||
* The entity form display ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSubjectNotVisible($id) {
|
||||
protected function assertSubjectNotVisible(string $id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent('subject');
|
||||
$this->assertNull($component);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,10 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID.
|
||||
* @param string $component_id
|
||||
* The ID of the form component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisplay($id, $component_id) {
|
||||
protected function assertDisplay(string $id, string $component_id): void {
|
||||
$component = EntityFormDisplay::load($id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame('comment_default', $component['type']);
|
||||
|
|
|
@ -44,14 +44,16 @@ class MigrateCommentFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
* The field's default_mode setting.
|
||||
* @param int $per_page
|
||||
* The field's per_page setting.
|
||||
* @param bool $anonymous
|
||||
* @param int $anonymous
|
||||
* The field's anonymous setting.
|
||||
* @param int $form_location
|
||||
* @param bool $form_location
|
||||
* The field's form_location setting.
|
||||
* @param bool $preview
|
||||
* @param int $preview
|
||||
* The field's preview setting.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($bundle, $field_name, $default_value, $default_mode, $per_page, $anonymous, $form_location, $preview) {
|
||||
protected function assertEntity(string $bundle, string $field_name, int $default_value, int $default_mode, int $per_page, int $anonymous, bool $form_location, int $preview): void {
|
||||
$entity = FieldConfig::load("node.$bundle.$field_name");
|
||||
$this->assertInstanceOf(FieldConfig::class, $entity);
|
||||
$this->assertSame('node', $entity->getTargetEntityTypeId());
|
||||
|
|
|
@ -32,8 +32,10 @@ class MigrateCommentFieldTest extends MigrateDrupal7TestBase {
|
|||
*
|
||||
* @param string $comment_type
|
||||
* The comment type.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($comment_type) {
|
||||
protected function assertEntity(string $comment_type): void {
|
||||
$entity = FieldStorageConfig::load('node.' . $comment_type);
|
||||
$this->assertInstanceOf(FieldStorageConfig::class, $entity);
|
||||
$this->assertSame('node', $entity->getTargetEntityTypeId());
|
||||
|
|
|
@ -25,8 +25,10 @@ class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID.
|
||||
* @param string $label
|
||||
* The entity label.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $label) {
|
||||
protected function assertEntity(string $id, string $label): void {
|
||||
$entity = CommentType::load($id);
|
||||
$this->assertInstanceOf(CommentType::class, $entity);
|
||||
$this->assertSame($label, $entity->label());
|
||||
|
|
|
@ -1186,10 +1186,9 @@ class ConfigTranslationUiTest extends BrowserTestBase {
|
|||
* @param string $id
|
||||
* The HTML ID of the textarea.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion passed; FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisabledTextarea($id) {
|
||||
protected function assertDisabledTextarea(string $id): void {
|
||||
$textarea = $this->assertSession()->fieldDisabled($id);
|
||||
$this->assertSame('textarea', $textarea->getTagName());
|
||||
$this->assertSame('This field has been disabled because you do not have sufficient permissions to edit it.', $textarea->getText());
|
||||
|
|
|
@ -98,8 +98,10 @@ class ContactLinkTest extends ViewTestBase {
|
|||
* All user objects used by the test.
|
||||
* @param array $names
|
||||
* Users which should have contact links.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertContactLinks(array $accounts, array $names) {
|
||||
public function assertContactLinks(array $accounts, array $names): void {
|
||||
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "views-field-contact")]//a', count($names));
|
||||
foreach ($names as $name) {
|
||||
$account_url = $accounts[$name]->toUrl('contact-form')->toString();
|
||||
|
|
|
@ -41,8 +41,10 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
|
|||
* The expected reply message.
|
||||
* @param int $expected_weight
|
||||
* The contact form's expected weight.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
|
||||
protected function assertEntity(string $id, string $expected_label, array $expected_recipients, string $expected_reply, int $expected_weight): void {
|
||||
/** @var \Drupal\contact\ContactFormInterface $entity */
|
||||
$entity = ContactForm::load($id);
|
||||
$this->assertInstanceOf(ContactFormInterface::class, $entity);
|
||||
|
|
|
@ -505,8 +505,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
|
|||
*
|
||||
* @param \Drupal\node\NodeInterface $node
|
||||
* A node object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertLatestVersionPage(NodeInterface $node) {
|
||||
public function assertLatestVersionPage(NodeInterface $node): void {
|
||||
$this->assertEquals($node->toUrl('latest-version')->setAbsolute()->toString(), $this->getSession()->getCurrentUrl());
|
||||
$this->assertModerationForm($node);
|
||||
}
|
||||
|
@ -519,8 +521,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
|
|||
* @param bool $moderation_form
|
||||
* (optional) Whether the page should contain the moderation form. Defaults
|
||||
* to FALSE.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertNotLatestVersionPage(NodeInterface $node, $moderation_form = FALSE) {
|
||||
public function assertNotLatestVersionPage(NodeInterface $node, bool $moderation_form = FALSE): void {
|
||||
$this->assertNotEquals($node->toUrl('latest-version')->setAbsolute()->toString(), $this->getSession()->getCurrentUrl());
|
||||
if ($moderation_form) {
|
||||
$this->assertModerationForm($node, FALSE);
|
||||
|
@ -538,8 +542,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
|
|||
* @param bool $latest_tab
|
||||
* (optional) Whether the node form is expected to be displayed on the
|
||||
* latest version page or on the node view page. Defaults to the former.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertModerationForm(NodeInterface $node, $latest_tab = TRUE) {
|
||||
public function assertModerationForm(NodeInterface $node, bool $latest_tab = TRUE): void {
|
||||
$this->drupalGet($node->toUrl());
|
||||
$this->assertEquals(!$latest_tab, $this->hasModerationForm());
|
||||
$this->drupalGet($node->toUrl('latest-version'));
|
||||
|
@ -551,8 +557,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
|
|||
*
|
||||
* @param \Drupal\node\NodeInterface $node
|
||||
* A node object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertNoModerationForm(NodeInterface $node) {
|
||||
public function assertNoModerationForm(NodeInterface $node): void {
|
||||
$this->drupalGet($node->toUrl());
|
||||
$this->assertFalse($this->hasModerationForm());
|
||||
$this->drupalGet($node->toUrl('latest-version'));
|
||||
|
|
|
@ -327,8 +327,10 @@ class ViewsModerationStateFilterTest extends ViewTestBase {
|
|||
* @param bool $check_size
|
||||
* (optional) Whether to check that size of the select element is not
|
||||
* greater than 8. Defaults to FALSE.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFilterStates($states, $check_size = FALSE) {
|
||||
protected function assertFilterStates(array $states, bool $check_size = FALSE): void {
|
||||
$this->drupalGet('/filter-test-path');
|
||||
|
||||
$assert_session = $this->assertSession();
|
||||
|
@ -355,8 +357,10 @@ class ViewsModerationStateFilterTest extends ViewTestBase {
|
|||
* An array of workflow IDs to check.
|
||||
* @param \Drupal\views\ViewEntityInterface $view
|
||||
* A view configuration object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertWorkflowDependencies(array $workflow_ids, ViewEntityInterface $view) {
|
||||
protected function assertWorkflowDependencies(array $workflow_ids, ViewEntityInterface $view): void {
|
||||
$dependencies = $view->getDependencies();
|
||||
|
||||
$expected = [];
|
||||
|
|
|
@ -124,8 +124,10 @@ class ContentModerationStateStorageSchemaTest extends KernelTestBase {
|
|||
* An array of entity values.
|
||||
* @param bool $has_exception
|
||||
* If an exception should be triggered when saving the entity.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertStorageException(array $values, $has_exception) {
|
||||
protected function assertStorageException(array $values, bool $has_exception): void {
|
||||
$defaults = [
|
||||
'moderation_state' => 'draft',
|
||||
'workflow' => 'editorial',
|
||||
|
|
|
@ -777,8 +777,10 @@ class ContentModerationStateTest extends KernelTestBase {
|
|||
* @param bool|null $published
|
||||
* (optional) Whether to check if the entity is published or not. Defaults
|
||||
* to TRUE.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDefaultRevision(EntityInterface $entity, $revision_id, $published = TRUE) {
|
||||
protected function assertDefaultRevision(EntityInterface $entity, int $revision_id, $published = TRUE): void {
|
||||
// Get the default revision.
|
||||
$entity = $this->reloadEntity($entity);
|
||||
$this->assertEquals($revision_id, $entity->getRevisionId());
|
||||
|
|
|
@ -123,8 +123,10 @@ class DefaultRevisionStateTest extends KernelTestBase {
|
|||
* The state the content moderation state revision should be in.
|
||||
* @param string $expected_workflow
|
||||
* The workflow the content moderation state revision should be using.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertModerationState($revision_id, $langcode, $expected_state, $expected_workflow = 'editorial') {
|
||||
protected function assertModerationState(int $revision_id, string $langcode, string $expected_state, string $expected_workflow = 'editorial'): void {
|
||||
$moderation_state_storage = $this->entityTypeManager->getStorage('content_moderation_state');
|
||||
|
||||
$query = $moderation_state_storage->getQuery()->accessCheck(FALSE);
|
||||
|
|
|
@ -162,8 +162,10 @@ class ModerationStateFieldItemListTest extends KernelTestBase {
|
|||
|
||||
/**
|
||||
* Assert the set of expectations when the moderation state field is emptied.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEmptiedModerationFieldItemList() {
|
||||
protected function assertEmptiedModerationFieldItemList(): void {
|
||||
$this->assertTrue($this->testNode->moderation_state->isEmpty());
|
||||
// Test the empty value causes a violation in the entity.
|
||||
$violations = $this->testNode->validate();
|
||||
|
|
|
@ -321,8 +321,10 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @param string[] $states
|
||||
* The states which should appear in the filter.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertPluginStates($states) {
|
||||
protected function assertPluginStates(array $states): void {
|
||||
$plugin = Views::pluginManager('filter')->createInstance('moderation_state_filter', []);
|
||||
$view = Views::getView('test_content_moderation_state_filter_base_table');
|
||||
$plugin->init($view, $view->getDisplay());
|
||||
|
@ -338,8 +340,10 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
|
|||
* An array of filters to apply to the view.
|
||||
* @param string $view_id
|
||||
* The view to execute for the results.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNodesWithFilters(array $nodes, array $filters, $view_id = 'test_content_moderation_state_filter_base_table') {
|
||||
protected function assertNodesWithFilters(array $nodes, array $filters, string $view_id = 'test_content_moderation_state_filter_base_table'): void {
|
||||
$view = Views::getView($view_id);
|
||||
$view->setExposedInput($filters);
|
||||
$view->execute();
|
||||
|
|
|
@ -165,8 +165,10 @@ class ViewsModerationStateSortTest extends ViewsKernelTestBase {
|
|||
* The sort order.
|
||||
* @param array $expected
|
||||
* The expected results array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSortResults($view_id, $column, $order, array $expected) {
|
||||
protected function assertSortResults(string $view_id, string $column, string $order, array $expected): void {
|
||||
// Test with exposed input.
|
||||
$view = Views::getView($view_id);
|
||||
$view->setExposedInput([
|
||||
|
|
|
@ -253,7 +253,7 @@ class WorkspacesContentModerationStateTest extends ContentModerationStateTest {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function assertDefaultRevision(EntityInterface $entity, $revision_id, $published = TRUE) {
|
||||
protected function assertDefaultRevision(EntityInterface $entity, int $revision_id, $published = TRUE): void {
|
||||
// In the context of a workspace, the default revision ID is always the
|
||||
// latest workspace-specific revision, so we need to adjust the expectation
|
||||
// of the parent assertion.
|
||||
|
|
|
@ -85,8 +85,10 @@ class ContentTranslationOutdatedRevisionTranslationTest extends ContentTranslati
|
|||
|
||||
/**
|
||||
* Checks whether the flag widget is displayed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFlagWidget() {
|
||||
protected function assertFlagWidget(): void {
|
||||
$this->assertSession()->pageTextNotContains('Flag other translations as outdated');
|
||||
$this->assertSession()->pageTextContains('Translations cannot be flagged as outdated when content is moderated.');
|
||||
}
|
||||
|
|
|
@ -253,14 +253,16 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
|
|||
*
|
||||
* @param string $entity_type
|
||||
* The entity type for which to check translatability.
|
||||
* @param string $bundle
|
||||
* @param string|null $bundle
|
||||
* The bundle for which to check translatability.
|
||||
* @param bool $enabled
|
||||
* TRUE if translatability should be enabled, FALSE otherwise.
|
||||
* @param array $edit
|
||||
* An array of values to submit to the content translation settings page.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSettings($entity_type, $bundle, $enabled, $edit) {
|
||||
protected function assertSettings(string $entity_type, ?string $bundle, bool $enabled, array $edit): void {
|
||||
$this->drupalGet('admin/config/regional/content-language');
|
||||
$this->submitForm($edit, 'Save configuration');
|
||||
$args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'];
|
||||
|
|
|
@ -414,10 +414,12 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
|
|||
|
||||
/**
|
||||
* Assert that the current page does not contain shared form elements.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNoSharedElements() {
|
||||
protected function assertNoSharedElements(): void {
|
||||
$language_none = LanguageInterface::LANGCODE_NOT_SPECIFIED;
|
||||
return $this->assertSession()->fieldNotExists("field_test_text[$language_none][0][value]");
|
||||
$this->assertSession()->fieldNotExists("field_test_text[$language_none][0][value]");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -449,8 +449,10 @@ class ContentTranslationFieldSyncRevisionTest extends EntityKernelTestBase {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityConstraintViolationListInterface $violations
|
||||
* A list of violations.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertViolations(EntityConstraintViolationListInterface $violations) {
|
||||
protected function assertViolations(EntityConstraintViolationListInterface $violations): void {
|
||||
$entity_type_id = $this->storage->getEntityTypeId();
|
||||
$settings = $this->contentTranslationManager->getBundleTranslationSettings($entity_type_id, $entity_type_id);
|
||||
$message = !empty($settings['untranslatable_fields_hide']) ?
|
||||
|
@ -478,8 +480,10 @@ class ContentTranslationFieldSyncRevisionTest extends EntityKernelTestBase {
|
|||
* - target ID (it)
|
||||
* - alt (en)
|
||||
* - alt (it)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertLatestRevisionFieldValues($entity_id, array $expected_values) {
|
||||
protected function assertLatestRevisionFieldValues(int $entity_id, array $expected_values): void {
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
$entity = $this->storage->loadRevision($this->storage->getLatestRevisionId($entity_id));
|
||||
@[$revision_id, $target_id_en, $target_id_it, $alt_en, $alt_it] = $expected_values;
|
||||
|
|
|
@ -72,8 +72,10 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
|
|||
* The value the migrated entity field should have.
|
||||
* @param int $expected_term_reference_tid
|
||||
* The term reference ID the migrated entity field should have.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $expected_language, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, $expected_parents = [], $expected_field_integer_value = NULL, $expected_term_reference_tid = NULL) {
|
||||
protected function assertEntity(int $id, string $expected_language, string $expected_label, string $expected_vid, string $expected_description = '', string $expected_format = NULL, int $expected_weight = 0, array $expected_parents = [], int $expected_field_integer_value = NULL, int $expected_term_reference_tid = NULL): void {
|
||||
/** @var \Drupal\taxonomy\TermInterface $entity */
|
||||
$entity = Term::load($id);
|
||||
$this->assertInstanceOf(TermInterface::class, $entity);
|
||||
|
@ -82,7 +84,7 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
|
|||
$this->assertSame($expected_vid, $entity->bundle());
|
||||
$this->assertSame($expected_description, $entity->getDescription());
|
||||
$this->assertSame($expected_format, $entity->getFormat());
|
||||
$this->assertSame($expected_weight, $entity->getWeight());
|
||||
$this->assertSame($expected_weight, (int) $entity->getWeight());
|
||||
$this->assertHierarchy($expected_vid, $id, $expected_parents);
|
||||
}
|
||||
|
||||
|
@ -95,8 +97,10 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
|
|||
* ID of the term to check.
|
||||
* @param array $parent_ids
|
||||
* The expected parent term IDs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertHierarchy($vid, $tid, array $parent_ids) {
|
||||
protected function assertHierarchy(string $vid, int $tid, array $parent_ids): void {
|
||||
if (!isset($this->treeData[$vid])) {
|
||||
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
|
||||
$this->treeData[$vid] = [];
|
||||
|
@ -119,13 +123,13 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
|
|||
* Tests the Drupal 6 i18n taxonomy term to Drupal 8 migration.
|
||||
*/
|
||||
public function testTranslatedTaxonomyTerms() {
|
||||
$this->assertEntity(1, 'zu', 'zu - term 1 of vocabulary 1', 'vocabulary_1_i_0_', 'zu - description of term 1 of vocabulary 1', NULL, '0', []);
|
||||
$this->assertEntity(2, 'fr', 'fr - term 2 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 2 of vocabulary 2', NULL, '3', []);
|
||||
$this->assertEntity(3, 'fr', 'fr - term 3 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 3 of vocabulary 2', NULL, '4', ['2']);
|
||||
$this->assertEntity(4, 'en', 'term 4 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 4 of vocabulary 3', NULL, '6', []);
|
||||
$this->assertEntity(5, 'en', 'term 5 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 5 of vocabulary 3', NULL, '7', ['4']);
|
||||
$this->assertEntity(6, 'en', 'term 6 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 6 of vocabulary 3', NULL, '8', ['4', '5']);
|
||||
$this->assertEntity(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, '0', []);
|
||||
$this->assertEntity(1, 'zu', 'zu - term 1 of vocabulary 1', 'vocabulary_1_i_0_', 'zu - description of term 1 of vocabulary 1', NULL, 0, []);
|
||||
$this->assertEntity(2, 'fr', 'fr - term 2 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 2 of vocabulary 2', NULL, 3, []);
|
||||
$this->assertEntity(3, 'fr', 'fr - term 3 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 3 of vocabulary 2', NULL, 4, ['2']);
|
||||
$this->assertEntity(4, 'en', 'term 4 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 4 of vocabulary 3', NULL, 6, []);
|
||||
$this->assertEntity(5, 'en', 'term 5 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 5 of vocabulary 3', NULL, 7, ['4']);
|
||||
$this->assertEntity(6, 'en', 'term 6 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 6 of vocabulary 3', NULL, 8, ['4', '5']);
|
||||
$this->assertEntity(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, 0, []);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -222,8 +222,10 @@ class ContextualDynamicContextTest extends BrowserTestBase {
|
|||
*
|
||||
* @param string $id
|
||||
* A contextual link id.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertContextualLinkPlaceHolder($id) {
|
||||
protected function assertContextualLinkPlaceHolder(string $id): void {
|
||||
$this->assertSession()->elementAttributeContains(
|
||||
'css',
|
||||
'div[data-contextual-id="' . $id . '"]',
|
||||
|
@ -237,8 +239,10 @@ class ContextualDynamicContextTest extends BrowserTestBase {
|
|||
*
|
||||
* @param string $id
|
||||
* A contextual link id.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNoContextualLinkPlaceHolder($id) {
|
||||
protected function assertNoContextualLinkPlaceHolder(string $id): void {
|
||||
$this->assertSession()->elementNotExists('css', 'div[data-contextual-id="' . $id . '"]');
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,10 @@ class EditModeTest extends WebDriverTestBase {
|
|||
|
||||
/**
|
||||
* Asserts that the correct message was announced when entering edit mode.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertAnnounceEditMode() {
|
||||
protected function assertAnnounceEditMode(): void {
|
||||
$web_assert = $this->assertSession();
|
||||
// Wait for contextual trigger button.
|
||||
$web_assert->waitForElementVisible('css', '.contextual trigger');
|
||||
|
@ -111,8 +113,10 @@ class EditModeTest extends WebDriverTestBase {
|
|||
|
||||
/**
|
||||
* Assert that the correct message was announced when leaving edit mode.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertAnnounceLeaveEditMode() {
|
||||
protected function assertAnnounceLeaveEditMode(): void {
|
||||
$web_assert = $this->assertSession();
|
||||
$page = $this->getSession()->getPage();
|
||||
// Wait till all the contextual links are hidden.
|
||||
|
|
|
@ -117,7 +117,7 @@ class EntityTestDateonlyTest extends EntityTestResourceTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {
|
||||
parent::assertNormalizationEdgeCases($method, $url, $request_options);
|
||||
|
||||
if ($this->entity->getEntityType()->hasKey('bundle')) {
|
||||
|
|
|
@ -117,7 +117,7 @@ class EntityTestDatetimeTest extends EntityTestResourceTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {
|
||||
parent::assertNormalizationEdgeCases($method, $url, $request_options);
|
||||
|
||||
if ($this->entity->getEntityType()->hasKey('bundle')) {
|
||||
|
|
|
@ -118,7 +118,7 @@ class EntityTestDateRangeTest extends EntityTestResourceTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {
|
||||
parent::assertNormalizationEdgeCases($method, $url, $request_options);
|
||||
|
||||
if ($this->entity->getEntityType()->hasKey('bundle')) {
|
||||
|
|
|
@ -118,7 +118,7 @@ class DbLogResourceTest extends ResourceTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {}
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -819,8 +819,10 @@ class DbLogTest extends BrowserTestBase {
|
|||
* The database log message to check.
|
||||
* @param string $message
|
||||
* The message to pass to simpletest.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertLogMessage($log_message, $message) {
|
||||
protected function assertLogMessage(string $log_message, string $message): void {
|
||||
$message_text = Unicode::truncate($log_message, 56, TRUE, TRUE);
|
||||
$this->assertSession()->linkExists($message_text, 0, $message);
|
||||
}
|
||||
|
|
|
@ -214,12 +214,14 @@ class EditorUploadImageScaleTest extends BrowserTestBase {
|
|||
/**
|
||||
* Asserts whether the saved maximum dimensions equal the ones provided.
|
||||
*
|
||||
* @param string $width
|
||||
* @param int|null $width
|
||||
* The expected width of the uploaded image.
|
||||
* @param string $height
|
||||
* @param int|null $height
|
||||
* The expected height of the uploaded image.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSavedMaxDimensions($width, $height) {
|
||||
protected function assertSavedMaxDimensions(?int $width, ?int $height): void {
|
||||
$image_upload_settings = Editor::load('basic_html')->getImageUploadSettings();
|
||||
$expected = [
|
||||
'width' => $image_upload_settings['max_dimensions']['width'],
|
||||
|
|
|
@ -398,8 +398,10 @@ class EntityReferenceAdminTest extends BrowserTestBase {
|
|||
* The field name.
|
||||
* @param array $expected_options
|
||||
* An array of expected options.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFieldSelectOptions($name, array $expected_options) {
|
||||
protected function assertFieldSelectOptions(string $name, array $expected_options): void {
|
||||
$options = $this->assertSession()->selectExists($name)->findAll('xpath', 'option');
|
||||
array_walk($options, function (NodeElement &$option) {
|
||||
$option = $option->getValue();
|
||||
|
|
|
@ -175,8 +175,10 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
|
|||
|
||||
/**
|
||||
* Assert entity reference display.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntityReferenceDisplay() {
|
||||
protected function assertEntityReferenceDisplay(): void {
|
||||
$url = $this->referrerEntity->toUrl();
|
||||
$translation_url = $this->referrerEntity->toUrl('canonical', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]);
|
||||
|
||||
|
@ -192,8 +194,10 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
|
|||
|
||||
/**
|
||||
* Assert entity reference form display.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntityReferenceFormDisplay() {
|
||||
protected function assertEntityReferenceFormDisplay(): void {
|
||||
$this->drupalLogin($this->webUser);
|
||||
$url = $this->referrerEntity->toUrl('edit-form');
|
||||
$translation_url = $this->referrerEntity->toUrl('edit-form', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]);
|
||||
|
|
|
@ -196,8 +196,10 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
|
|||
* The name of the test entity.
|
||||
* @param \Drupal\Core\Entity\EntityInterface[] $referenced_entities
|
||||
* An array of referenced entities.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFieldValues($entity_name, $referenced_entities) {
|
||||
protected function assertFieldValues(string $entity_name, array $referenced_entities): void {
|
||||
$entity = current($this->container->get('entity_type.manager')->getStorage(
|
||||
$this->entityType)->loadByProperties(['name' => $entity_name]));
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\field\Functional\Number;
|
|||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\FieldConfigInterface;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
|
@ -426,8 +427,10 @@ class NumberFieldTest extends BrowserTestBase {
|
|||
|
||||
/**
|
||||
* Helper function to set the minimum value of a field.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertSetMinimumValue($field, $minimum_value) {
|
||||
public function assertSetMinimumValue(FieldConfigInterface $field, int $minimum_value): void {
|
||||
$field_configuration_url = 'entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field->getName();
|
||||
|
||||
// Set the minimum value.
|
||||
|
|
|
@ -352,8 +352,10 @@ class EntityReferenceAdminTest extends WebDriverTestBase {
|
|||
* The field name.
|
||||
* @param array $expected_options
|
||||
* An array of expected options.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFieldSelectOptions($name, array $expected_options) {
|
||||
protected function assertFieldSelectOptions(string $name, array $expected_options): void {
|
||||
$field = $this->assertSession()->selectExists($name);
|
||||
$options = $field->findAll('xpath', 'option');
|
||||
$optgroups = $field->findAll('xpath', 'optgroup');
|
||||
|
|
|
@ -150,8 +150,10 @@ class SelectionTest extends KernelTestBase {
|
|||
*
|
||||
* @param array $result
|
||||
* Query results keyed by node type and nid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertResults(array $result) {
|
||||
protected function assertResults(array $result): void {
|
||||
foreach ($result as $node_type => $values) {
|
||||
foreach ($values as $nid => $label) {
|
||||
$this->assertSame($node_type, $this->nodes[$nid]->bundle());
|
||||
|
|
|
@ -34,8 +34,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
|
|||
* The display ID.
|
||||
* @param string $component_id
|
||||
* The component ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertComponentNotExists($display_id, $component_id) {
|
||||
protected function assertComponentNotExists(string $display_id, string $component_id): void {
|
||||
$component = EntityViewDisplay::load($display_id)->getComponent($component_id);
|
||||
$this->assertNull($component);
|
||||
}
|
||||
|
|
|
@ -43,8 +43,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
|
|||
*
|
||||
* @param string $id
|
||||
* The view display ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id) {
|
||||
protected function assertEntity(string $id): void {
|
||||
$display = EntityViewDisplay::load($id);
|
||||
$this->assertInstanceOf(EntityViewDisplayInterface::class, $display);
|
||||
}
|
||||
|
@ -62,8 +64,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
|
|||
* The expected label of the component.
|
||||
* @param int $weight
|
||||
* The expected weight of the component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertComponent($display_id, $component_id, $type, $label, $weight) {
|
||||
protected function assertComponent(string $display_id, string $component_id, string $type, string $label, int $weight): void {
|
||||
$component = EntityViewDisplay::load($display_id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame($type, $component['type']);
|
||||
|
@ -78,8 +82,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
|
|||
* The display ID.
|
||||
* @param string $component_id
|
||||
* The component ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertComponentNotExists($display_id, $component_id) {
|
||||
protected function assertComponentNotExists(string $display_id, string $component_id): void {
|
||||
$component = EntityViewDisplay::load($display_id)->getComponent($component_id);
|
||||
$this->assertNull($component);
|
||||
}
|
||||
|
|
|
@ -50,8 +50,10 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
* Whether or not the field is required.
|
||||
* @param bool $expected_translatable
|
||||
* Whether or not the field is expected to be translatable.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $expected_label, $expected_field_type, $is_required, $expected_translatable) {
|
||||
protected function assertEntity(string $id, string $expected_label, string $expected_field_type, bool $is_required, bool $expected_translatable): void {
|
||||
[$expected_entity_type, $expected_bundle, $expected_name] = explode('.', $id);
|
||||
|
||||
/** @var \Drupal\field\FieldConfigInterface $field */
|
||||
|
@ -70,12 +72,14 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
/**
|
||||
* Asserts the settings of a link field config entity.
|
||||
*
|
||||
* @param $id
|
||||
* @param string $id
|
||||
* The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.
|
||||
* @param $title_setting
|
||||
* @param int $title_setting
|
||||
* The expected title setting.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertLinkFields($id, $title_setting) {
|
||||
protected function assertLinkFields(string $id, int $title_setting): void {
|
||||
$field = FieldConfig::load($id);
|
||||
$this->assertSame($title_setting, $field->getSetting('title'));
|
||||
}
|
||||
|
@ -87,8 +91,10 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
* The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.
|
||||
* @param string[] $target_bundles
|
||||
* An array of expected target bundles.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntityReferenceFields($id, array $target_bundles) {
|
||||
protected function assertEntityReferenceFields(string $id, array $target_bundles): void {
|
||||
$field = FieldConfig::load($id);
|
||||
$handler_settings = $field->getSetting('handler_settings');
|
||||
$this->assertArrayHasKey('target_bundles', $handler_settings);
|
||||
|
|
|
@ -49,8 +49,10 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
|
|||
* The expected entity type to which the display settings are attached.
|
||||
* @param string $expected_bundle
|
||||
* The expected bundle to which the display settings are attached.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $expected_entity_type, $expected_bundle) {
|
||||
protected function assertEntity(string $id, string $expected_entity_type, string $expected_bundle): void {
|
||||
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $entity */
|
||||
$entity = EntityFormDisplay::load($id);
|
||||
$this->assertInstanceOf(EntityFormDisplayInterface::class, $entity);
|
||||
|
@ -67,10 +69,12 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
|
|||
* The component ID.
|
||||
* @param string $widget_type
|
||||
* The expected widget type.
|
||||
* @param string $weight
|
||||
* @param int $weight
|
||||
* The expected weight of the component.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertComponent($display_id, $component_id, $widget_type, $weight) {
|
||||
protected function assertComponent(string $display_id, string $component_id, string $widget_type, int $weight): void {
|
||||
$component = EntityFormDisplay::load($display_id)->getComponent($component_id);
|
||||
$this->assertIsArray($component);
|
||||
$this->assertSame($widget_type, $component['type']);
|
||||
|
|
|
@ -42,8 +42,10 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
|
|||
* Whether or not the field is expected to be translatable.
|
||||
* @param int $expected_cardinality
|
||||
* The expected cardinality of the field.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $expected_type, $expected_translatable, $expected_cardinality) {
|
||||
protected function assertEntity(string $id, string $expected_type, bool $expected_translatable, int $expected_cardinality): void {
|
||||
[$expected_entity_type, $expected_name] = explode('.', $id);
|
||||
|
||||
/** @var \Drupal\field\FieldStorageConfigInterface $field */
|
||||
|
|
|
@ -34,8 +34,10 @@ class MigrateViewModesTest extends MigrateDrupal7TestBase {
|
|||
* The expected label of the view mode.
|
||||
* @param string $entity_type
|
||||
* The expected entity type ID which owns the view mode.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $label, $entity_type) {
|
||||
protected function assertEntity(string $id, string $label, string $entity_type): void {
|
||||
/** @var \Drupal\Core\Entity\EntityViewModeInterface $view_mode */
|
||||
$view_mode = EntityViewMode::load($id);
|
||||
$this->assertInstanceOf(EntityViewModeInterface::class, $view_mode);
|
||||
|
|
|
@ -164,8 +164,10 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
|
|||
* A list of allowed operations.
|
||||
* @param \Drupal\Core\Session\AccountInterface $user
|
||||
* The account to use for get access.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertAllowOperations(array $allow_operations, AccountInterface $user) {
|
||||
public function assertAllowOperations(array $allow_operations, AccountInterface $user): void {
|
||||
foreach (['view', 'update', 'delete'] as $operation) {
|
||||
$expected = in_array($operation, $allow_operations);
|
||||
$actual = $this->accessControlHandler->access($this->entity, $operation, $user);
|
||||
|
|
|
@ -306,8 +306,10 @@ class FieldLayoutTest extends WebDriverTestBase {
|
|||
* The field selector, one of field id|name|label|value.
|
||||
* @param string $region_name
|
||||
* The machine name of the region.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFieldInRegion($field_selector, $region_name) {
|
||||
protected function assertFieldInRegion(string $field_selector, string $region_name): void {
|
||||
$region_element = $this->getSession()->getPage()->find('css', ".layout__region--$region_name");
|
||||
$this->assertNotNull($region_element);
|
||||
$this->assertSession()->fieldExists($field_selector, $region_element);
|
||||
|
|
|
@ -175,14 +175,16 @@ class FieldLayoutEntityDisplayTest extends KernelTestBase {
|
|||
/**
|
||||
* Asserts than an entity has the correct values.
|
||||
*
|
||||
* @param mixed $expected
|
||||
* @param array $expected
|
||||
* The expected values.
|
||||
* @param array $values
|
||||
* The actual values.
|
||||
* @param string $message
|
||||
* (optional) An error message.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function assertEntityValues($expected, array $values, $message = '') {
|
||||
public static function assertEntityValues(array $expected, array $values, string $message = ''): void {
|
||||
|
||||
static::assertArrayHasKey('uuid', $values);
|
||||
unset($values['uuid']);
|
||||
|
|
|
@ -108,8 +108,10 @@ class FieldUIRouteTest extends BrowserTestBase {
|
|||
|
||||
/**
|
||||
* Asserts that local tasks exists.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertLocalTasks() {
|
||||
public function assertLocalTasks(): void {
|
||||
$this->assertSession()->linkExists('Settings');
|
||||
$this->assertSession()->linkExists('Manage fields');
|
||||
$this->assertSession()->linkExists('Manage display');
|
||||
|
|
|
@ -220,18 +220,17 @@ class ManageDisplayTest extends BrowserTestBase {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $node
|
||||
* The node.
|
||||
* @param $view_mode
|
||||
* @param string $view_mode
|
||||
* The view mode in which the node should be displayed.
|
||||
* @param $text
|
||||
* @param string $text
|
||||
* Plain text to look for.
|
||||
* @param $message
|
||||
* @param string $message
|
||||
* Message to display.
|
||||
*
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
* @internal
|
||||
*/
|
||||
public function assertNodeViewText(EntityInterface $node, $view_mode, $text, $message) {
|
||||
return $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, FALSE);
|
||||
public function assertNodeViewText(EntityInterface $node, string $view_mode, string $text, string $message): void {
|
||||
$this->assertNodeViewTextHelper($node, $view_mode, $text, $message, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,18 +238,17 @@ class ManageDisplayTest extends BrowserTestBase {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $node
|
||||
* The node.
|
||||
* @param $view_mode
|
||||
* @param string $view_mode
|
||||
* The view mode in which the node should be displayed.
|
||||
* @param $text
|
||||
* @param string $text
|
||||
* Plain text to look for.
|
||||
* @param $message
|
||||
* @param string $message
|
||||
* Message to display.
|
||||
*
|
||||
* @return
|
||||
* TRUE on pass, FALSE on fail.
|
||||
* @internal
|
||||
*/
|
||||
public function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $message) {
|
||||
return $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, TRUE);
|
||||
public function assertNodeViewNoText(EntityInterface $node, string $view_mode, string $text, string $message): void {
|
||||
$this->assertNodeViewTextHelper($node, $view_mode, $text, $message, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,16 +259,18 @@ class ManageDisplayTest extends BrowserTestBase {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $node
|
||||
* The node.
|
||||
* @param $view_mode
|
||||
* @param string $view_mode
|
||||
* The view mode in which the node should be displayed.
|
||||
* @param $text
|
||||
* @param string $text
|
||||
* Plain text to look for.
|
||||
* @param $message
|
||||
* @param string $message
|
||||
* Message to display.
|
||||
* @param $not_exists
|
||||
* @param bool $not_exists
|
||||
* TRUE if this text should not exist, FALSE if it should.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $message, $not_exists) {
|
||||
public function assertNodeViewTextHelper(EntityInterface $node, string $view_mode, string $text, string $message, bool $not_exists): void {
|
||||
// Make sure caches on the tester side are refreshed after changes
|
||||
// submitted on the tested side.
|
||||
\Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
|
||||
|
@ -297,8 +297,10 @@ class ManageDisplayTest extends BrowserTestBase {
|
|||
* The field name.
|
||||
* @param array $expected_options
|
||||
* An array of expected options.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFieldSelectOptions($name, array $expected_options) {
|
||||
protected function assertFieldSelectOptions(string $name, array $expected_options): void {
|
||||
$xpath = $this->assertSession()->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
|
||||
$fields = $this->xpath($xpath);
|
||||
if ($fields) {
|
||||
|
|
|
@ -439,16 +439,18 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
|
|||
/**
|
||||
* Asserts field settings are as expected.
|
||||
*
|
||||
* @param $bundle
|
||||
* @param string $bundle
|
||||
* The bundle name for the field.
|
||||
* @param $field_name
|
||||
* @param string $field_name
|
||||
* The field name for the field.
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* The settings text.
|
||||
* @param $entity_type
|
||||
* @param string $entity_type
|
||||
* The entity type for the field.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertFieldSettings($bundle, $field_name, $string = 'dummy test string', $entity_type = 'node') {
|
||||
public function assertFieldSettings(string $bundle, string $field_name, string $string = 'dummy test string', string $entity_type = 'node'): void {
|
||||
// Assert field storage settings.
|
||||
$field_storage = FieldStorageConfig::loadByName($entity_type, $field_name);
|
||||
$this->assertSame($string, $field_storage->getSetting('test_field_storage_setting'), 'Field storage settings were found.');
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\field_ui\FunctionalJavascript;
|
||||
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
|
@ -387,10 +388,12 @@ class ManageDisplayTest extends WebDriverTestBase {
|
|||
* The select field to validate.
|
||||
* @param array $expected_options
|
||||
* An array of expected options.
|
||||
* @param null $selected
|
||||
* @param string|null $selected
|
||||
* The default value to validate.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertFieldSelectOptions($field, array $expected_options, $selected = NULL) {
|
||||
protected function assertFieldSelectOptions(NodeElement $field, array $expected_options, ?string $selected = NULL): void {
|
||||
/** @var \Behat\Mink\Element\NodeElement[] $select_options */
|
||||
$select_options = $field->findAll('xpath', 'option');
|
||||
|
||||
|
|
|
@ -649,11 +649,10 @@ class EntityDisplayTest extends KernelTestBase {
|
|||
* @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
|
||||
* The entity display object to get dependencies from.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDependency($type, $key, EntityDisplayInterface $display) {
|
||||
return $this->assertDependencyHelper(TRUE, $type, $key, $display);
|
||||
protected function assertDependency(string $type, string $key, EntityDisplayInterface $display): void {
|
||||
$this->assertDependencyHelper(TRUE, $type, $key, $display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -666,11 +665,10 @@ class EntityDisplayTest extends KernelTestBase {
|
|||
* @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
|
||||
* The entity display object to get dependencies from.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNoDependency($type, $key, EntityDisplayInterface $display) {
|
||||
return $this->assertDependencyHelper(FALSE, $type, $key, $display);
|
||||
protected function assertNoDependency(string $type, string $key, EntityDisplayInterface $display): void {
|
||||
$this->assertDependencyHelper(FALSE, $type, $key, $display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -685,10 +683,9 @@ class EntityDisplayTest extends KernelTestBase {
|
|||
* @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
|
||||
* The entity display object to get dependencies from.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDependencyHelper($assertion, $type, $key, EntityDisplayInterface $display) {
|
||||
protected function assertDependencyHelper(bool $assertion, string $type, string $key, EntityDisplayInterface $display): void {
|
||||
$all_dependencies = $display->getDependencies();
|
||||
$dependencies = !empty($all_dependencies[$type]) ? $all_dependencies[$type] : [];
|
||||
$context = $display instanceof EntityViewDisplayInterface ? 'View' : 'Form';
|
||||
|
@ -696,7 +693,6 @@ class EntityDisplayTest extends KernelTestBase {
|
|||
$args = ['@context' => $context, '@id' => $display->id(), '@type' => $type, '@key' => $key];
|
||||
$message = $assertion ? new FormattableMarkup("@context display '@id' depends on @type '@key'.", $args) : new FormattableMarkup("@context display '@id' do not depend on @type '@key'.", $args);
|
||||
$this->assertTrue($value, $message);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,8 +85,10 @@ class FileFieldPathTest extends FileFieldTestBase {
|
|||
* Where the file was actually uploaded.
|
||||
* @param string $message
|
||||
* The message to display with this assertion.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertPathMatch($expected_path, $actual_path, $message) {
|
||||
public function assertPathMatch(string $expected_path, string $actual_path, string $message): void {
|
||||
// Strip off the extension of the expected path to allow for _0, _1, etc.
|
||||
// suffixes when the file hits a duplicate name.
|
||||
$pos = strrpos($expected_path, '.');
|
||||
|
|
|
@ -49,26 +49,28 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
|
|||
* The expected MIME type.
|
||||
* @param int $uid
|
||||
* The expected file owner ID.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($fid, $name, $size, $uri, $type, $uid) {
|
||||
protected function assertEntity(int $fid, string $name, int $size, string $uri, string $type, int $uid): void {
|
||||
/** @var \Drupal\file\FileInterface $file */
|
||||
$file = File::load($fid);
|
||||
$this->assertInstanceOf(FileInterface::class, $file);
|
||||
$this->assertSame($name, $file->getFilename());
|
||||
$this->assertSame($size, $file->getSize());
|
||||
$this->assertSame($size, (int) $file->getSize());
|
||||
$this->assertSame($uri, $file->getFileUri());
|
||||
$this->assertSame($type, $file->getMimeType());
|
||||
$this->assertSame($uid, $file->getOwnerId());
|
||||
$this->assertSame($uid, (int) $file->getOwnerId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 files to Drupal 8 migration.
|
||||
*/
|
||||
public function testFiles() {
|
||||
$this->assertEntity(1, 'Image1.png', '39325', 'public://image-1.png', 'image/png', '1');
|
||||
$this->assertEntity(2, 'Image2.jpg', '1831', 'public://image-2.jpg', 'image/jpeg', '1');
|
||||
$this->assertEntity(3, 'image-3.jpg', '1831', 'public://image-3.jpg', 'image/jpeg', '1');
|
||||
$this->assertEntity(4, 'html-1.txt', '24', 'public://html-1.txt', 'text/plain', '1');
|
||||
$this->assertEntity(1, 'Image1.png', 39325, 'public://image-1.png', 'image/png', 1);
|
||||
$this->assertEntity(2, 'Image2.jpg', 1831, 'public://image-2.jpg', 'image/jpeg', 1);
|
||||
$this->assertEntity(3, 'image-3.jpg', 1831, 'public://image-3.jpg', 'image/jpeg', 1);
|
||||
$this->assertEntity(4, 'html-1.txt', 24, 'public://html-1.txt', 'text/plain', 1);
|
||||
// Ensure temporary file was not migrated.
|
||||
$this->assertNull(File::load(6));
|
||||
|
||||
|
|
|
@ -175,8 +175,10 @@ class FilterFormTest extends BrowserTestBase {
|
|||
*
|
||||
* @param string $id
|
||||
* The HTML ID of the select element.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNoSelect($id) {
|
||||
protected function assertNoSelect(string $id): void {
|
||||
$this->assertSession()->elementNotExists('xpath', "//select[@id=$id]");
|
||||
}
|
||||
|
||||
|
@ -190,10 +192,9 @@ class FilterFormTest extends BrowserTestBase {
|
|||
* @param string $selected
|
||||
* The value of the selected option.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion passed; FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertOptions($id, array $expected_options, $selected) {
|
||||
protected function assertOptions(string $id, array $expected_options, string $selected): void {
|
||||
$select = $this->assertSession()->selectExists($id);
|
||||
$found_options = $select->findAll('css', 'option');
|
||||
$found_options = array_map(function ($item) {
|
||||
|
@ -212,10 +213,9 @@ class FilterFormTest extends BrowserTestBase {
|
|||
* An array of option values that are contained in the select element
|
||||
* besides the "- Select -" option.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion passed; FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertRequiredSelectAndOptions($id, array $options) {
|
||||
protected function assertRequiredSelectAndOptions(string $id, array $options): void {
|
||||
$select = $this->assertSession()->selectExists($id);
|
||||
$this->assertSame('required', $select->getAttribute('required'));
|
||||
// A required select element has a "- Select -" option whose key is an empty
|
||||
|
@ -230,10 +230,9 @@ class FilterFormTest extends BrowserTestBase {
|
|||
* @param string $id
|
||||
* The HTML ID of the textarea.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion passed; FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEnabledTextarea($id) {
|
||||
protected function assertEnabledTextarea(string $id): void {
|
||||
$textarea = $this->assertSession()->fieldEnabled($id);
|
||||
$this->assertSame('textarea', $textarea->getTagName());
|
||||
}
|
||||
|
@ -244,10 +243,9 @@ class FilterFormTest extends BrowserTestBase {
|
|||
* @param string $id
|
||||
* The HTML ID of the textarea.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion passed; FALSE otherwise.
|
||||
* @internal
|
||||
*/
|
||||
protected function assertDisabledTextarea($id) {
|
||||
protected function assertDisabledTextarea(string $id): void {
|
||||
$textarea = $this->assertSession()->fieldDisabled($id);
|
||||
$this->assertSame('textarea', $textarea->getTagName());
|
||||
$this->assertSame('This field has been disabled because you do not have sufficient permissions to edit it.', $textarea->getText());
|
||||
|
|
|
@ -430,10 +430,12 @@ class FilterAPITest extends EntityKernelTestBase {
|
|||
*
|
||||
* @param \Symfony\Component\Validator\ConstraintViolationListInterface $violations
|
||||
* The violations to assert.
|
||||
* @param mixed $invalid_value
|
||||
* @param string $invalid_value
|
||||
* The expected invalid value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertFilterFormatViolation(ConstraintViolationListInterface $violations, $invalid_value) {
|
||||
public function assertFilterFormatViolation(ConstraintViolationListInterface $violations, string $invalid_value): void {
|
||||
$filter_format_violation_found = FALSE;
|
||||
foreach ($violations as $violation) {
|
||||
if ($violation->getRoot() instanceof FilterFormatDataType && $violation->getInvalidValue() === $invalid_value) {
|
||||
|
|
|
@ -9,6 +9,7 @@ use Drupal\Core\Render\RenderContext;
|
|||
use Drupal\editor\EditorXssFilter\Standard;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\filter\FilterPluginCollection;
|
||||
use Drupal\filter\Plugin\FilterInterface;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
|
@ -860,7 +861,7 @@ www.example.com with a newline in comments -->
|
|||
/**
|
||||
* Asserts multiple filter output expectations for multiple input strings.
|
||||
*
|
||||
* @param FilterInterface $filter
|
||||
* @param \Drupal\filter\Plugin\FilterInterface $filter
|
||||
* An input filter object.
|
||||
* @param array $tests
|
||||
* An associative array, whereas each key is an arbitrary input string and
|
||||
|
@ -875,8 +876,10 @@ www.example.com with a newline in comments -->
|
|||
* ),
|
||||
* );
|
||||
* @endcode
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertFilteredString($filter, $tests) {
|
||||
public function assertFilteredString(FilterInterface $filter, array $tests): void {
|
||||
foreach ($tests as $source => $tasks) {
|
||||
$result = $filter->process($source, $filter)->getProcessedText();
|
||||
foreach ($tasks as $value => $is_expected) {
|
||||
|
@ -1141,8 +1144,10 @@ body {color:red}
|
|||
* (optional) Message to display if failed. Defaults to an empty string.
|
||||
* @param string $group
|
||||
* (optional) The group this message belongs to. Defaults to 'Other'.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertNormalized($haystack, $needle, $message = '', $group = 'Other') {
|
||||
public function assertNormalized(string $haystack, string $needle, string $message = '', string $group = 'Other'): void {
|
||||
$this->assertStringContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
|
||||
}
|
||||
|
||||
|
@ -1163,8 +1168,10 @@ body {color:red}
|
|||
* (optional) Message to display if failed. Defaults to an empty string.
|
||||
* @param string $group
|
||||
* (optional) The group this message belongs to. Defaults to 'Other'.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertNoNormalized($haystack, $needle, $message = '', $group = 'Other') {
|
||||
public function assertNoNormalized(string $haystack, string $needle, string $message = '', string $group = 'Other'): void {
|
||||
$this->assertStringNotContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,8 +67,10 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase implements MigrateD
|
|||
* The weight of the filter.
|
||||
* @param bool $status
|
||||
* The status of the filter.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertEntity($id, $label, array $enabled_filters, $weight, $status) {
|
||||
protected function assertEntity(string $id, string $label, array $enabled_filters, int $weight, bool $status): void {
|
||||
/** @var \Drupal\filter\FilterFormatInterface $entity */
|
||||
$entity = FilterFormat::load($id);
|
||||
$this->assertInstanceOf(FilterFormatInterface::class, $entity);
|
||||
|
|
|
@ -290,8 +290,10 @@ class HelpTopicSearchTest extends HelpTopicTranslatedTestBase {
|
|||
*
|
||||
* @param int $count
|
||||
* The expected number of search results.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertSearchResultsCount($count) {
|
||||
protected function assertSearchResultsCount(int $count): void {
|
||||
$this->assertSession()->elementsCount('css', '.help_search-results > li', $count);
|
||||
}
|
||||
|
||||
|
|
|
@ -206,8 +206,10 @@ class ImageFormatterTest extends FieldKernelTestBase {
|
|||
* The renderable array. Must have a #cache[tags] element.
|
||||
* @param array $cache_tags
|
||||
* The expected cache tags.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCacheTags(array $renderable, array $cache_tags) {
|
||||
protected function assertCacheTags(array $renderable, array $cache_tags): void {
|
||||
$diff = array_diff($cache_tags, $renderable['#cache']['tags']);
|
||||
$this->assertEmpty($diff);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\image\Kernel\Migrate\d6;
|
|||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\image\ImageEffectPluginCollection;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
@ -141,27 +142,27 @@ class MigrateImageCacheTest extends MigrateDrupal6TestBase {
|
|||
/**
|
||||
* Assert that a given image effect is migrated.
|
||||
*
|
||||
* @param array $collection
|
||||
* @param \Drupal\image\ImageEffectPluginCollection $collection
|
||||
* Collection of effects
|
||||
* @param $id
|
||||
* @param string $id
|
||||
* Id that should exist in the collection.
|
||||
* @param $config
|
||||
* @param array $config
|
||||
* Expected configuration for the collection.
|
||||
*
|
||||
* @return bool
|
||||
* @internal
|
||||
*/
|
||||
protected function assertImageEffect($collection, $id, $config) {
|
||||
protected function assertImageEffect(ImageEffectPluginCollection $collection, string $id, array $config): void {
|
||||
/** @var \Drupal\image\ConfigurableImageEffectBase $effect */
|
||||
foreach ($collection as $effect) {
|
||||
$effect_config = $effect->getConfiguration();
|
||||
|
||||
if ($effect_config['id'] == $id && $effect_config['data'] == $config) {
|
||||
// We found this effect so succeed and return.
|
||||
return TRUE;
|
||||
// We found this effect so the assertion is successful.
|
||||
return;
|
||||
}
|
||||
}
|
||||
// The loop did not find the effect so we it was not imported correctly.
|
||||
return $this->fail('Effect ' . $id . ' did not import correctly');
|
||||
$this->fail('Effect ' . $id . ' did not import correctly');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class MigrateImageStylesTest extends MigrateDrupal7TestBase {
|
|||
* @param array $expected_effect_config
|
||||
* An array of expected configuration for each effect in the image style
|
||||
*/
|
||||
protected function assertEntity($id, $label, array $expected_effect_plugins, array $expected_effect_config) {
|
||||
protected function assertEntity(string $id, string $label, array $expected_effect_plugins, array $expected_effect_config): void {
|
||||
$style = ImageStyle::load($id);
|
||||
$this->assertInstanceOf(ImageStyleInterface::class, $style);
|
||||
/** @var \Drupal\image\ImageStyleInterface $style */
|
||||
|
|
|
@ -910,8 +910,10 @@ class FileUploadTest extends ResourceTestBase {
|
|||
* The expected data.
|
||||
* @param \Psr\Http\Message\ResponseInterface $response
|
||||
* The file upload response.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertResponseData(array $expected, ResponseInterface $response) {
|
||||
protected function assertResponseData(array $expected, ResponseInterface $response): void {
|
||||
static::recursiveKSort($expected);
|
||||
$actual = Json::decode((string) $response->getBody());
|
||||
static::recursiveKSort($actual);
|
||||
|
|
|
@ -370,8 +370,10 @@ class NodeTest extends ResourceTestBase {
|
|||
* Asserts that normalizations are cached in an incremental way.
|
||||
*
|
||||
* @throws \Drupal\Core\Entity\EntityStorageException
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCacheableNormalizations() {
|
||||
protected function assertCacheableNormalizations(): void {
|
||||
// Save the entity to invalidate caches.
|
||||
$this->entity->save();
|
||||
$uuid = $this->entity->uuid();
|
||||
|
@ -407,8 +409,10 @@ class NodeTest extends ResourceTestBase {
|
|||
*
|
||||
* @param string[] $field_names
|
||||
* The field names.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertNormalizedFieldsAreCached($field_names) {
|
||||
protected function assertNormalizedFieldsAreCached(array $field_names): void {
|
||||
$cache = \Drupal::service('render_cache')->get([
|
||||
'#cache' => [
|
||||
'keys' => ['node--camelids', $this->entity->uuid()],
|
||||
|
|
|
@ -112,7 +112,7 @@ class RestJsonApiUnsupported extends ResourceTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {}
|
||||
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -315,8 +315,10 @@ class UserTest extends ResourceTestBase {
|
|||
* The username to log in with.
|
||||
* @param string $password
|
||||
* The password to log in with.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertRpcLogin($username, $password) {
|
||||
protected function assertRpcLogin(string $username, string $password): void {
|
||||
$request_body = [
|
||||
'name' => $username,
|
||||
'pass' => $password,
|
||||
|
|
|
@ -66,8 +66,10 @@ class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal
|
|||
* The expected state of language alterable.
|
||||
* @param array $third_party_settings
|
||||
* The content translation setting.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertLanguageContentSettings($target_entity, $bundle, $default_langcode, $language_alterable, array $third_party_settings) {
|
||||
public function assertLanguageContentSettings(string $target_entity, string $bundle, string $default_langcode, bool $language_alterable, array $third_party_settings): void {
|
||||
$config = ContentLanguageSettings::load($target_entity . "." . $bundle);
|
||||
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
|
||||
$this->assertSame($target_entity, $config->getTargetEntityTypeId());
|
||||
|
|
|
@ -28,8 +28,10 @@ class MigrateLanguageTest extends MigrateDrupal6TestBase {
|
|||
* ConfigurableLanguageInterface). Defaults to LTR.
|
||||
* @param int $weight
|
||||
* (optional) The weight of the language. Defaults to 0.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertLanguage($id, $label, $direction = ConfigurableLanguageInterface::DIRECTION_LTR, $weight = 0) {
|
||||
protected function assertLanguage(string $id, string $label, string $direction = ConfigurableLanguageInterface::DIRECTION_LTR, int $weight = 0): void {
|
||||
/** @var \Drupal\language\ConfigurableLanguageInterface $language */
|
||||
$language = ConfigurableLanguage::load($id);
|
||||
$this->assertInstanceOf(ConfigurableLanguageInterface::class, $language);
|
||||
|
|
|
@ -67,8 +67,10 @@ class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal
|
|||
* The expected state of language alterable.
|
||||
* @param array $third_party_settings
|
||||
* The content translation setting.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function assertLanguageContentSettings($target_entity, $bundle, $default_langcode, $language_alterable, array $third_party_settings) {
|
||||
public function assertLanguageContentSettings(string $target_entity, string $bundle, string $default_langcode, bool $language_alterable, array $third_party_settings): void {
|
||||
$config = ContentLanguageSettings::load($target_entity . '.' . $bundle);
|
||||
$this->assertInstanceOf(ContentLanguageSettings::class, $config);
|
||||
$this->assertSame($target_entity, $config->getTargetEntityTypeId());
|
||||
|
|
|
@ -279,7 +279,7 @@ class LayoutBuilderAccessTest extends BrowserTestBase {
|
|||
* @param bool $expected_access
|
||||
* The expected access.
|
||||
*/
|
||||
private function assertExpectedAccess($expected_access) {
|
||||
private function assertExpectedAccess(bool $expected_access): void {
|
||||
$expected_status_code = $expected_access ? 200 : 403;
|
||||
$this->assertSession()->statusCodeEquals($expected_status_code);
|
||||
}
|
||||
|
|
|
@ -1452,8 +1452,10 @@ class LayoutBuilderTest extends BrowserTestBase {
|
|||
|
||||
/**
|
||||
* Asserts that the correct layouts are available.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCorrectLayouts() {
|
||||
protected function assertCorrectLayouts(): void {
|
||||
$assert_session = $this->assertSession();
|
||||
// Ensure the layouts provided by layout_builder are available.
|
||||
$expected_layouts_hrefs = [
|
||||
|
|
|
@ -293,8 +293,10 @@ class LayoutSectionTest extends BrowserTestBase {
|
|||
* A string of cache tags to be found in the header.
|
||||
* @param string $expected_dynamic_cache
|
||||
* The expected dynamic cache header. Either 'HIT', 'MISS' or 'UNCACHEABLE'.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertLayoutSection($expected_selector, $expected_content, $expected_cache_contexts = '', $expected_cache_tags = '', $expected_dynamic_cache = 'MISS') {
|
||||
protected function assertLayoutSection($expected_selector, $expected_content, string $expected_cache_contexts = '', string $expected_cache_tags = '', string $expected_dynamic_cache = 'MISS'): void {
|
||||
$assert_session = $this->assertSession();
|
||||
// Find the given selector.
|
||||
foreach ((array) $expected_selector as $selector) {
|
||||
|
|
|
@ -149,8 +149,10 @@ class BlockFilterTest extends WebDriverTestBase {
|
|||
*
|
||||
* @param string $expected_message
|
||||
* The text expected to be present in #drupal-live-announce.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertAnnounceContains($expected_message) {
|
||||
protected function assertAnnounceContains(string $expected_message): void {
|
||||
$assert_session = $this->assertSession();
|
||||
$this->assertNotEmpty($assert_session->waitForElement('css', "#drupal-live-announce:contains('$expected_message')"));
|
||||
}
|
||||
|
|
|
@ -91,8 +91,10 @@ class BlockFormMessagesTest extends WebDriverTestBase {
|
|||
|
||||
/**
|
||||
* Asserts that the validation messages are shown correctly.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertMessagesDisplayed() {
|
||||
protected function assertMessagesDisplayed(): void {
|
||||
$assert_session = $this->assertSession();
|
||||
$page = $this->getSession()->getPage();
|
||||
$messages_locator = '#drupal-off-canvas .messages--error';
|
||||
|
|
|
@ -123,8 +123,10 @@ class ContentPreviewToggleTest extends WebDriverTestBase {
|
|||
|
||||
/**
|
||||
* Checks if contextual links are working properly.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertContextualLinks() {
|
||||
protected function assertContextualLinks(): void {
|
||||
$page = $this->getSession()->getPage();
|
||||
$assert_session = $this->assertSession();
|
||||
|
||||
|
@ -141,8 +143,10 @@ class ContentPreviewToggleTest extends WebDriverTestBase {
|
|||
*
|
||||
* @param string[] $items
|
||||
* An ordered list of strings that should appear in the blocks.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertOrderInPage(array $items) {
|
||||
protected function assertOrderInPage(array $items): void {
|
||||
$session = $this->getSession();
|
||||
$page = $session->getPage();
|
||||
$blocks = $page->findAll('css', '[data-layout-content-preview-placeholder-label]');
|
||||
|
|
|
@ -123,8 +123,10 @@ class ContextualLinksTest extends WebDriverTestBase {
|
|||
|
||||
/**
|
||||
* Asserts the contextual links are correct in Layout Builder UI.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCorrectContextualLinksInUi() {
|
||||
protected function assertCorrectContextualLinksInUi(): void {
|
||||
$assert_session = $this->assertSession();
|
||||
$page = $this->getSession()->getPage();
|
||||
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '.block-views-blocktest-block-view-block-2'));
|
||||
|
@ -139,8 +141,10 @@ class ContextualLinksTest extends WebDriverTestBase {
|
|||
|
||||
/**
|
||||
* Asserts the contextual links are correct on the canonical entity route.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function assertCorrectContextualLinksInNode() {
|
||||
protected function assertCorrectContextualLinksInNode(): void {
|
||||
$assert_session = $this->assertSession();
|
||||
$page = $this->getSession()->getPage();
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
|
|||
$this->assertSaveLayout();
|
||||
|
||||
$this->drupalGet('node/1');
|
||||
$private_href1 = $this->assertFileAccessibleOnNode($file);
|
||||
$private_href1 = $this->getFileHrefAccessibleOnNode($file);
|
||||
|
||||
// Remove the inline block with the private file.
|
||||
$this->drupalGet('node/1/layout');
|
||||
|
@ -121,7 +121,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
|
|||
$this->assertSaveLayout();
|
||||
|
||||
$this->drupalGet('node/1');
|
||||
$private_href2 = $this->assertFileAccessibleOnNode($file2);
|
||||
$private_href2 = $this->getFileHrefAccessibleOnNode($file2);
|
||||
|
||||
$this->createNewNodeRevision(1);
|
||||
|
||||
|
@ -131,7 +131,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
|
|||
$this->assertSaveLayout();
|
||||
|
||||
$this->drupalGet('node/1');
|
||||
$private_href3 = $this->assertFileAccessibleOnNode($file3);
|
||||
$private_href3 = $this->getFileHrefAccessibleOnNode($file3);
|
||||
|
||||
// $file2 is on a previous revision of the block which is on a previous
|
||||
// revision of the node. The user does not have access to view the previous
|
||||
|
@ -154,7 +154,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
|
|||
$this->assertSaveLayout();
|
||||
|
||||
$this->drupalGet('node/2');
|
||||
$private_href4 = $this->assertFileAccessibleOnNode($file4);
|
||||
$private_href4 = $this->getFileHrefAccessibleOnNode($file4);
|
||||
|
||||
$this->createNewNodeRevision(2);
|
||||
|
||||
|
@ -236,7 +236,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts a file is accessible on the page.
|
||||
* Returns the href of a file, asserting it is accessible on the page.
|
||||
*
|
||||
* @param \Drupal\file\FileInterface $file
|
||||
* The file entity.
|
||||
|
@ -244,17 +244,16 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
|
|||
* @return string
|
||||
* The file href.
|
||||
*/
|
||||
protected function assertFileAccessibleOnNode(FileInterface $file) {
|
||||
$assert_session = $this->assertSession();
|
||||
protected function getFileHrefAccessibleOnNode(FileInterface $file): string {
|
||||
$page = $this->getSession()->getPage();
|
||||
$assert_session->linkExists($file->label());
|
||||
$this->assertSession()->linkExists($file->label());
|
||||
$private_href = $page->findLink($file->label())->getAttribute('href');
|
||||
$page->clickLink($file->label());
|
||||
$assert_session->pageTextContains($this->getFileSecret($file));
|
||||
$this->assertSession()->pageTextContains($this->getFileSecret($file));
|
||||
|
||||
// Access file directly.
|
||||
$this->drupalGet($private_href);
|
||||
$assert_session->pageTextContains($this->getFileSecret($file));
|
||||
$this->assertSession()->pageTextContains($this->getFileSecret($file));
|
||||
return $private_href;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue