Issue #3399754 by mstrelan, smustgrave, xjm: Fix strict type errors in functional JavaScript tests
(cherry picked from commit 35cfa70992
)
merge-requests/5443/head
parent
aa810af52e
commit
d76ca17c9f
|
@ -37,7 +37,7 @@ class CKEditor5OffCanvasTest extends CKEditor5TestBase {
|
|||
$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');
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ class ManageDisplayTest extends WebDriverTestBase {
|
|||
$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 @@ class ManageDisplayTest extends WebDriverTestBase {
|
|||
|
||||
// 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();
|
||||
|
|
|
@ -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 @@ class FileFieldWidgetTest extends WebDriverTestBase {
|
|||
// 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;
|
||||
|
|
|
@ -99,11 +99,11 @@ class MaximumFileSizeExceededUploadTest extends WebDriverTestBase {
|
|||
$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.
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\FunctionalJavascript;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
|
@ -43,9 +42,9 @@ class FrameworkTest extends WebDriverTestBase {
|
|||
|
||||
// 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 @@ class FrameworkTest extends WebDriverTestBase {
|
|||
$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 @@ class FrameworkTest extends WebDriverTestBase {
|
|||
|
||||
// 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 @@ class FrameworkTest extends WebDriverTestBase {
|
|||
// 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.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,10 +52,10 @@ class OffCanvasTest extends OffCanvasTestBase {
|
|||
// 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);
|
||||
|
|
|
@ -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 @@ class DialogTest extends WebDriverTestBase {
|
|||
$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');
|
||||
|
|
|
@ -163,11 +163,11 @@ class TableDragTest extends WebDriverTestBase {
|
|||
*/
|
||||
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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
|
||||
// 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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
|
||||
// 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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
// 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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
|
||||
$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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
$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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
// 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 @@ class TableDragTest extends WebDriverTestBase {
|
|||
// 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,
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue