diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php index 2cec1138d2e79ab40f17ec3016e4b7a3e0a28bf5..6c4effb5e989aaf8bf3cafec5a3f8e71636ff4ff 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php @@ -37,7 +37,7 @@ public function testOffCanvasStyles() { $assert_session->assertWaitOnAjaxRequest(); $styles = $assert_session->elementExists('css', 'style#ckeditor5-off-canvas-reset'); - $this->stringContains('#drupal-off-canvas-wrapper [data-drupal-ck-style-fence]', $styles->getText()); + $this->assertStringContainsString('#drupal-off-canvas-wrapper [data-drupal-ck-style-fence]', $styles->getHtml()); $assert_session->elementExists('css', '.ck'); diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php index e782b5255a12f0511f983b3bd5d731433eeb401c..80b2a58ef0ac2939bd287481795387814095fd43 100644 --- a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php +++ b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php @@ -204,7 +204,7 @@ public function testFormatterUI() { $field_test_format_type->setValue('field_empty_setting'); $assert_session->assertWaitOnAjaxRequest(); $assert_session->responseNotContains('Default empty setting now has a value.'); - $this->assertTrue($field_test_settings->isVisible(), TRUE); + $this->assertTrue($field_test_settings->isVisible()); // Set the empty_setting option to a non-empty value again and validate // the formatting summary now display's this correctly. @@ -237,7 +237,7 @@ public function testFormatterUI() { // Ensure the button is still there after the module has been disabled. $this->drupalGet($manage_display); - $this->assertTrue($field_test_settings->isVisible(), TRUE); + $this->assertTrue($field_test_settings->isVisible()); // Ensure that third-party form elements are not present anymore. $field_test_settings->click(); diff --git a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php index cc4a03cee099c44df7965447f8074843e4bd0361..9f3a8d87ad52dd878b4a038bf18b18c9274f3bdd 100644 --- a/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php +++ b/core/modules/file/tests/src/FunctionalJavascript/FileFieldWidgetTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\file\FunctionalJavascript; -use Drupal\Component\Render\FormattableMarkup; use Drupal\file\Entity\File; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; @@ -100,7 +99,7 @@ public function testMultiValuedWidget() { // Ensure we have the expected number of Remove buttons, and that they // are numbered sequentially. $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]'); - $this->assertCount($num_expected_remove_buttons, $buttons, new FormattableMarkup('There are %n "Remove" buttons displayed.', ['%n' => $num_expected_remove_buttons])); + $this->assertCount($num_expected_remove_buttons, $buttons, 'There are ' . $num_expected_remove_buttons . ' "Remove" buttons displayed.'); foreach ($buttons as $i => $button) { $key = $i >= $remaining ? $i - $remaining : $i; $check_field_name = $field_name2; diff --git a/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php b/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php index ca30daefbd32e1c5a0608d3192c4b8543de232e9..323fdd18e42832db0449e8266b5c2a214b367fc3 100644 --- a/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php +++ b/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php @@ -99,11 +99,11 @@ public function testUploadFileExceedingMaximumFileSize() { $session = $this->getSession(); // Create a test file that exceeds the maximum POST size with 1 kilobyte. - $post_max_size = Bytes::toNumber(ini_get('post_max_size')); + $post_max_size = (int) Bytes::toNumber(ini_get('post_max_size')); $invalid_file = 'public://exceeding_post_max_size.bin'; $file = fopen($invalid_file, 'wb'); fseek($file, $post_max_size + 1024); - fwrite($file, 0x0); + fwrite($file, '0'); fclose($file); // Go to the node creation form and try to upload the test file. diff --git a/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php b/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php index f6c21f89f04780eda6dbedc03c6bf708f8f10adf..360930cc2e2bc0d11809cc77791c2623c58a5510 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\system\FunctionalJavascript; -use Drupal\Component\Render\FormattableMarkup; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** @@ -43,9 +42,9 @@ public function testLazyLoad() { // Verify that the base page doesn't have the settings and files that are to // be lazy loaded as part of the next requests. - $this->assertTrue(!isset($original_settings[$expected['setting_name']]), new FormattableMarkup('Page originally lacks the %setting, as expected.', ['%setting' => $expected['setting_name']])); - $this->assertNotContains($expected['library_1'], $original_libraries, new FormattableMarkup('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_1']])); - $this->assertNotContains($expected['library_2'], $original_libraries, new FormattableMarkup('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_2']])); + $this->assertTrue(!isset($original_settings[$expected['setting_name']]), "Page originally lacks the {$expected['setting_name']}, as expected."); + $this->assertNotContains($expected['library_1'], $original_libraries, "Page originally lacks the {$expected['library_1']} library, as expected."); + $this->assertNotContains($expected['library_2'], $original_libraries, "Page originally lacks the {$expected['library_2']} library, as expected."); // Submit the AJAX request without triggering files getting added. $page->pressButton('Submit'); @@ -54,9 +53,9 @@ public function testLazyLoad() { $new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']); // Verify the setting was not added when not expected. - $this->assertTrue(!isset($new_settings[$expected['setting_name']]), new FormattableMarkup('Page still lacks the %setting, as expected.', ['%setting' => $expected['setting_name']])); - $this->assertNotContains($expected['library_1'], $new_libraries, new FormattableMarkup('Page still lacks the %library library, as expected.', ['%library' => $expected['library_1']])); - $this->assertNotContains($expected['library_2'], $new_libraries, new FormattableMarkup('Page still lacks the %library library, as expected.', ['%library' => $expected['library_2']])); + $this->assertTrue(!isset($new_settings[$expected['setting_name']]), "Page still lacks the {$expected['setting_name']}, as expected."); + $this->assertNotContains($expected['library_1'], $new_libraries, "Page still lacks the {$expected['library_1']} library, as expected."); + $this->assertNotContains($expected['library_2'], $new_libraries, "Page still lacks the {$expected['library_2']} library, as expected."); // Submit the AJAX request and trigger adding files. $page->checkField('add_files'); @@ -67,11 +66,11 @@ public function testLazyLoad() { // Verify the expected setting was added, both to drupalSettings, and as // the first AJAX command. - $this->assertSame($expected['setting_value'], $new_settings[$expected['setting_name']], new FormattableMarkup('Page now has the %setting.', ['%setting' => $expected['setting_name']])); + $this->assertSame($expected['setting_value'], $new_settings[$expected['setting_name']], "Page now has the {$expected['setting_name']}."); // Verify the expected CSS file was added, both to drupalSettings, and as // the second AJAX command for inclusion into the HTML. - $this->assertContains($expected['library_1'], $new_libraries, new FormattableMarkup('Page state now has the %library library.', ['%library' => $expected['library_1']])); + $this->assertContains($expected['library_1'], $new_libraries, "Page state now has the {$expected['library_1']} library."); // Verify the expected JS file was added, both to drupalSettings, and as // the third AJAX command for inclusion into the HTML. By testing for an @@ -79,7 +78,7 @@ public function testLazyLoad() { // unexpected JavaScript code, such as a jQuery.extend() that would // potentially clobber rather than properly merge settings, didn't // accidentally get added. - $this->assertContains($expected['library_2'], $new_libraries, new FormattableMarkup('Page state now has the %library library.', ['%library' => $expected['library_2']])); + $this->assertContains($expected['library_2'], $new_libraries, "Page state now has the {$expected['library_2']} library."); } /** diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php index 6663a276665324a2ec5f4303beb078a08f6229be..9e3a21977e715a6113709510b933f48a16e3972c 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -52,10 +52,10 @@ public function testOffCanvasLinks($theme) { // Make sure tray updates to new content. // Check the first link again to make sure the empty title class is // removed. - foreach (['1', '2', '1'] as $link_index) { + foreach ([1, 2, 1] as $link_index) { $this->assertOffCanvasDialog($link_index, 'side'); $header_text = $this->getOffCanvasDialog()->find('css', '.ui-dialog-title')->getText(); - if ($link_index == '2') { + if ($link_index === 2) { // Check no title behavior. $web_assert->elementExists('css', '.ui-dialog-empty-title'); $this->assertEquals(' ', $header_text); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php index 42701e8fcd48ac47b104b2095f10174d78ddb7f9..00523326621961a7eca02d80c0d3c7a56892f295 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php @@ -3,7 +3,6 @@ namespace Drupal\FunctionalJavascriptTests\Ajax; use Drupal\ajax_test\Controller\AjaxTestController; -use Drupal\Component\Render\FormattableMarkup; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** @@ -72,7 +71,7 @@ public function testDialog() { $dialog = $this->assertSession()->waitForElementVisible('css', 'div.ui-dialog'); $this->assertNotNull($dialog, 'Link was used to open a dialog ( non-modal, with options )'); $style = $dialog->getAttribute('style'); - $this->assertStringContainsString('width: 400px;', $style, new FormattableMarkup('Modal respected the dialog-options width parameter. Style = style', ['%style' => $style])); + $this->assertStringContainsString('width: 400px;', $style, "Modal respected the dialog-options width parameter. Style = $style"); // Reset: Return to the dialog links page. $this->drupalGet('ajax-test/dialog'); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php b/core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php index 9288ddaf7288895a5196d7eadfc1bf20e36e5840..8609cabc8fa06a72d3ca5d9dd9ac14e27b997d3a 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php @@ -163,11 +163,11 @@ public function testKeyboardAccessibility() { */ protected function assertKeyboardAccessibility(string $drupal_path = 'tabledrag_test', ?array $structure = NULL): void { $expected_table = $structure ?: [ - ['id' => 1, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], - ['id' => 2, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], - ['id' => 3, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], - ['id' => 4, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], - ['id' => 5, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '1', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '2', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '3', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '4', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '5', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], ]; if (!empty($drupal_path)) { $this->state->set('tabledrag_test_table', array_flip(range(1, 5))); @@ -177,45 +177,45 @@ protected function assertKeyboardAccessibility(string $drupal_path = 'tabledrag_ // Nest the row with id 2 as child of row 1. $this->moveRowWithKeyboard($this->findRowById(2), 'right'); - $expected_table[1] = ['id' => 2, 'weight' => -10, 'parent' => 1, 'indentation' => 1, 'changed' => TRUE]; + $expected_table[1] = ['id' => '2', 'weight' => -10, 'parent' => '1', 'indentation' => 1, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // Nest the row with id 3 as child of row 1. $this->moveRowWithKeyboard($this->findRowById(3), 'right'); - $expected_table[2] = ['id' => 3, 'weight' => -9, 'parent' => 1, 'indentation' => 1, 'changed' => TRUE]; + $expected_table[2] = ['id' => '3', 'weight' => -9, 'parent' => '1', 'indentation' => 1, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // Nest the row with id 3 as child of row 2. $this->moveRowWithKeyboard($this->findRowById(3), 'right'); - $expected_table[2] = ['id' => 3, 'weight' => -10, 'parent' => 2, 'indentation' => 2, 'changed' => TRUE]; + $expected_table[2] = ['id' => '3', 'weight' => -10, 'parent' => '2', 'indentation' => 2, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // Nesting should be allowed to maximum level 2. $this->moveRowWithKeyboard($this->findRowById(4), 'right', 4); - $expected_table[3] = ['id' => 4, 'weight' => -9, 'parent' => 2, 'indentation' => 2, 'changed' => TRUE]; + $expected_table[3] = ['id' => '4', 'weight' => -9, 'parent' => '2', 'indentation' => 2, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // Re-order children of row 1. $this->moveRowWithKeyboard($this->findRowById(4), 'up'); - $expected_table[2] = ['id' => 4, 'weight' => -10, 'parent' => 2, 'indentation' => 2, 'changed' => TRUE]; - $expected_table[3] = ['id' => 3, 'weight' => -9, 'parent' => 2, 'indentation' => 2, 'changed' => TRUE]; + $expected_table[2] = ['id' => '4', 'weight' => -10, 'parent' => '2', 'indentation' => 2, 'changed' => TRUE]; + $expected_table[3] = ['id' => '3', 'weight' => -9, 'parent' => '2', 'indentation' => 2, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // Move back the row 3 to the 1st level. $this->moveRowWithKeyboard($this->findRowById(3), 'left'); - $expected_table[3] = ['id' => 3, 'weight' => -9, 'parent' => 1, 'indentation' => 1, 'changed' => TRUE]; + $expected_table[3] = ['id' => '3', 'weight' => -9, 'parent' => '1', 'indentation' => 1, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); $this->moveRowWithKeyboard($this->findRowById(3), 'left'); - $expected_table[0] = ['id' => 1, 'weight' => -10, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; - $expected_table[3] = ['id' => 3, 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; - $expected_table[4] = ['id' => 5, 'weight' => -8, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; + $expected_table[0] = ['id' => '1', 'weight' => -10, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; + $expected_table[3] = ['id' => '3', 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; + $expected_table[4] = ['id' => '5', 'weight' => -8, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; $this->assertDraggableTable($expected_table); // Move row 3 to the last position. $this->moveRowWithKeyboard($this->findRowById(3), 'down'); - $expected_table[3] = ['id' => 5, 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; - $expected_table[4] = ['id' => 3, 'weight' => -8, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; + $expected_table[3] = ['id' => '5', 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; + $expected_table[4] = ['id' => '3', 'weight' => -8, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // Nothing happens when trying to move the last row further down. @@ -224,7 +224,7 @@ protected function assertKeyboardAccessibility(string $drupal_path = 'tabledrag_ // Nest row 3 under 5. The max depth allowed should be 1. $this->moveRowWithKeyboard($this->findRowById(3), 'right', 3); - $expected_table[4] = ['id' => 3, 'weight' => -10, 'parent' => 5, 'indentation' => 1, 'changed' => TRUE]; + $expected_table[4] = ['id' => '3', 'weight' => -10, 'parent' => '5', 'indentation' => 1, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); // The first row of the table cannot be nested. @@ -235,11 +235,11 @@ protected function assertKeyboardAccessibility(string $drupal_path = 'tabledrag_ // with nesting preserved. Swap the order of the top-level rows by moving // row 1 to after row 3. $this->moveRowWithKeyboard($this->findRowById(1), 'down', 2); - $expected_table[0] = ['id' => 5, 'weight' => -10, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; + $expected_table[0] = ['id' => '5', 'weight' => -10, 'parent' => '', 'indentation' => 0, 'changed' => FALSE]; $expected_table[3] = $expected_table[1]; $expected_table[1] = $expected_table[4]; $expected_table[4] = $expected_table[2]; - $expected_table[2] = ['id' => 1, 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; + $expected_table[2] = ['id' => '1', 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); } @@ -257,11 +257,11 @@ public function testRootLeafDraggableRowsWithKeyboard() { $this->drupalGet('tabledrag_test'); $expected_table = [ - ['id' => 1, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], - ['id' => 2, 'weight' => 0, 'parent' => 1, 'indentation' => 1, 'changed' => FALSE], - ['id' => 3, 'weight' => 0, 'parent' => 1, 'indentation' => 1, 'changed' => FALSE], - ['id' => 4, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], - ['id' => 5, 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '1', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '2', 'weight' => 0, 'parent' => '1', 'indentation' => 1, 'changed' => FALSE], + ['id' => '3', 'weight' => 0, 'parent' => '1', 'indentation' => 1, 'changed' => FALSE], + ['id' => '4', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], + ['id' => '5', 'weight' => 0, 'parent' => '', 'indentation' => 0, 'changed' => FALSE], ]; $this->assertDraggableTable($expected_table); @@ -278,9 +278,9 @@ public function testRootLeafDraggableRowsWithKeyboard() { $this->moveRowWithKeyboard($this->findRowById(2), 'down'); $this->moveRowWithKeyboard($this->findRowById(2), 'left'); $expected_table[0]['weight'] = -10; - $expected_table[1]['id'] = 3; + $expected_table[1]['id'] = '3'; $expected_table[1]['weight'] = -10; - $expected_table[2] = ['id' => 2, 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; + $expected_table[2] = ['id' => '2', 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE]; $expected_table[3]['weight'] = -8; $expected_table[4]['weight'] = -7; $this->assertDraggableTable($expected_table); @@ -288,8 +288,8 @@ public function testRootLeafDraggableRowsWithKeyboard() { // Root rows can have children. $this->moveRowWithKeyboard($this->findRowById(4), 'down'); $this->moveRowWithKeyboard($this->findRowById(4), 'right'); - $expected_table[3]['id'] = 5; - $expected_table[4] = ['id' => 4, 'weight' => -10, 'parent' => 5, 'indentation' => 1, 'changed' => TRUE]; + $expected_table[3]['id'] = '5'; + $expected_table[4] = ['id' => '4', 'weight' => -10, 'parent' => '5', 'indentation' => 1, 'changed' => TRUE]; $this->assertDraggableTable($expected_table); } @@ -437,37 +437,37 @@ public function testNestedDraggableTables() { // Re-test the nested draggable table. $expected_child_table_structure = [ [ - 'id' => 5, + 'id' => '5', 'weight' => -10, 'parent' => '', 'indentation' => 0, 'changed' => FALSE, ], [ - 'id' => 3, + 'id' => '3', 'weight' => -10, - 'parent' => 5, + 'parent' => '5', 'indentation' => 1, 'changed' => TRUE, ], [ - 'id' => 1, + 'id' => '1', 'weight' => -9, 'parent' => '', 'indentation' => 0, 'changed' => TRUE, ], [ - 'id' => 2, + 'id' => '2', 'weight' => -10, - 'parent' => 1, + 'parent' => '1', 'indentation' => 1, 'changed' => TRUE, ], [ - 'id' => 4, + 'id' => '4', 'weight' => -10, - 'parent' => 2, + 'parent' => '2', 'indentation' => 2, 'changed' => TRUE, ],