Skip to content
Snippets Groups Projects
Verified Commit f9d3970b authored by Dave Long's avatar Dave Long
Browse files

Issue #3421258 by mstrelan, acbramley: Fix strict type errors in WebAssert calls

(cherry picked from commit c4e7dd71)
parent e8b89f34
No related branches found
No related tags found
No related merge requests found
...@@ -312,7 +312,7 @@ public function testContentTranslationNodeForm() { ...@@ -312,7 +312,7 @@ public function testContentTranslationNodeForm() {
$french = \Drupal::languageManager()->getLanguage('fr'); $french = \Drupal::languageManager()->getLanguage('fr');
$this->drupalGet($latest_version_path); $this->drupalGet($latest_version_path);
$this->assertSession()->statusCodeEquals('403'); $this->assertSession()->statusCodeEquals(403);
$this->assertSession()->elementNotExists('xpath', '//ul[@class="entity-moderation-form"]'); $this->assertSession()->elementNotExists('xpath', '//ul[@class="entity-moderation-form"]');
// Add french translation (revision 2). // Add french translation (revision 2).
...@@ -326,7 +326,7 @@ public function testContentTranslationNodeForm() { ...@@ -326,7 +326,7 @@ public function testContentTranslationNodeForm() {
], 'Save (this translation)'); ], 'Save (this translation)');
$this->drupalGet($latest_version_path, ['language' => $french]); $this->drupalGet($latest_version_path, ['language' => $french]);
$this->assertSession()->statusCodeEquals('403'); $this->assertSession()->statusCodeEquals(403);
$this->assertSession()->elementNotExists('xpath', '//ul[@class="entity-moderation-form"]'); $this->assertSession()->elementNotExists('xpath', '//ul[@class="entity-moderation-form"]');
// Add french pending revision (revision 3). // Add french pending revision (revision 3).
......
...@@ -341,7 +341,7 @@ protected function assertFilterStates(array $states, bool $check_size = FALSE): ...@@ -341,7 +341,7 @@ protected function assertFilterStates(array $states, bool $check_size = FALSE):
// Check that the size of the select element does not exceed 8 options. // Check that the size of the select element does not exceed 8 options.
if ($check_size) { if ($check_size) {
$this->assertGreaterThan(8, count($states)); $this->assertGreaterThan(8, count($states));
$assert_session->elementAttributeContains('css', '#edit-default-revision-state', 'size', 8); $assert_session->elementAttributeContains('css', '#edit-default-revision-state', 'size', '8');
} }
// Check that an option exists for each of the expected states. // Check that an option exists for each of the expected states.
......
...@@ -160,22 +160,22 @@ public function testExposedGroupedFilters() { ...@@ -160,22 +160,22 @@ public function testExposedGroupedFilters() {
$this->drupalGet($path); $this->drupalGet($path);
// Filter the Preview by 'empty'. // Filter the Preview by 'empty'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption(1); $this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('1');
$this->getSession()->getPage()->pressButton('Apply'); $this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([4]); $this->assertIds([4]);
// Filter the Preview by 'not empty'. // Filter the Preview by 'not empty'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption(2); $this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('2');
$this->getSession()->getPage()->pressButton('Apply'); $this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([1, 2, 3]); $this->assertIds([1, 2, 3]);
// Filter the Preview by 'less than'. // Filter the Preview by 'less than'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption(3); $this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('3');
$this->getSession()->getPage()->pressButton('Apply'); $this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([2, 3]); $this->assertIds([2, 3]);
// Filter the Preview by 'between'. // Filter the Preview by 'between'.
$this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption(4); $this->getSession()->getPage()->findField($this->fieldName . '_value')->selectOption('4');
$this->getSession()->getPage()->pressButton('Apply'); $this->getSession()->getPage()->pressButton('Apply');
$this->assertIds([2]); $this->assertIds([2]);
} }
......
...@@ -182,7 +182,7 @@ protected function assertTwigTransTags(): void { ...@@ -182,7 +182,7 @@ protected function assertTwigTransTags(): void {
// Makes sure https://www.drupal.org/node/2489024 doesn't happen without // Makes sure https://www.drupal.org/node/2489024 doesn't happen without
// twig debug. // twig debug.
// Ensure that running php code inside a Twig trans is not possible. // Ensure that running php code inside a Twig trans is not possible.
$this->assertSession()->pageTextNotContains(pi()); $this->assertSession()->pageTextNotContains((string) pi());
} }
/** /**
......
...@@ -91,7 +91,7 @@ protected function setUp(): void { ...@@ -91,7 +91,7 @@ protected function setUp(): void {
public function testTelephoneWidget() { public function testTelephoneWidget() {
$this->drupalGet('node/add/article'); $this->drupalGet('node/add/article');
$this->assertSession()->fieldValueEquals("field_telephone[0][value]", ''); $this->assertSession()->fieldValueEquals("field_telephone[0][value]", '');
$this->assertSession()->elementAttributeContains('css', 'input[name="field_telephone[0][value]"]', 'maxlength', TelephoneItem::MAX_LENGTH); $this->assertSession()->elementAttributeContains('css', 'input[name="field_telephone[0][value]"]', 'maxlength', (string) TelephoneItem::MAX_LENGTH);
$this->assertSession()->responseContains('placeholder="123-456-7890"'); $this->assertSession()->responseContains('placeholder="123-456-7890"');
} }
......
...@@ -121,8 +121,8 @@ public function testMajorUpdateAvailable() { ...@@ -121,8 +121,8 @@ public function testMajorUpdateAvailable() {
$this->refreshUpdateStatus([$this->updateProject => '9']); $this->refreshUpdateStatus([$this->updateProject => '9']);
$this->standardTests(); $this->standardTests();
$this->assertUpdateTableTextNotContains('Security update required!'); $this->assertUpdateTableTextNotContains('Security update required!');
$this->assertUpdateTableElementContains(Link::fromTextAndUrl('9.0.0', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))->toString()); $this->assertUpdateTableElementContains((string) Link::fromTextAndUrl('9.0.0', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))->toString());
$this->assertUpdateTableElementContains(Link::fromTextAndUrl('Release notes', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))->toString()); $this->assertUpdateTableElementContains((string) Link::fromTextAndUrl('Release notes', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))->toString());
$this->assertUpdateTableTextNotContains('Up to date'); $this->assertUpdateTableTextNotContains('Up to date');
$this->assertUpdateTableTextContains('Not supported!'); $this->assertUpdateTableTextContains('Not supported!');
$this->assertUpdateTableTextContains('Recommended version:'); $this->assertUpdateTableTextContains('Recommended version:');
......
...@@ -174,10 +174,10 @@ public function testEditNodesByAdmin() { ...@@ -174,10 +174,10 @@ public function testEditNodesByAdmin() {
->loadByProperties(['title' => 'Deep mediterranean quiche']); ->loadByProperties(['title' => 'Deep mediterranean quiche']);
$node = reset($nodes); $node = reset($nodes);
$this->drupalGet($node->toUrl('edit-form')); $this->drupalGet($node->toUrl('edit-form'));
$webassert->statusCodeEquals('200'); $webassert->statusCodeEquals(200);
$this->submitForm([], 'Preview'); $this->submitForm([], 'Preview');
$webassert->statusCodeEquals('200'); $webassert->statusCodeEquals(200);
$this->assertSession()->elementsCount('css', 'h1', 1); $this->assertSession()->elementsCount('css', 'h1', 1);
$this->clickLink('Back to content editing'); $this->clickLink('Back to content editing');
...@@ -221,27 +221,27 @@ protected function testDemonstrationWarningMessage() { ...@@ -221,27 +221,27 @@ protected function testDemonstrationWarningMessage() {
// Check when editing a node, the warning is visible. // Check when editing a node, the warning is visible.
$this->drupalGet($recipe_node->toUrl('edit-form')); $this->drupalGet($recipe_node->toUrl('edit-form'));
$web_assert->statusCodeEquals('200'); $web_assert->statusCodeEquals(200);
$web_assert->pageTextContains('This site is intended for demonstration purposes.'); $web_assert->pageTextContains('This site is intended for demonstration purposes.');
// Check when adding a node, the warning is visible. // Check when adding a node, the warning is visible.
$this->drupalGet('node/add/recipe'); $this->drupalGet('node/add/recipe');
$web_assert->statusCodeEquals('200'); $web_assert->statusCodeEquals(200);
$web_assert->pageTextContains('This site is intended for demonstration purposes.'); $web_assert->pageTextContains('This site is intended for demonstration purposes.');
// Check when looking at admin/content, the warning is visible. // Check when looking at admin/content, the warning is visible.
$this->drupalGet('admin/content'); $this->drupalGet('admin/content');
$web_assert->statusCodeEquals('200'); $web_assert->statusCodeEquals(200);
$web_assert->pageTextContains('This site is intended for demonstration purposes.'); $web_assert->pageTextContains('This site is intended for demonstration purposes.');
// Check when viewing a node, the warning is not visible. // Check when viewing a node, the warning is not visible.
$this->drupalGet($recipe_node->toUrl()); $this->drupalGet($recipe_node->toUrl());
$web_assert->statusCodeEquals('200'); $web_assert->statusCodeEquals(200);
$web_assert->pageTextNotContains('This site is intended for demonstration purposes.'); $web_assert->pageTextNotContains('This site is intended for demonstration purposes.');
// Check when viewing the homepage, the warning is not visible. // Check when viewing the homepage, the warning is not visible.
$this->drupalGet('<front>'); $this->drupalGet('<front>');
$web_assert->statusCodeEquals('200'); $web_assert->statusCodeEquals(200);
$web_assert->pageTextNotContains('This site is intended for demonstration purposes.'); $web_assert->pageTextNotContains('This site is intended for demonstration purposes.');
} }
......
...@@ -359,13 +359,13 @@ public function testFieldAssertsForCheckbox() { ...@@ -359,13 +359,13 @@ public function testFieldAssertsForCheckbox() {
// Part 1 - Test by name. // Part 1 - Test by name.
// Test that checkboxes are found/not found correctly by name, when using // Test that checkboxes are found/not found correctly by name, when using
// TRUE or FALSE to match their 'checked' state. // '1' or '' to match their 'checked' state.
$this->assertSession()->fieldExists('checkbox_enabled'); $this->assertSession()->fieldExists('checkbox_enabled');
$this->assertSession()->fieldExists('checkbox_disabled'); $this->assertSession()->fieldExists('checkbox_disabled');
$this->assertSession()->fieldValueEquals('checkbox_enabled', TRUE); $this->assertSession()->fieldValueEquals('checkbox_enabled', '1');
$this->assertSession()->fieldValueEquals('checkbox_disabled', FALSE); $this->assertSession()->fieldValueEquals('checkbox_disabled', '');
$this->assertSession()->fieldValueNotEquals('checkbox_enabled', FALSE); $this->assertSession()->fieldValueNotEquals('checkbox_enabled', '');
$this->assertSession()->fieldValueNotEquals('checkbox_disabled', TRUE); $this->assertSession()->fieldValueNotEquals('checkbox_disabled', '1');
// Test that we have legacy support. // Test that we have legacy support.
$this->assertSession()->fieldValueEquals('checkbox_enabled', '1'); $this->assertSession()->fieldValueEquals('checkbox_enabled', '1');
...@@ -373,7 +373,7 @@ public function testFieldAssertsForCheckbox() { ...@@ -373,7 +373,7 @@ public function testFieldAssertsForCheckbox() {
// Test that the assertion fails correctly if given the right value. // Test that the assertion fails correctly if given the right value.
try { try {
$this->assertSession()->fieldValueNotEquals('checkbox_enabled', TRUE); $this->assertSession()->fieldValueNotEquals('checkbox_enabled', '1');
$this->fail('fieldValueNotEquals failed to throw an exception.'); $this->fail('fieldValueNotEquals failed to throw an exception.');
} }
catch (ExpectationException $e) { catch (ExpectationException $e) {
...@@ -382,11 +382,11 @@ public function testFieldAssertsForCheckbox() { ...@@ -382,11 +382,11 @@ public function testFieldAssertsForCheckbox() {
// Part 2 - Test by ID. // Part 2 - Test by ID.
// Test that checkboxes are found/not found correctly by ID, when using // Test that checkboxes are found/not found correctly by ID, when using
// TRUE or FALSE to match their 'checked' state. // '1' or '' to match their 'checked' state.
$this->assertSession()->fieldValueEquals('edit-checkbox-enabled', TRUE); $this->assertSession()->fieldValueEquals('edit-checkbox-enabled', '1');
$this->assertSession()->fieldValueEquals('edit-checkbox-disabled', FALSE); $this->assertSession()->fieldValueEquals('edit-checkbox-disabled', '');
$this->assertSession()->fieldValueNotEquals('edit-checkbox-enabled', FALSE); $this->assertSession()->fieldValueNotEquals('edit-checkbox-enabled', '');
$this->assertSession()->fieldValueNotEquals('edit-checkbox-disabled', TRUE); $this->assertSession()->fieldValueNotEquals('edit-checkbox-disabled', '1');
// Test that checkboxes are found by ID, when using NULL to ignore the // Test that checkboxes are found by ID, when using NULL to ignore the
// 'checked' state. // 'checked' state.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment