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
catch 2021-11-22 15:25:32 +00:00
parent 2eec3dc4cb
commit 37a54000b8
320 changed files with 1615 additions and 783 deletions

View File

@ -57,8 +57,10 @@ class MigrateActionsTest extends MigrateDrupal6TestBase {
* The expected Action type. * The expected Action type.
* @param array $configuration * @param array $configuration
* The expected Action 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); $action = Action::load($id);
$this->assertInstanceOf(Action::class, $action); $this->assertInstanceOf(Action::class, $action);

View File

@ -57,8 +57,10 @@ class MigrateActionsTest extends MigrateDrupal7TestBase {
* The expected Action type. * The expected Action type.
* @param array $configuration * @param array $configuration
* The expected Action 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); $action = Action::load($id);
$this->assertInstanceOf(Action::class, $action); $this->assertInstanceOf(Action::class, $action);

View File

@ -327,7 +327,10 @@ class BigPipeTest extends BrowserTestBase {
$this->assertSession()->responseNotContains('The count is 3.'); $this->assertSession()->responseNotContains('The count is 3.');
} }
protected function assertBigPipeResponseHeadersPresent() { /**
* @internal
*/
protected function assertBigPipeResponseHeadersPresent(): void {
// Check that Cache-Control header set to "private". // Check that Cache-Control header set to "private".
$this->assertSession()->responseHeaderContains('Cache-Control', 'private'); $this->assertSession()->responseHeaderContains('Cache-Control', 'private');
$this->assertSession()->responseHeaderEquals('Surrogate-Control', 'no-store, content="BigPipe/1.0"'); $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 * @param array $expected_big_pipe_nojs_placeholders
* Keys: BigPipe no-JS placeholder markup. Values: expected replacement * Keys: BigPipe no-JS placeholder markup. Values: expected replacement
* markup. * 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')))); $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) { foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
// Checking whether the replacement for the BigPipe no-JS placeholder // 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 * @param array $expected_big_pipe_placeholder_stream_order
* Keys: BigPipe placeholder IDs. Values: expected AJAX response. Keys are * Keys: BigPipe placeholder IDs. Values: expected AJAX response. Keys are
* defined in the order that they are expected to be rendered & streamed. * 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'))); $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->getSession()->getResponseHeader('BigPipe-Test-Placeholders')));
$placeholder_positions = []; $placeholder_positions = [];
$placeholder_replacement_positions = []; $placeholder_replacement_positions = [];
@ -437,36 +444,49 @@ class BigPipeTest extends BrowserTestBase {
/** /**
* Asserts whether arrays A and B are equal, when treated as sets. * 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) { protected function assertSetsEqual(array $a, array $b): void {
return count($a) == count($b) && !array_diff_assoc($a, $b); $result = count($a) == count($b) && !array_diff_assoc($a, $b);
} }
/** /**
* Asserts whether a BigPipe no-JS cookie exists or not. * 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'); $this->assertCookieExists('big_pipe_nojs', $expected, 'BigPipe no-JS');
} }
/** /**
* Asserts whether a session cookie exists or not. * 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'); $this->assertCookieExists($this->getSessionName(), $expected, 'Session');
} }
/** /**
* Asserts whether a cookie exists on the client or not. * 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."); $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. * Calls ::performMetaRefresh() and asserts the responses.
*
* @internal
*/ */
protected function assertBigPipeNoJsMetaRefreshRedirect() { protected function assertBigPipeNoJsMetaRefreshRedirect(): void {
$original_url = $this->getSession()->getCurrentUrl(); $original_url = $this->getSession()->getCurrentUrl();
// Disable automatic following of redirects by the HTTP client, so that this // Disable automatic following of redirects by the HTTP client, so that this

View File

@ -288,8 +288,10 @@ class BlockViewBuilderTest extends KernelTestBase {
* The expected cache tags. * The expected cache tags.
* @param int $expected_max_age * @param int $expected_max_age
* The 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']; $required_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions'];
// Check that the expected cacheability metadata is present in: // Check that the expected cacheability metadata is present in:

View File

@ -69,14 +69,16 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
* The display region. * The display region.
* @param string $theme * @param string $theme
* The theme. * The theme.
* @param string $weight * @param int $weight
* The block weight. * The block weight.
* @param array $settings * @param array $settings
* (optional) The block settings. * (optional) The block settings.
* @param bool $status * @param bool $status
* Whether the block is expected to be enabled or disabled. * 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); $block = Block::load($id);
$this->assertInstanceOf(Block::class, $block); $this->assertInstanceOf(Block::class, $block);
$this->assertSame($visibility, $block->getVisibility()); $this->assertSame($visibility, $block->getVisibility());

View File

@ -73,7 +73,7 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
* The display region. * The display region.
* @param string $theme * @param string $theme
* The theme. * The theme.
* @param string $weight * @param int $weight
* The block weight. * The block weight.
* @param string $label * @param string $label
* The block label. * The block label.
@ -81,8 +81,10 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
* The block label display setting. * The block label display setting.
* @param bool $status * @param bool $status
* Whether the block is expected to be enabled or disabled. * 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); $block = Block::load($id);
$this->assertInstanceOf(Block::class, $block); $this->assertInstanceOf(Block::class, $block);
/** @var \Drupal\block\BlockInterface $block */ /** @var \Drupal\block\BlockInterface $block */

View File

@ -99,8 +99,10 @@ class BlockContentFieldFilterTest extends BlockContentTestBase {
* that translation should be shown on the given page. * that translation should be shown on the given page.
* @param string $message * @param string $message
* Message suffix to display. * 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. // Get the text of the page.
$this->drupalGet($path); $this->drupalGet($path);
$text = $this->getTextContent(); $text = $this->getTextContent();

View File

@ -59,8 +59,10 @@ class BlockContentIntegrationTest extends BlockContentTestBase {
* *
* @param array $expected_ids * @param array $expected_ids
* An array of block_content 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"]'); $result = $this->xpath('//span[@class="field-content"]');
$ids = []; $ids = [];
foreach ($result as $element) { foreach ($result as $element) {

View File

@ -38,8 +38,10 @@ class MigrateBlockContentEntityDisplayTest extends MigrateDrupal7TestBase {
* The entity ID. * The entity ID.
* @param string $component_id * @param string $component_id
* The ID of the display component. * 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); $component = EntityViewDisplay::load($id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('hidden', $component['label']); $this->assertSame('hidden', $component['label']);

View File

@ -38,8 +38,10 @@ class MigrateBlockContentEntityFormDisplayTest extends MigrateDrupal7TestBase {
* The entity ID. * The entity ID.
* @param string $component_id * @param string $component_id
* The ID of the form component. * 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); $component = EntityFormDisplay::load($id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('text_textarea_with_summary', $component['type']); $this->assertSame('text_textarea_with_summary', $component['type']);

View File

@ -143,9 +143,11 @@ class BookJavascriptTest extends WebDriverTestBase {
* @throws \Behat\Mink\Exception\ExpectationException * @throws \Behat\Mink\Exception\ExpectationException
* When any of the given string is not found. * When any of the given string is not found.
* *
* @internal
*
* @todo Remove this once https://www.drupal.org/node/2817657 is committed. * @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(); $session = $this->getSession();
$text = $session->getPage()->getHtml(); $text = $session->getPage()->getHtml();
$strings = []; $strings = [];

View File

@ -289,6 +289,8 @@ class BookMultilingualTest extends KernelTestBase {
* A book tree item. * A book tree item.
* @param string $langcode * @param string $langcode
* The language code for the requested translation. * The language code for the requested translation.
*
* @internal
*/ */
protected function assertBookItemIsCorrectlyTranslated(array $item, string $langcode): void { protected function assertBookItemIsCorrectlyTranslated(array $item, string $langcode): void {
$this->assertNodeLinkIsCorrectlyTranslated($item['original_link']['nid'], $item['title'], $item['url'], $langcode); $this->assertNodeLinkIsCorrectlyTranslated($item['original_link']['nid'], $item['title'], $item['url'], $langcode);
@ -305,6 +307,8 @@ class BookMultilingualTest extends KernelTestBase {
* The URL being tested. * The URL being tested.
* @param string $langcode * @param string $langcode
* The language code. * The language code.
*
* @internal
*/ */
protected function assertNodeLinkIsCorrectlyTranslated(int $nid, string $title, Url $url, string $langcode): void { protected function assertNodeLinkIsCorrectlyTranslated(int $nid, string $title, Url $url, string $langcode): void {
$node = Node::load($nid); $node = Node::load($nid);
@ -324,8 +328,10 @@ class BookMultilingualTest extends KernelTestBase {
* The node ID. * The node ID.
* @param string $indent * @param string $indent
* The indentation before the actual table of contents label. * 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 = Node::load($nid);
$node_label = $node->getTranslation($langcode)->label(); $node_label = $node->getTranslation($langcode)->label();
$this->assertSame($indent . ' ' . $node_label, $toc[$nid]); $this->assertSame($indent . ' ' . $node_label, $toc[$nid]);

View File

@ -473,8 +473,10 @@ class CKEditorTest extends KernelTestBase {
* @param string $langcode * @param string $langcode
* Language code to assert for. Defaults to French. That is the default * Language code to assert for. Defaults to French. That is the default
* language set in this assertion. * 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. // Set French as the site default language.
ConfigurableLanguage::createFromLangcode('fr')->save(); ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('default_langcode', 'fr')->save(); $this->config('system.site')->set('default_langcode', 'fr')->save();

View File

@ -664,11 +664,13 @@ class MediaTest extends WebDriverTestBase {
* *
* @param string $attribute * @param string $attribute
* The attribute to check. * The attribute to check.
* @param mixed $value * @param string|null $value
* Either a string value or if NULL, asserts that <drupal-media> element * Either a string value or if NULL, asserts that <drupal-media> element
* doesn't have the attribute. * doesn't have the attribute.
*
* @internal
*/ */
protected function assertSourceAttributeSame($attribute, $value) { protected function assertSourceAttributeSame(string $attribute, ?string $value): void {
$dom = $this->getEditorDataAsDom(); $dom = $this->getEditorDataAsDom();
$drupal_media = (new \DOMXPath($dom))->query('//drupal-media'); $drupal_media = (new \DOMXPath($dom))->query('//drupal-media');
$this->assertNotEmpty($drupal_media); $this->assertNotEmpty($drupal_media);

View File

@ -210,8 +210,10 @@ class CommentPagerTest extends CommentTestBase {
* An array of comments, must be of the type CommentInterface. * An array of comments, must be of the type CommentInterface.
* @param array $expected_order * @param array $expected_order
* An array of keys from $comments describing the 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 = []; $expected_cids = [];
// First, rekey the expected order by cid. // First, rekey the expected order by cid.

View File

@ -131,8 +131,10 @@ class CommentThreadingTest extends CommentTestBase {
* The comment ID to check. * The comment ID to check.
* @param int $pid * @param int $pid
* The expected parent comment ID. * 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: // This pattern matches a markup structure like:
// @code // @code
// <a id="comment-2"></a> // <a id="comment-2"></a>
@ -152,8 +154,10 @@ class CommentThreadingTest extends CommentTestBase {
* *
* @param int $cid * @param int $cid
* The comment ID to check. * The comment ID to check.
*
* @internal
*/ */
protected function assertNoParentLink($cid) { protected function assertNoParentLink(int $cid): void {
// This pattern matches a markup structure like: // This pattern matches a markup structure like:
// @code // @code
// <a id="comment-2"></a> // <a id="comment-2"></a>

View File

@ -108,8 +108,10 @@ class CommentFieldFilterTest extends CommentTestBase {
* that translation should be shown on the given page. * that translation should be shown on the given page.
* @param string $message * @param string $message
* Message suffix to display. * 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. // Get the text of the page.
$this->drupalGet($path); $this->drupalGet($path);
$text = $this->getTextContent(); $text = $this->getTextContent();

View File

@ -189,8 +189,10 @@ class CommentValidationTest extends EntityKernelTestBase {
* The field that violates the maximum length. * The field that violates the maximum length.
* @param int $length * @param int $length
* Number of characters that was exceeded. * 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(); $violations = $comment->validate();
$this->assertCount(1, $violations, "Violation found when $field_name is too long."); $this->assertCount(1, $violations, "Violation found when $field_name is too long.");
$this->assertEquals("{$field_name}.0.value", $violations[0]->getPropertyPath()); $this->assertEquals("{$field_name}.0.value", $violations[0]->getPropertyPath());

View File

@ -41,8 +41,10 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal6TestBase {
* The entity ID. * The entity ID.
* @param string $component_id * @param string $component_id
* The ID of the display component. * 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); $component = EntityViewDisplay::load($id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('hidden', $component['label']); $this->assertSame('hidden', $component['label']);

View File

@ -35,8 +35,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase
* *
* @param string $id * @param string $id
* The entity form display ID. * The entity form display ID.
*
* @internal
*/ */
protected function assertSubjectVisible($id) { protected function assertSubjectVisible(string $id): void {
$component = EntityFormDisplay::load($id)->getComponent('subject'); $component = EntityFormDisplay::load($id)->getComponent('subject');
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('string_textfield', $component['type']); $this->assertSame('string_textfield', $component['type']);
@ -48,8 +50,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase
* *
* @param string $id * @param string $id
* The entity form display ID. * The entity form display ID.
*
* @internal
*/ */
protected function assertSubjectNotVisible($id) { protected function assertSubjectNotVisible(string $id): void {
$component = EntityFormDisplay::load($id)->getComponent('subject'); $component = EntityFormDisplay::load($id)->getComponent('subject');
$this->assertNull($component); $this->assertNull($component);
} }

View File

@ -40,8 +40,10 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal6TestBase {
* The entity ID. * The entity ID.
* @param string $component_id * @param string $component_id
* The ID of the form component. * 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); $component = EntityFormDisplay::load($id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('comment_default', $component['type']); $this->assertSame('comment_default', $component['type']);

View File

@ -45,14 +45,16 @@ class MigrateCommentFieldInstanceTest extends MigrateDrupal6TestBase {
* The field's default_mode setting. * The field's default_mode setting.
* @param int $per_page * @param int $per_page
* The field's per_page setting. * The field's per_page setting.
* @param bool $anonymous * @param int $anonymous
* The field's anonymous setting. * The field's anonymous setting.
* @param int $form_location * @param bool $form_location
* The field's form_location setting. * The field's form_location setting.
* @param bool $preview * @param int $preview
* The field's preview setting. * 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"); $entity = FieldConfig::load("node.$bundle.$field_name");
$this->assertInstanceOf(FieldConfig::class, $entity); $this->assertInstanceOf(FieldConfig::class, $entity);
$this->assertSame('node', $entity->getTargetEntityTypeId()); $this->assertSame('node', $entity->getTargetEntityTypeId());

View File

@ -35,8 +35,10 @@ class MigrateCommentFieldTest extends MigrateDrupal6TestBase {
* *
* @param string $comment_type * @param string $comment_type
* The comment type. * The comment type.
*
* @internal
*/ */
protected function assertEntity($comment_type) { protected function assertEntity(string $comment_type): void {
$entity = FieldStorageConfig::load('node.' . $comment_type); $entity = FieldStorageConfig::load('node.' . $comment_type);
$this->assertInstanceOf(FieldStorageConfig::class, $entity); $this->assertInstanceOf(FieldStorageConfig::class, $entity);
$this->assertSame('node', $entity->getTargetEntityTypeId()); $this->assertSame('node', $entity->getTargetEntityTypeId());

View File

@ -25,8 +25,10 @@ class MigrateCommentTypeTest extends MigrateDrupal6TestBase {
* The entity ID. * The entity ID.
* @param string $label * @param string $label
* The entity label. * The entity label.
*
* @internal
*/ */
protected function assertEntity($id, $label) { protected function assertEntity(string $id, string $label): void {
$entity = CommentType::load($id); $entity = CommentType::load($id);
$this->assertInstanceOf(CommentType::class, $entity); $this->assertInstanceOf(CommentType::class, $entity);
$this->assertSame($label, $entity->label()); $this->assertSame($label, $entity->label());

View File

@ -39,8 +39,10 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
* The entity ID. * The entity ID.
* @param string $component_id * @param string $component_id
* The ID of the display component. * 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); $component = EntityViewDisplay::load($id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('hidden', $component['label']); $this->assertSame('hidden', $component['label']);

View File

@ -32,8 +32,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase
* *
* @param string $id * @param string $id
* The entity form display ID. * The entity form display ID.
*
* @internal
*/ */
protected function assertSubjectVisible($id) { protected function assertSubjectVisible(string $id): void {
$component = EntityFormDisplay::load($id)->getComponent('subject'); $component = EntityFormDisplay::load($id)->getComponent('subject');
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('string_textfield', $component['type']); $this->assertSame('string_textfield', $component['type']);
@ -45,8 +47,10 @@ class MigrateCommentEntityFormDisplaySubjectTest extends MigrateDrupal7TestBase
* *
* @param string $id * @param string $id
* The entity form display ID. * The entity form display ID.
*
* @internal
*/ */
protected function assertSubjectNotVisible($id) { protected function assertSubjectNotVisible(string $id): void {
$component = EntityFormDisplay::load($id)->getComponent('subject'); $component = EntityFormDisplay::load($id)->getComponent('subject');
$this->assertNull($component); $this->assertNull($component);
} }

View File

@ -39,8 +39,10 @@ class MigrateCommentEntityFormDisplayTest extends MigrateDrupal7TestBase {
* The entity ID. * The entity ID.
* @param string $component_id * @param string $component_id
* The ID of the form component. * 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); $component = EntityFormDisplay::load($id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame('comment_default', $component['type']); $this->assertSame('comment_default', $component['type']);

View File

@ -44,14 +44,16 @@ class MigrateCommentFieldInstanceTest extends MigrateDrupal7TestBase {
* The field's default_mode setting. * The field's default_mode setting.
* @param int $per_page * @param int $per_page
* The field's per_page setting. * The field's per_page setting.
* @param bool $anonymous * @param int $anonymous
* The field's anonymous setting. * The field's anonymous setting.
* @param int $form_location * @param bool $form_location
* The field's form_location setting. * The field's form_location setting.
* @param bool $preview * @param int $preview
* The field's preview setting. * 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"); $entity = FieldConfig::load("node.$bundle.$field_name");
$this->assertInstanceOf(FieldConfig::class, $entity); $this->assertInstanceOf(FieldConfig::class, $entity);
$this->assertSame('node', $entity->getTargetEntityTypeId()); $this->assertSame('node', $entity->getTargetEntityTypeId());

View File

@ -32,8 +32,10 @@ class MigrateCommentFieldTest extends MigrateDrupal7TestBase {
* *
* @param string $comment_type * @param string $comment_type
* The comment type. * The comment type.
*
* @internal
*/ */
protected function assertEntity($comment_type) { protected function assertEntity(string $comment_type): void {
$entity = FieldStorageConfig::load('node.' . $comment_type); $entity = FieldStorageConfig::load('node.' . $comment_type);
$this->assertInstanceOf(FieldStorageConfig::class, $entity); $this->assertInstanceOf(FieldStorageConfig::class, $entity);
$this->assertSame('node', $entity->getTargetEntityTypeId()); $this->assertSame('node', $entity->getTargetEntityTypeId());

View File

@ -25,8 +25,10 @@ class MigrateCommentTypeTest extends MigrateDrupal7TestBase {
* The entity ID. * The entity ID.
* @param string $label * @param string $label
* The entity label. * The entity label.
*
* @internal
*/ */
protected function assertEntity($id, $label) { protected function assertEntity(string $id, string $label): void {
$entity = CommentType::load($id); $entity = CommentType::load($id);
$this->assertInstanceOf(CommentType::class, $entity); $this->assertInstanceOf(CommentType::class, $entity);
$this->assertSame($label, $entity->label()); $this->assertSame($label, $entity->label());

View File

@ -1186,10 +1186,9 @@ class ConfigTranslationUiTest extends BrowserTestBase {
* @param string $id * @param string $id
* The HTML ID of the textarea. * The HTML ID of the textarea.
* *
* @return bool * @internal
* TRUE if the assertion passed; FALSE otherwise.
*/ */
protected function assertDisabledTextarea($id) { protected function assertDisabledTextarea(string $id): void {
$textarea = $this->assertSession()->fieldDisabled($id); $textarea = $this->assertSession()->fieldDisabled($id);
$this->assertSame('textarea', $textarea->getTagName()); $this->assertSame('textarea', $textarea->getTagName());
$this->assertSame('This field has been disabled because you do not have sufficient permissions to edit it.', $textarea->getText()); $this->assertSame('This field has been disabled because you do not have sufficient permissions to edit it.', $textarea->getText());

View File

@ -98,8 +98,10 @@ class ContactLinkTest extends ViewTestBase {
* All user objects used by the test. * All user objects used by the test.
* @param array $names * @param array $names
* Users which should have contact links. * 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)); $this->assertSession()->elementsCount('xpath', '//div[contains(@class, "views-field-contact")]//a', count($names));
foreach ($names as $name) { foreach ($names as $name) {
$account_url = $accounts[$name]->toUrl('contact-form')->toString(); $account_url = $accounts[$name]->toUrl('contact-form')->toString();

View File

@ -41,8 +41,10 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
* The expected reply message. * The expected reply message.
* @param int $expected_weight * @param int $expected_weight
* The contact form's 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 */ /** @var \Drupal\contact\ContactFormInterface $entity */
$entity = ContactForm::load($id); $entity = ContactForm::load($id);
$this->assertInstanceOf(ContactFormInterface::class, $entity); $this->assertInstanceOf(ContactFormInterface::class, $entity);

View File

@ -505,8 +505,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
* *
* @param \Drupal\node\NodeInterface $node * @param \Drupal\node\NodeInterface $node
* A node object. * 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->assertEquals($node->toUrl('latest-version')->setAbsolute()->toString(), $this->getSession()->getCurrentUrl());
$this->assertModerationForm($node); $this->assertModerationForm($node);
} }
@ -519,8 +521,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
* @param bool $moderation_form * @param bool $moderation_form
* (optional) Whether the page should contain the moderation form. Defaults * (optional) Whether the page should contain the moderation form. Defaults
* to FALSE. * 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()); $this->assertNotEquals($node->toUrl('latest-version')->setAbsolute()->toString(), $this->getSession()->getCurrentUrl());
if ($moderation_form) { if ($moderation_form) {
$this->assertModerationForm($node, FALSE); $this->assertModerationForm($node, FALSE);
@ -538,8 +542,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
* @param bool $latest_tab * @param bool $latest_tab
* (optional) Whether the node form is expected to be displayed on the * (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. * 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->drupalGet($node->toUrl());
$this->assertEquals(!$latest_tab, $this->hasModerationForm()); $this->assertEquals(!$latest_tab, $this->hasModerationForm());
$this->drupalGet($node->toUrl('latest-version')); $this->drupalGet($node->toUrl('latest-version'));
@ -551,8 +557,10 @@ class ModerationLocaleTest extends ModerationStateTestBase {
* *
* @param \Drupal\node\NodeInterface $node * @param \Drupal\node\NodeInterface $node
* A node object. * A node object.
*
* @internal
*/ */
public function assertNoModerationForm(NodeInterface $node) { public function assertNoModerationForm(NodeInterface $node): void {
$this->drupalGet($node->toUrl()); $this->drupalGet($node->toUrl());
$this->assertFalse($this->hasModerationForm()); $this->assertFalse($this->hasModerationForm());
$this->drupalGet($node->toUrl('latest-version')); $this->drupalGet($node->toUrl('latest-version'));

View File

@ -327,8 +327,10 @@ class ViewsModerationStateFilterTest extends ViewTestBase {
* @param bool $check_size * @param bool $check_size
* (optional) Whether to check that size of the select element is not * (optional) Whether to check that size of the select element is not
* greater than 8. Defaults to FALSE. * 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'); $this->drupalGet('/filter-test-path');
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
@ -355,8 +357,10 @@ class ViewsModerationStateFilterTest extends ViewTestBase {
* An array of workflow IDs to check. * An array of workflow IDs to check.
* @param \Drupal\views\ViewEntityInterface $view * @param \Drupal\views\ViewEntityInterface $view
* A view configuration object. * 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(); $dependencies = $view->getDependencies();
$expected = []; $expected = [];

View File

@ -124,8 +124,10 @@ class ContentModerationStateStorageSchemaTest extends KernelTestBase {
* An array of entity values. * An array of entity values.
* @param bool $has_exception * @param bool $has_exception
* If an exception should be triggered when saving the entity. * 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 = [ $defaults = [
'moderation_state' => 'draft', 'moderation_state' => 'draft',
'workflow' => 'editorial', 'workflow' => 'editorial',

View File

@ -777,8 +777,10 @@ class ContentModerationStateTest extends KernelTestBase {
* @param bool|null $published * @param bool|null $published
* (optional) Whether to check if the entity is published or not. Defaults * (optional) Whether to check if the entity is published or not. Defaults
* to TRUE. * 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. // Get the default revision.
$entity = $this->reloadEntity($entity); $entity = $this->reloadEntity($entity);
$this->assertEquals($revision_id, $entity->getRevisionId()); $this->assertEquals($revision_id, $entity->getRevisionId());

View File

@ -123,8 +123,10 @@ class DefaultRevisionStateTest extends KernelTestBase {
* The state the content moderation state revision should be in. * The state the content moderation state revision should be in.
* @param string $expected_workflow * @param string $expected_workflow
* The workflow the content moderation state revision should be using. * 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'); $moderation_state_storage = $this->entityTypeManager->getStorage('content_moderation_state');
$query = $moderation_state_storage->getQuery()->accessCheck(FALSE); $query = $moderation_state_storage->getQuery()->accessCheck(FALSE);

View File

@ -162,8 +162,10 @@ class ModerationStateFieldItemListTest extends KernelTestBase {
/** /**
* Assert the set of expectations when the moderation state field is emptied. * 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()); $this->assertTrue($this->testNode->moderation_state->isEmpty());
// Test the empty value causes a violation in the entity. // Test the empty value causes a violation in the entity.
$violations = $this->testNode->validate(); $violations = $this->testNode->validate();

View File

@ -321,8 +321,10 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
* *
* @param string[] $states * @param string[] $states
* The states which should appear in the filter. * 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', []); $plugin = Views::pluginManager('filter')->createInstance('moderation_state_filter', []);
$view = Views::getView('test_content_moderation_state_filter_base_table'); $view = Views::getView('test_content_moderation_state_filter_base_table');
$plugin->init($view, $view->getDisplay()); $plugin->init($view, $view->getDisplay());
@ -338,8 +340,10 @@ class ViewsModerationStateFilterTest extends ViewsKernelTestBase {
* An array of filters to apply to the view. * An array of filters to apply to the view.
* @param string $view_id * @param string $view_id
* The view to execute for the results. * 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 = Views::getView($view_id);
$view->setExposedInput($filters); $view->setExposedInput($filters);
$view->execute(); $view->execute();

View File

@ -165,8 +165,10 @@ class ViewsModerationStateSortTest extends ViewsKernelTestBase {
* The sort order. * The sort order.
* @param array $expected * @param array $expected
* The expected results array. * 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. // Test with exposed input.
$view = Views::getView($view_id); $view = Views::getView($view_id);
$view->setExposedInput([ $view->setExposedInput([

View File

@ -253,7 +253,7 @@ class WorkspacesContentModerationStateTest extends ContentModerationStateTest {
/** /**
* {@inheritdoc} * {@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 // In the context of a workspace, the default revision ID is always the
// latest workspace-specific revision, so we need to adjust the expectation // latest workspace-specific revision, so we need to adjust the expectation
// of the parent assertion. // of the parent assertion.

View File

@ -85,8 +85,10 @@ class ContentTranslationOutdatedRevisionTranslationTest extends ContentTranslati
/** /**
* Checks whether the flag widget is displayed. * 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()->pageTextNotContains('Flag other translations as outdated');
$this->assertSession()->pageTextContains('Translations cannot be flagged as outdated when content is moderated.'); $this->assertSession()->pageTextContains('Translations cannot be flagged as outdated when content is moderated.');
} }

View File

@ -253,14 +253,16 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
* *
* @param string $entity_type * @param string $entity_type
* The entity type for which to check translatability. * The entity type for which to check translatability.
* @param string $bundle * @param string|null $bundle
* The bundle for which to check translatability. * The bundle for which to check translatability.
* @param bool $enabled * @param bool $enabled
* TRUE if translatability should be enabled, FALSE otherwise. * TRUE if translatability should be enabled, FALSE otherwise.
* @param array $edit * @param array $edit
* An array of values to submit to the content translation settings page. * 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->drupalGet('admin/config/regional/content-language');
$this->submitForm($edit, 'Save configuration'); $this->submitForm($edit, 'Save configuration');
$args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled']; $args = ['@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'];

View File

@ -414,10 +414,12 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
/** /**
* Assert that the current page does not contain shared form elements. * 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; $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]");
} }
} }

View File

@ -449,8 +449,10 @@ class ContentTranslationFieldSyncRevisionTest extends EntityKernelTestBase {
* *
* @param \Drupal\Core\Entity\EntityConstraintViolationListInterface $violations * @param \Drupal\Core\Entity\EntityConstraintViolationListInterface $violations
* A list of violations. * A list of violations.
*
* @internal
*/ */
protected function assertViolations(EntityConstraintViolationListInterface $violations) { protected function assertViolations(EntityConstraintViolationListInterface $violations): void {
$entity_type_id = $this->storage->getEntityTypeId(); $entity_type_id = $this->storage->getEntityTypeId();
$settings = $this->contentTranslationManager->getBundleTranslationSettings($entity_type_id, $entity_type_id); $settings = $this->contentTranslationManager->getBundleTranslationSettings($entity_type_id, $entity_type_id);
$message = !empty($settings['untranslatable_fields_hide']) ? $message = !empty($settings['untranslatable_fields_hide']) ?
@ -478,8 +480,10 @@ class ContentTranslationFieldSyncRevisionTest extends EntityKernelTestBase {
* - target ID (it) * - target ID (it)
* - alt (en) * - alt (en)
* - alt (it) * - 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 */ /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->storage->loadRevision($this->storage->getLatestRevisionId($entity_id)); $entity = $this->storage->loadRevision($this->storage->getLatestRevisionId($entity_id));
@[$revision_id, $target_id_en, $target_id_it, $alt_en, $alt_it] = $expected_values; @[$revision_id, $target_id_en, $target_id_it, $alt_en, $alt_it] = $expected_values;

View File

@ -72,8 +72,10 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
* The value the migrated entity field should have. * The value the migrated entity field should have.
* @param int $expected_term_reference_tid * @param int $expected_term_reference_tid
* The term reference ID the migrated entity field should have. * 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 */ /** @var \Drupal\taxonomy\TermInterface $entity */
$entity = Term::load($id); $entity = Term::load($id);
$this->assertInstanceOf(TermInterface::class, $entity); $this->assertInstanceOf(TermInterface::class, $entity);
@ -82,7 +84,7 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
$this->assertSame($expected_vid, $entity->bundle()); $this->assertSame($expected_vid, $entity->bundle());
$this->assertSame($expected_description, $entity->getDescription()); $this->assertSame($expected_description, $entity->getDescription());
$this->assertSame($expected_format, $entity->getFormat()); $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); $this->assertHierarchy($expected_vid, $id, $expected_parents);
} }
@ -95,8 +97,10 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
* ID of the term to check. * ID of the term to check.
* @param array $parent_ids * @param array $parent_ids
* The expected parent term 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])) { if (!isset($this->treeData[$vid])) {
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid); $tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
$this->treeData[$vid] = []; $this->treeData[$vid] = [];
@ -119,13 +123,13 @@ class MigrateTaxonomyTermTranslationTest extends MigrateDrupal6TestBase {
* Tests the Drupal 6 i18n taxonomy term to Drupal 8 migration. * Tests the Drupal 6 i18n taxonomy term to Drupal 8 migration.
*/ */
public function testTranslatedTaxonomyTerms() { 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(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(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(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(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(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(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(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, 0, []);
} }
} }

View File

@ -222,8 +222,10 @@ class ContextualDynamicContextTest extends BrowserTestBase {
* *
* @param string $id * @param string $id
* A contextual link id. * A contextual link id.
*
* @internal
*/ */
protected function assertContextualLinkPlaceHolder($id) { protected function assertContextualLinkPlaceHolder(string $id): void {
$this->assertSession()->elementAttributeContains( $this->assertSession()->elementAttributeContains(
'css', 'css',
'div[data-contextual-id="' . $id . '"]', 'div[data-contextual-id="' . $id . '"]',
@ -237,8 +239,10 @@ class ContextualDynamicContextTest extends BrowserTestBase {
* *
* @param string $id * @param string $id
* A contextual link 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 . '"]'); $this->assertSession()->elementNotExists('css', 'div[data-contextual-id="' . $id . '"]');
} }

View File

@ -100,8 +100,10 @@ class EditModeTest extends WebDriverTestBase {
/** /**
* Asserts that the correct message was announced when entering edit mode. * Asserts that the correct message was announced when entering edit mode.
*
* @internal
*/ */
protected function assertAnnounceEditMode() { protected function assertAnnounceEditMode(): void {
$web_assert = $this->assertSession(); $web_assert = $this->assertSession();
// Wait for contextual trigger button. // Wait for contextual trigger button.
$web_assert->waitForElementVisible('css', '.contextual trigger'); $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. * Assert that the correct message was announced when leaving edit mode.
*
* @internal
*/ */
protected function assertAnnounceLeaveEditMode() { protected function assertAnnounceLeaveEditMode(): void {
$web_assert = $this->assertSession(); $web_assert = $this->assertSession();
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
// Wait till all the contextual links are hidden. // Wait till all the contextual links are hidden.

View File

@ -117,7 +117,7 @@ class EntityTestDateonlyTest extends EntityTestResourceTestBase {
/** /**
* {@inheritdoc} * {@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); parent::assertNormalizationEdgeCases($method, $url, $request_options);
if ($this->entity->getEntityType()->hasKey('bundle')) { if ($this->entity->getEntityType()->hasKey('bundle')) {

View File

@ -117,7 +117,7 @@ class EntityTestDatetimeTest extends EntityTestResourceTestBase {
/** /**
* {@inheritdoc} * {@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); parent::assertNormalizationEdgeCases($method, $url, $request_options);
if ($this->entity->getEntityType()->hasKey('bundle')) { if ($this->entity->getEntityType()->hasKey('bundle')) {

View File

@ -118,7 +118,7 @@ class EntityTestDateRangeTest extends EntityTestResourceTestBase {
/** /**
* {@inheritdoc} * {@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); parent::assertNormalizationEdgeCases($method, $url, $request_options);
if ($this->entity->getEntityType()->hasKey('bundle')) { if ($this->entity->getEntityType()->hasKey('bundle')) {

View File

@ -118,7 +118,7 @@ class DbLogResourceTest extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {} protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {}
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -819,8 +819,10 @@ class DbLogTest extends BrowserTestBase {
* The database log message to check. * The database log message to check.
* @param string $message * @param string $message
* The message to pass to simpletest. * 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); $message_text = Unicode::truncate($log_message, 56, TRUE, TRUE);
$this->assertSession()->linkExists($message_text, 0, $message); $this->assertSession()->linkExists($message_text, 0, $message);
} }

View File

@ -214,12 +214,14 @@ class EditorUploadImageScaleTest extends BrowserTestBase {
/** /**
* Asserts whether the saved maximum dimensions equal the ones provided. * Asserts whether the saved maximum dimensions equal the ones provided.
* *
* @param string $width * @param int|null $width
* The expected width of the uploaded image. * The expected width of the uploaded image.
* @param string $height * @param int|null $height
* The expected height of the uploaded image. * 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(); $image_upload_settings = Editor::load('basic_html')->getImageUploadSettings();
$expected = [ $expected = [
'width' => $image_upload_settings['max_dimensions']['width'], 'width' => $image_upload_settings['max_dimensions']['width'],

View File

@ -398,8 +398,10 @@ class EntityReferenceAdminTest extends BrowserTestBase {
* The field name. * The field name.
* @param array $expected_options * @param array $expected_options
* An array of 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'); $options = $this->assertSession()->selectExists($name)->findAll('xpath', 'option');
array_walk($options, function (NodeElement &$option) { array_walk($options, function (NodeElement &$option) {
$option = $option->getValue(); $option = $option->getValue();

View File

@ -175,8 +175,10 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
/** /**
* Assert entity reference display. * Assert entity reference display.
*
* @internal
*/ */
protected function assertEntityReferenceDisplay() { protected function assertEntityReferenceDisplay(): void {
$url = $this->referrerEntity->toUrl(); $url = $this->referrerEntity->toUrl();
$translation_url = $this->referrerEntity->toUrl('canonical', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]); $translation_url = $this->referrerEntity->toUrl('canonical', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]);
@ -192,8 +194,10 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends BrowserTestBase {
/** /**
* Assert entity reference form display. * Assert entity reference form display.
*
* @internal
*/ */
protected function assertEntityReferenceFormDisplay() { protected function assertEntityReferenceFormDisplay(): void {
$this->drupalLogin($this->webUser); $this->drupalLogin($this->webUser);
$url = $this->referrerEntity->toUrl('edit-form'); $url = $this->referrerEntity->toUrl('edit-form');
$translation_url = $this->referrerEntity->toUrl('edit-form', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]); $translation_url = $this->referrerEntity->toUrl('edit-form', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]);

View File

@ -196,8 +196,10 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
* The name of the test entity. * The name of the test entity.
* @param \Drupal\Core\Entity\EntityInterface[] $referenced_entities * @param \Drupal\Core\Entity\EntityInterface[] $referenced_entities
* An array of 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( $entity = current($this->container->get('entity_type.manager')->getStorage(
$this->entityType)->loadByProperties(['name' => $entity_name])); $this->entityType)->loadByProperties(['name' => $entity_name]));

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\field\Functional\Number;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
@ -426,8 +427,10 @@ class NumberFieldTest extends BrowserTestBase {
/** /**
* Helper function to set the minimum value of a field. * 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(); $field_configuration_url = 'entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field->getName();
// Set the minimum value. // Set the minimum value.

View File

@ -352,8 +352,10 @@ class EntityReferenceAdminTest extends WebDriverTestBase {
* The field name. * The field name.
* @param array $expected_options * @param array $expected_options
* An array of 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); $field = $this->assertSession()->selectExists($name);
$options = $field->findAll('xpath', 'option'); $options = $field->findAll('xpath', 'option');
$optgroups = $field->findAll('xpath', 'optgroup'); $optgroups = $field->findAll('xpath', 'optgroup');

View File

@ -150,8 +150,10 @@ class SelectionTest extends KernelTestBase {
* *
* @param array $result * @param array $result
* Query results keyed by node type and nid. * 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 ($result as $node_type => $values) {
foreach ($values as $nid => $label) { foreach ($values as $nid => $label) {
$this->assertSame($node_type, $this->nodes[$nid]->bundle()); $this->assertSame($node_type, $this->nodes[$nid]->bundle());

View File

@ -34,8 +34,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
* The display ID. * The display ID.
* @param string $component_id * @param string $component_id
* The 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); $component = EntityViewDisplay::load($display_id)->getComponent($component_id);
$this->assertNull($component); $this->assertNull($component);
} }

View File

@ -43,8 +43,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
* *
* @param string $id * @param string $id
* The view display ID. * The view display ID.
*
* @internal
*/ */
protected function assertEntity($id) { protected function assertEntity(string $id): void {
$display = EntityViewDisplay::load($id); $display = EntityViewDisplay::load($id);
$this->assertInstanceOf(EntityViewDisplayInterface::class, $display); $this->assertInstanceOf(EntityViewDisplayInterface::class, $display);
} }
@ -62,8 +64,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
* The expected label of the component. * The expected label of the component.
* @param int $weight * @param int $weight
* The expected weight of the component. * 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); $component = EntityViewDisplay::load($display_id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame($type, $component['type']); $this->assertSame($type, $component['type']);
@ -78,8 +82,10 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
* The display ID. * The display ID.
* @param string $component_id * @param string $component_id
* The 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); $component = EntityViewDisplay::load($display_id)->getComponent($component_id);
$this->assertNull($component); $this->assertNull($component);
} }

View File

@ -50,8 +50,10 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
* Whether or not the field is required. * Whether or not the field is required.
* @param bool $expected_translatable * @param bool $expected_translatable
* Whether or not the field is expected to be 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); [$expected_entity_type, $expected_bundle, $expected_name] = explode('.', $id);
/** @var \Drupal\field\FieldConfigInterface $field */ /** @var \Drupal\field\FieldConfigInterface $field */
@ -70,12 +72,14 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
/** /**
* Asserts the settings of a link field config entity. * 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. * The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.
* @param $title_setting * @param int $title_setting
* The expected 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); $field = FieldConfig::load($id);
$this->assertSame($title_setting, $field->getSetting('title')); $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. * The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.
* @param string[] $target_bundles * @param string[] $target_bundles
* An array of expected 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); $field = FieldConfig::load($id);
$handler_settings = $field->getSetting('handler_settings'); $handler_settings = $field->getSetting('handler_settings');
$this->assertArrayHasKey('target_bundles', $handler_settings); $this->assertArrayHasKey('target_bundles', $handler_settings);

View File

@ -49,8 +49,10 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
* The expected entity type to which the display settings are attached. * The expected entity type to which the display settings are attached.
* @param string $expected_bundle * @param string $expected_bundle
* The expected bundle to which the display settings are attached. * 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 */ /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $entity */
$entity = EntityFormDisplay::load($id); $entity = EntityFormDisplay::load($id);
$this->assertInstanceOf(EntityFormDisplayInterface::class, $entity); $this->assertInstanceOf(EntityFormDisplayInterface::class, $entity);
@ -67,10 +69,12 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
* The component ID. * The component ID.
* @param string $widget_type * @param string $widget_type
* The expected widget type. * The expected widget type.
* @param string $weight * @param int $weight
* The expected weight of the component. * 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); $component = EntityFormDisplay::load($display_id)->getComponent($component_id);
$this->assertIsArray($component); $this->assertIsArray($component);
$this->assertSame($widget_type, $component['type']); $this->assertSame($widget_type, $component['type']);

View File

@ -42,8 +42,10 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
* Whether or not the field is expected to be translatable. * Whether or not the field is expected to be translatable.
* @param int $expected_cardinality * @param int $expected_cardinality
* The expected cardinality of the field. * 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); [$expected_entity_type, $expected_name] = explode('.', $id);
/** @var \Drupal\field\FieldStorageConfigInterface $field */ /** @var \Drupal\field\FieldStorageConfigInterface $field */

View File

@ -34,8 +34,10 @@ class MigrateViewModesTest extends MigrateDrupal7TestBase {
* The expected label of the view mode. * The expected label of the view mode.
* @param string $entity_type * @param string $entity_type
* The expected entity type ID which owns the view mode. * 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 */ /** @var \Drupal\Core\Entity\EntityViewModeInterface $view_mode */
$view_mode = EntityViewMode::load($id); $view_mode = EntityViewMode::load($id);
$this->assertInstanceOf(EntityViewModeInterface::class, $view_mode); $this->assertInstanceOf(EntityViewModeInterface::class, $view_mode);

View File

@ -164,8 +164,10 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
* A list of allowed operations. * A list of allowed operations.
* @param \Drupal\Core\Session\AccountInterface $user * @param \Drupal\Core\Session\AccountInterface $user
* The account to use for get access. * 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) { foreach (['view', 'update', 'delete'] as $operation) {
$expected = in_array($operation, $allow_operations); $expected = in_array($operation, $allow_operations);
$actual = $this->accessControlHandler->access($this->entity, $operation, $user); $actual = $this->accessControlHandler->access($this->entity, $operation, $user);

View File

@ -306,8 +306,10 @@ class FieldLayoutTest extends WebDriverTestBase {
* The field selector, one of field id|name|label|value. * The field selector, one of field id|name|label|value.
* @param string $region_name * @param string $region_name
* The machine name of the region. * 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"); $region_element = $this->getSession()->getPage()->find('css', ".layout__region--$region_name");
$this->assertNotNull($region_element); $this->assertNotNull($region_element);
$this->assertSession()->fieldExists($field_selector, $region_element); $this->assertSession()->fieldExists($field_selector, $region_element);

View File

@ -175,14 +175,16 @@ class FieldLayoutEntityDisplayTest extends KernelTestBase {
/** /**
* Asserts than an entity has the correct values. * Asserts than an entity has the correct values.
* *
* @param mixed $expected * @param array $expected
* The expected values. * The expected values.
* @param array $values * @param array $values
* The actual values. * The actual values.
* @param string $message * @param string $message
* (optional) An error 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); static::assertArrayHasKey('uuid', $values);
unset($values['uuid']); unset($values['uuid']);

View File

@ -108,8 +108,10 @@ class FieldUIRouteTest extends BrowserTestBase {
/** /**
* Asserts that local tasks exists. * Asserts that local tasks exists.
*
* @internal
*/ */
public function assertLocalTasks() { public function assertLocalTasks(): void {
$this->assertSession()->linkExists('Settings'); $this->assertSession()->linkExists('Settings');
$this->assertSession()->linkExists('Manage fields'); $this->assertSession()->linkExists('Manage fields');
$this->assertSession()->linkExists('Manage display'); $this->assertSession()->linkExists('Manage display');

View File

@ -220,18 +220,17 @@ class ManageDisplayTest extends BrowserTestBase {
* *
* @param \Drupal\Core\Entity\EntityInterface $node * @param \Drupal\Core\Entity\EntityInterface $node
* The node. * The node.
* @param $view_mode * @param string $view_mode
* The view mode in which the node should be displayed. * The view mode in which the node should be displayed.
* @param $text * @param string $text
* Plain text to look for. * Plain text to look for.
* @param $message * @param string $message
* Message to display. * Message to display.
* *
* @return * @internal
* TRUE on pass, FALSE on fail.
*/ */
public function assertNodeViewText(EntityInterface $node, $view_mode, $text, $message) { public function assertNodeViewText(EntityInterface $node, string $view_mode, string $text, string $message): void {
return $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, FALSE); $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, FALSE);
} }
/** /**
@ -239,18 +238,17 @@ class ManageDisplayTest extends BrowserTestBase {
* *
* @param \Drupal\Core\Entity\EntityInterface $node * @param \Drupal\Core\Entity\EntityInterface $node
* The node. * The node.
* @param $view_mode * @param string $view_mode
* The view mode in which the node should be displayed. * The view mode in which the node should be displayed.
* @param $text * @param string $text
* Plain text to look for. * Plain text to look for.
* @param $message * @param string $message
* Message to display. * Message to display.
* *
* @return * @internal
* TRUE on pass, FALSE on fail.
*/ */
public function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $message) { public function assertNodeViewNoText(EntityInterface $node, string $view_mode, string $text, string $message): void {
return $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, TRUE); $this->assertNodeViewTextHelper($node, $view_mode, $text, $message, TRUE);
} }
/** /**
@ -261,16 +259,18 @@ class ManageDisplayTest extends BrowserTestBase {
* *
* @param \Drupal\Core\Entity\EntityInterface $node * @param \Drupal\Core\Entity\EntityInterface $node
* The node. * The node.
* @param $view_mode * @param string $view_mode
* The view mode in which the node should be displayed. * The view mode in which the node should be displayed.
* @param $text * @param string $text
* Plain text to look for. * Plain text to look for.
* @param $message * @param string $message
* Message to display. * Message to display.
* @param $not_exists * @param bool $not_exists
* TRUE if this text should not exist, FALSE if it should. * 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 // Make sure caches on the tester side are refreshed after changes
// submitted on the tested side. // submitted on the tested side.
\Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
@ -297,8 +297,10 @@ class ManageDisplayTest extends BrowserTestBase {
* The field name. * The field name.
* @param array $expected_options * @param array $expected_options
* An array of 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]); $xpath = $this->assertSession()->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$fields = $this->xpath($xpath); $fields = $this->xpath($xpath);
if ($fields) { if ($fields) {

View File

@ -439,16 +439,18 @@ class ManageFieldsFunctionalTest extends BrowserTestBase {
/** /**
* Asserts field settings are as expected. * Asserts field settings are as expected.
* *
* @param $bundle * @param string $bundle
* The bundle name for the field. * The bundle name for the field.
* @param $field_name * @param string $field_name
* The field name for the field. * The field name for the field.
* @param $string * @param string $string
* The settings text. * The settings text.
* @param $entity_type * @param string $entity_type
* The entity type for the field. * 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. // Assert field storage settings.
$field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name);
$this->assertSame($string, $field_storage->getSetting('test_field_storage_setting'), 'Field storage settings were found.'); $this->assertSame($string, $field_storage->getSetting('test_field_storage_setting'), 'Field storage settings were found.');

View File

@ -2,6 +2,7 @@
namespace Drupal\Tests\field_ui\FunctionalJavascript; namespace Drupal\Tests\field_ui\FunctionalJavascript;
use Behat\Mink\Element\NodeElement;
use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
@ -387,10 +388,12 @@ class ManageDisplayTest extends WebDriverTestBase {
* The select field to validate. * The select field to validate.
* @param array $expected_options * @param array $expected_options
* An array of expected options. * An array of expected options.
* @param null $selected * @param string|null $selected
* The default value to validate. * 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 */ /** @var \Behat\Mink\Element\NodeElement[] $select_options */
$select_options = $field->findAll('xpath', 'option'); $select_options = $field->findAll('xpath', 'option');

View File

@ -649,11 +649,10 @@ class EntityDisplayTest extends KernelTestBase {
* @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
* The entity display object to get dependencies from. * The entity display object to get dependencies from.
* *
* @return bool * @internal
* TRUE if the assertion succeeded, FALSE otherwise.
*/ */
protected function assertDependency($type, $key, EntityDisplayInterface $display) { protected function assertDependency(string $type, string $key, EntityDisplayInterface $display): void {
return $this->assertDependencyHelper(TRUE, $type, $key, $display); $this->assertDependencyHelper(TRUE, $type, $key, $display);
} }
/** /**
@ -666,11 +665,10 @@ class EntityDisplayTest extends KernelTestBase {
* @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
* The entity display object to get dependencies from. * The entity display object to get dependencies from.
* *
* @return bool * @internal
* TRUE if the assertion succeeded, FALSE otherwise.
*/ */
protected function assertNoDependency($type, $key, EntityDisplayInterface $display) { protected function assertNoDependency(string $type, string $key, EntityDisplayInterface $display): void {
return $this->assertDependencyHelper(FALSE, $type, $key, $display); $this->assertDependencyHelper(FALSE, $type, $key, $display);
} }
/** /**
@ -685,10 +683,9 @@ class EntityDisplayTest extends KernelTestBase {
* @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
* The entity display object to get dependencies from. * The entity display object to get dependencies from.
* *
* @return bool * @internal
* TRUE if the assertion succeeded.
*/ */
protected function assertDependencyHelper($assertion, $type, $key, EntityDisplayInterface $display) { protected function assertDependencyHelper(bool $assertion, string $type, string $key, EntityDisplayInterface $display): void {
$all_dependencies = $display->getDependencies(); $all_dependencies = $display->getDependencies();
$dependencies = !empty($all_dependencies[$type]) ? $all_dependencies[$type] : []; $dependencies = !empty($all_dependencies[$type]) ? $all_dependencies[$type] : [];
$context = $display instanceof EntityViewDisplayInterface ? 'View' : 'Form'; $context = $display instanceof EntityViewDisplayInterface ? 'View' : 'Form';
@ -696,7 +693,6 @@ class EntityDisplayTest extends KernelTestBase {
$args = ['@context' => $context, '@id' => $display->id(), '@type' => $type, '@key' => $key]; $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); $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); $this->assertTrue($value, $message);
return TRUE;
} }
} }

View File

@ -85,8 +85,10 @@ class FileFieldPathTest extends FileFieldTestBase {
* Where the file was actually uploaded. * Where the file was actually uploaded.
* @param string $message * @param string $message
* The message to display with this assertion. * 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. // Strip off the extension of the expected path to allow for _0, _1, etc.
// suffixes when the file hits a duplicate name. // suffixes when the file hits a duplicate name.
$pos = strrpos($expected_path, '.'); $pos = strrpos($expected_path, '.');

View File

@ -49,26 +49,28 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
* The expected MIME type. * The expected MIME type.
* @param int $uid * @param int $uid
* The expected file owner ID. * 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 */ /** @var \Drupal\file\FileInterface $file */
$file = File::load($fid); $file = File::load($fid);
$this->assertInstanceOf(FileInterface::class, $file); $this->assertInstanceOf(FileInterface::class, $file);
$this->assertSame($name, $file->getFilename()); $this->assertSame($name, $file->getFilename());
$this->assertSame($size, $file->getSize()); $this->assertSame($size, (int) $file->getSize());
$this->assertSame($uri, $file->getFileUri()); $this->assertSame($uri, $file->getFileUri());
$this->assertSame($type, $file->getMimeType()); $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. * Tests the Drupal 6 files to Drupal 8 migration.
*/ */
public function testFiles() { public function testFiles() {
$this->assertEntity(1, 'Image1.png', '39325', 'public://image-1.png', 'image/png', '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(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(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(4, 'html-1.txt', 24, 'public://html-1.txt', 'text/plain', 1);
// Ensure temporary file was not migrated. // Ensure temporary file was not migrated.
$this->assertNull(File::load(6)); $this->assertNull(File::load(6));

View File

@ -175,8 +175,10 @@ class FilterFormTest extends BrowserTestBase {
* *
* @param string $id * @param string $id
* The HTML ID of the select element. * 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]"); $this->assertSession()->elementNotExists('xpath', "//select[@id=$id]");
} }
@ -190,10 +192,9 @@ class FilterFormTest extends BrowserTestBase {
* @param string $selected * @param string $selected
* The value of the selected option. * The value of the selected option.
* *
* @return bool * @internal
* TRUE if the assertion passed; FALSE otherwise.
*/ */
protected function assertOptions($id, array $expected_options, $selected) { protected function assertOptions(string $id, array $expected_options, string $selected): void {
$select = $this->assertSession()->selectExists($id); $select = $this->assertSession()->selectExists($id);
$found_options = $select->findAll('css', 'option'); $found_options = $select->findAll('css', 'option');
$found_options = array_map(function ($item) { $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 * An array of option values that are contained in the select element
* besides the "- Select -" option. * besides the "- Select -" option.
* *
* @return bool * @internal
* TRUE if the assertion passed; FALSE otherwise.
*/ */
protected function assertRequiredSelectAndOptions($id, array $options) { protected function assertRequiredSelectAndOptions(string $id, array $options): void {
$select = $this->assertSession()->selectExists($id); $select = $this->assertSession()->selectExists($id);
$this->assertSame('required', $select->getAttribute('required')); $this->assertSame('required', $select->getAttribute('required'));
// A required select element has a "- Select -" option whose key is an empty // A required select element has a "- Select -" option whose key is an empty
@ -230,10 +230,9 @@ class FilterFormTest extends BrowserTestBase {
* @param string $id * @param string $id
* The HTML ID of the textarea. * The HTML ID of the textarea.
* *
* @return bool * @internal
* TRUE if the assertion passed; FALSE otherwise.
*/ */
protected function assertEnabledTextarea($id) { protected function assertEnabledTextarea(string $id): void {
$textarea = $this->assertSession()->fieldEnabled($id); $textarea = $this->assertSession()->fieldEnabled($id);
$this->assertSame('textarea', $textarea->getTagName()); $this->assertSame('textarea', $textarea->getTagName());
} }
@ -244,10 +243,9 @@ class FilterFormTest extends BrowserTestBase {
* @param string $id * @param string $id
* The HTML ID of the textarea. * The HTML ID of the textarea.
* *
* @return bool * @internal
* TRUE if the assertion passed; FALSE otherwise.
*/ */
protected function assertDisabledTextarea($id) { protected function assertDisabledTextarea(string $id): void {
$textarea = $this->assertSession()->fieldDisabled($id); $textarea = $this->assertSession()->fieldDisabled($id);
$this->assertSame('textarea', $textarea->getTagName()); $this->assertSame('textarea', $textarea->getTagName());
$this->assertSame('This field has been disabled because you do not have sufficient permissions to edit it.', $textarea->getText()); $this->assertSame('This field has been disabled because you do not have sufficient permissions to edit it.', $textarea->getText());

View File

@ -430,10 +430,12 @@ class FilterAPITest extends EntityKernelTestBase {
* *
* @param \Symfony\Component\Validator\ConstraintViolationListInterface $violations * @param \Symfony\Component\Validator\ConstraintViolationListInterface $violations
* The violations to assert. * The violations to assert.
* @param mixed $invalid_value * @param string $invalid_value
* The expected 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; $filter_format_violation_found = FALSE;
foreach ($violations as $violation) { foreach ($violations as $violation) {
if ($violation->getRoot() instanceof FilterFormatDataType && $violation->getInvalidValue() === $invalid_value) { if ($violation->getRoot() instanceof FilterFormatDataType && $violation->getInvalidValue() === $invalid_value) {

View File

@ -9,6 +9,7 @@ use Drupal\Core\Render\RenderContext;
use Drupal\editor\EditorXssFilter\Standard; use Drupal\editor\EditorXssFilter\Standard;
use Drupal\filter\Entity\FilterFormat; use Drupal\filter\Entity\FilterFormat;
use Drupal\filter\FilterPluginCollection; use Drupal\filter\FilterPluginCollection;
use Drupal\filter\Plugin\FilterInterface;
use Drupal\KernelTests\KernelTestBase; 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. * Asserts multiple filter output expectations for multiple input strings.
* *
* @param FilterInterface $filter * @param \Drupal\filter\Plugin\FilterInterface $filter
* An input filter object. * An input filter object.
* @param array $tests * @param array $tests
* An associative array, whereas each key is an arbitrary input string and * 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 * @endcode
*
* @internal
*/ */
public function assertFilteredString($filter, $tests) { public function assertFilteredString(FilterInterface $filter, array $tests): void {
foreach ($tests as $source => $tasks) { foreach ($tests as $source => $tasks) {
$result = $filter->process($source, $filter)->getProcessedText(); $result = $filter->process($source, $filter)->getProcessedText();
foreach ($tasks as $value => $is_expected) { foreach ($tasks as $value => $is_expected) {
@ -1141,8 +1144,10 @@ body {color:red}
* (optional) Message to display if failed. Defaults to an empty string. * (optional) Message to display if failed. Defaults to an empty string.
* @param string $group * @param string $group
* (optional) The group this message belongs to. Defaults to 'Other'. * (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); $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. * (optional) Message to display if failed. Defaults to an empty string.
* @param string $group * @param string $group
* (optional) The group this message belongs to. Defaults to 'Other'. * (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); $this->assertStringNotContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
} }

View File

@ -67,8 +67,10 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase implements MigrateD
* The weight of the filter. * The weight of the filter.
* @param bool $status * @param bool $status
* The status of the filter. * 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 */ /** @var \Drupal\filter\FilterFormatInterface $entity */
$entity = FilterFormat::load($id); $entity = FilterFormat::load($id);
$this->assertInstanceOf(FilterFormatInterface::class, $entity); $this->assertInstanceOf(FilterFormatInterface::class, $entity);

View File

@ -290,8 +290,10 @@ class HelpTopicSearchTest extends HelpTopicTranslatedTestBase {
* *
* @param int $count * @param int $count
* The expected number of search results. * 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); $this->assertSession()->elementsCount('css', '.help_search-results > li', $count);
} }

View File

@ -206,8 +206,10 @@ class ImageFormatterTest extends FieldKernelTestBase {
* The renderable array. Must have a #cache[tags] element. * The renderable array. Must have a #cache[tags] element.
* @param array $cache_tags * @param array $cache_tags
* The expected 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']); $diff = array_diff($cache_tags, $renderable['#cache']['tags']);
$this->assertEmpty($diff); $this->assertEmpty($diff);
} }

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\image\Kernel\Migrate\d6;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\image\Entity\ImageStyle; use Drupal\image\Entity\ImageStyle;
use Drupal\image\ImageEffectPluginCollection;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Exception\RequirementsException;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase; use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
@ -141,27 +142,27 @@ class MigrateImageCacheTest extends MigrateDrupal6TestBase {
/** /**
* Assert that a given image effect is migrated. * Assert that a given image effect is migrated.
* *
* @param array $collection * @param \Drupal\image\ImageEffectPluginCollection $collection
* Collection of effects * Collection of effects
* @param $id * @param string $id
* Id that should exist in the collection. * Id that should exist in the collection.
* @param $config * @param array $config
* Expected configuration for the collection. * 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 */ /** @var \Drupal\image\ConfigurableImageEffectBase $effect */
foreach ($collection as $effect) { foreach ($collection as $effect) {
$effect_config = $effect->getConfiguration(); $effect_config = $effect->getConfiguration();
if ($effect_config['id'] == $id && $effect_config['data'] == $config) { if ($effect_config['id'] == $id && $effect_config['data'] == $config) {
// We found this effect so succeed and return. // We found this effect so the assertion is successful.
return TRUE; return;
} }
} }
// The loop did not find the effect so we it was not imported correctly. // 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');
} }
} }

View File

@ -49,7 +49,7 @@ class MigrateImageStylesTest extends MigrateDrupal7TestBase {
* @param array $expected_effect_config * @param array $expected_effect_config
* An array of expected configuration for each effect in the image style * 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); $style = ImageStyle::load($id);
$this->assertInstanceOf(ImageStyleInterface::class, $style); $this->assertInstanceOf(ImageStyleInterface::class, $style);
/** @var \Drupal\image\ImageStyleInterface $style */ /** @var \Drupal\image\ImageStyleInterface $style */

View File

@ -910,8 +910,10 @@ class FileUploadTest extends ResourceTestBase {
* The expected data. * The expected data.
* @param \Psr\Http\Message\ResponseInterface $response * @param \Psr\Http\Message\ResponseInterface $response
* The file upload response. * The file upload response.
*
* @internal
*/ */
protected function assertResponseData(array $expected, ResponseInterface $response) { protected function assertResponseData(array $expected, ResponseInterface $response): void {
static::recursiveKSort($expected); static::recursiveKSort($expected);
$actual = Json::decode((string) $response->getBody()); $actual = Json::decode((string) $response->getBody());
static::recursiveKSort($actual); static::recursiveKSort($actual);

View File

@ -370,8 +370,10 @@ class NodeTest extends ResourceTestBase {
* Asserts that normalizations are cached in an incremental way. * Asserts that normalizations are cached in an incremental way.
* *
* @throws \Drupal\Core\Entity\EntityStorageException * @throws \Drupal\Core\Entity\EntityStorageException
*
* @internal
*/ */
protected function assertCacheableNormalizations() { protected function assertCacheableNormalizations(): void {
// Save the entity to invalidate caches. // Save the entity to invalidate caches.
$this->entity->save(); $this->entity->save();
$uuid = $this->entity->uuid(); $uuid = $this->entity->uuid();
@ -407,8 +409,10 @@ class NodeTest extends ResourceTestBase {
* *
* @param string[] $field_names * @param string[] $field_names
* The 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 = \Drupal::service('render_cache')->get([
'#cache' => [ '#cache' => [
'keys' => ['node--camelids', $this->entity->uuid()], 'keys' => ['node--camelids', $this->entity->uuid()],

View File

@ -112,7 +112,7 @@ class RestJsonApiUnsupported extends ResourceTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {} protected function assertNormalizationEdgeCases($method, Url $url, array $request_options): void {}
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@ -315,8 +315,10 @@ class UserTest extends ResourceTestBase {
* The username to log in with. * The username to log in with.
* @param string $password * @param string $password
* The password to log in with. * The password to log in with.
*
* @internal
*/ */
protected function assertRpcLogin($username, $password) { protected function assertRpcLogin(string $username, string $password): void {
$request_body = [ $request_body = [
'name' => $username, 'name' => $username,
'pass' => $password, 'pass' => $password,

View File

@ -66,8 +66,10 @@ class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal
* The expected state of language alterable. * The expected state of language alterable.
* @param array $third_party_settings * @param array $third_party_settings
* The content translation setting. * 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); $config = ContentLanguageSettings::load($target_entity . "." . $bundle);
$this->assertInstanceOf(ContentLanguageSettings::class, $config); $this->assertInstanceOf(ContentLanguageSettings::class, $config);
$this->assertSame($target_entity, $config->getTargetEntityTypeId()); $this->assertSame($target_entity, $config->getTargetEntityTypeId());

View File

@ -28,8 +28,10 @@ class MigrateLanguageTest extends MigrateDrupal6TestBase {
* ConfigurableLanguageInterface). Defaults to LTR. * ConfigurableLanguageInterface). Defaults to LTR.
* @param int $weight * @param int $weight
* (optional) The weight of the language. Defaults to 0. * (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 */ /** @var \Drupal\language\ConfigurableLanguageInterface $language */
$language = ConfigurableLanguage::load($id); $language = ConfigurableLanguage::load($id);
$this->assertInstanceOf(ConfigurableLanguageInterface::class, $language); $this->assertInstanceOf(ConfigurableLanguageInterface::class, $language);

View File

@ -67,8 +67,10 @@ class MigrateLanguageContentTaxonomyVocabularySettingsTest extends MigrateDrupal
* The expected state of language alterable. * The expected state of language alterable.
* @param array $third_party_settings * @param array $third_party_settings
* The content translation setting. * 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); $config = ContentLanguageSettings::load($target_entity . '.' . $bundle);
$this->assertInstanceOf(ContentLanguageSettings::class, $config); $this->assertInstanceOf(ContentLanguageSettings::class, $config);
$this->assertSame($target_entity, $config->getTargetEntityTypeId()); $this->assertSame($target_entity, $config->getTargetEntityTypeId());

View File

@ -279,7 +279,7 @@ class LayoutBuilderAccessTest extends BrowserTestBase {
* @param bool $expected_access * @param bool $expected_access
* The expected access. * The expected access.
*/ */
private function assertExpectedAccess($expected_access) { private function assertExpectedAccess(bool $expected_access): void {
$expected_status_code = $expected_access ? 200 : 403; $expected_status_code = $expected_access ? 200 : 403;
$this->assertSession()->statusCodeEquals($expected_status_code); $this->assertSession()->statusCodeEquals($expected_status_code);
} }

View File

@ -1452,8 +1452,10 @@ class LayoutBuilderTest extends BrowserTestBase {
/** /**
* Asserts that the correct layouts are available. * Asserts that the correct layouts are available.
*
* @internal
*/ */
protected function assertCorrectLayouts() { protected function assertCorrectLayouts(): void {
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
// Ensure the layouts provided by layout_builder are available. // Ensure the layouts provided by layout_builder are available.
$expected_layouts_hrefs = [ $expected_layouts_hrefs = [

View File

@ -293,8 +293,10 @@ class LayoutSectionTest extends BrowserTestBase {
* A string of cache tags to be found in the header. * A string of cache tags to be found in the header.
* @param string $expected_dynamic_cache * @param string $expected_dynamic_cache
* The expected dynamic cache header. Either 'HIT', 'MISS' or 'UNCACHEABLE'. * 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(); $assert_session = $this->assertSession();
// Find the given selector. // Find the given selector.
foreach ((array) $expected_selector as $selector) { foreach ((array) $expected_selector as $selector) {

View File

@ -149,8 +149,10 @@ class BlockFilterTest extends WebDriverTestBase {
* *
* @param string $expected_message * @param string $expected_message
* The text expected to be present in #drupal-live-announce. * 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(); $assert_session = $this->assertSession();
$this->assertNotEmpty($assert_session->waitForElement('css', "#drupal-live-announce:contains('$expected_message')")); $this->assertNotEmpty($assert_session->waitForElement('css', "#drupal-live-announce:contains('$expected_message')"));
} }

View File

@ -91,8 +91,10 @@ class BlockFormMessagesTest extends WebDriverTestBase {
/** /**
* Asserts that the validation messages are shown correctly. * Asserts that the validation messages are shown correctly.
*
* @internal
*/ */
protected function assertMessagesDisplayed() { protected function assertMessagesDisplayed(): void {
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$messages_locator = '#drupal-off-canvas .messages--error'; $messages_locator = '#drupal-off-canvas .messages--error';

View File

@ -123,8 +123,10 @@ class ContentPreviewToggleTest extends WebDriverTestBase {
/** /**
* Checks if contextual links are working properly. * Checks if contextual links are working properly.
*
* @internal
*/ */
protected function assertContextualLinks() { protected function assertContextualLinks(): void {
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
@ -141,8 +143,10 @@ class ContentPreviewToggleTest extends WebDriverTestBase {
* *
* @param string[] $items * @param string[] $items
* An ordered list of strings that should appear in the blocks. * 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(); $session = $this->getSession();
$page = $session->getPage(); $page = $session->getPage();
$blocks = $page->findAll('css', '[data-layout-content-preview-placeholder-label]'); $blocks = $page->findAll('css', '[data-layout-content-preview-placeholder-label]');

View File

@ -123,8 +123,10 @@ class ContextualLinksTest extends WebDriverTestBase {
/** /**
* Asserts the contextual links are correct in Layout Builder UI. * Asserts the contextual links are correct in Layout Builder UI.
*
* @internal
*/ */
protected function assertCorrectContextualLinksInUi() { protected function assertCorrectContextualLinksInUi(): void {
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '.block-views-blocktest-block-view-block-2')); $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. * Asserts the contextual links are correct on the canonical entity route.
*
* @internal
*/ */
protected function assertCorrectContextualLinksInNode() { protected function assertCorrectContextualLinksInNode(): void {
$assert_session = $this->assertSession(); $assert_session = $this->assertSession();
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();

View File

@ -97,7 +97,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
$this->assertSaveLayout(); $this->assertSaveLayout();
$this->drupalGet('node/1'); $this->drupalGet('node/1');
$private_href1 = $this->assertFileAccessibleOnNode($file); $private_href1 = $this->getFileHrefAccessibleOnNode($file);
// Remove the inline block with the private file. // Remove the inline block with the private file.
$this->drupalGet('node/1/layout'); $this->drupalGet('node/1/layout');
@ -121,7 +121,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
$this->assertSaveLayout(); $this->assertSaveLayout();
$this->drupalGet('node/1'); $this->drupalGet('node/1');
$private_href2 = $this->assertFileAccessibleOnNode($file2); $private_href2 = $this->getFileHrefAccessibleOnNode($file2);
$this->createNewNodeRevision(1); $this->createNewNodeRevision(1);
@ -131,7 +131,7 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
$this->assertSaveLayout(); $this->assertSaveLayout();
$this->drupalGet('node/1'); $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 // $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 // 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->assertSaveLayout();
$this->drupalGet('node/2'); $this->drupalGet('node/2');
$private_href4 = $this->assertFileAccessibleOnNode($file4); $private_href4 = $this->getFileHrefAccessibleOnNode($file4);
$this->createNewNodeRevision(2); $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 * @param \Drupal\file\FileInterface $file
* The file entity. * The file entity.
@ -244,17 +244,16 @@ class InlineBlockPrivateFilesTest extends InlineBlockTestBase {
* @return string * @return string
* The file href. * The file href.
*/ */
protected function assertFileAccessibleOnNode(FileInterface $file) { protected function getFileHrefAccessibleOnNode(FileInterface $file): string {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$assert_session->linkExists($file->label()); $this->assertSession()->linkExists($file->label());
$private_href = $page->findLink($file->label())->getAttribute('href'); $private_href = $page->findLink($file->label())->getAttribute('href');
$page->clickLink($file->label()); $page->clickLink($file->label());
$assert_session->pageTextContains($this->getFileSecret($file)); $this->assertSession()->pageTextContains($this->getFileSecret($file));
// Access file directly. // Access file directly.
$this->drupalGet($private_href); $this->drupalGet($private_href);
$assert_session->pageTextContains($this->getFileSecret($file)); $this->assertSession()->pageTextContains($this->getFileSecret($file));
return $private_href; return $private_href;
} }

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