Skip to content
Snippets Groups Projects
Verified Commit 6496b03d authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2827014 by michielnugter, Lendude, marcoscano, dawehner, cilefen,...

Issue #2827014 by michielnugter, Lendude, marcoscano, dawehner, cilefen, larowlan, xjm, droplet, alexpott, Wim Leers: Throw an exception when testing status code or response headers in functional JavaScript tests
parent 401bd662
No related branches found
No related tags found
No related merge requests found
......@@ -123,7 +123,6 @@ public function doTestCreateMediaType($media_type_id, $source_id, array $provide
// Save the form to create the type.
$page->pressButton('Save');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('The media type ' . $media_type_id . ' has been added.');
$this->drupalGet('admin/structure/media');
$assert_session->pageTextContains($media_type_id);
......
......@@ -54,7 +54,6 @@ public function testMediaTypes() {
$assert_session = $this->assertSession();
$this->drupalGet('admin/structure/media');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No media types available. Add media type.');
$assert_session->linkExists('Add media type');
......@@ -69,10 +68,8 @@ public function testMediaTypes() {
$this->assertJsCondition("jQuery('.form-item-source-configuration-test-config-value').length > 0;");
$page->fillField('description', $description);
$page->pressButton('Save');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('The media type ' . $name . ' has been added.');
$this->drupalGet('admin/structure/media');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains($name);
$assert_session->pageTextContains($description);
......@@ -142,7 +139,7 @@ public function testMediaTypes() {
$page->uncheckField('options[status]');
$page->checkField('options[queue_thumbnail_downloads]');
$page->pressButton('Save');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains("The media type $new_name has been updated.");
// Test if edit worked and if new field values have been saved as expected.
$this->drupalGet('admin/structure/media/manage/' . $this->testMediaType->id());
......
......@@ -48,13 +48,10 @@ public function testSessionExpiration() {
// number of times.
$this->drupalGet('<front>');
$session_assert = $this->assertSession();
$page = $this->getSession()->getPage();
for ($i = 0; $i < 25; $i++) {
$page->clickLink('Link to front page');
$session_assert->statusCodeEquals(200);
}
}
......
......@@ -7,7 +7,7 @@
use Zumba\Mink\Driver\PhantomJSDriver;
/**
* Runs a browser test using PhantomJS.
* Runs a browser test using a driver that supports Javascript.
*
* Base class for testing browser interaction implemented in JavaScript.
*/
......@@ -142,7 +142,7 @@ protected function createScreenshot($filename, $set_background_color = TRUE) {
* {@inheritdoc}
*/
public function assertSession($name = NULL) {
return new JSWebAssert($this->getSession($name), $this->baseUrl);
return new WebDriverWebAssert($this->getSession($name), $this->baseUrl);
}
/**
......
<?php
namespace Drupal\FunctionalJavascriptTests;
/**
* Runs a browser test using PhantomJS.
*
* Base class for testing browser interaction implemented in JavaScript.
*/
abstract class LegacyJavascriptTestBase extends JavascriptTestBase {
/**
* {@inheritdoc}
*/
public function assertSession($name = NULL) {
// Return a WebAssert that supports status code and header assertions.
return new JSWebAssert($this->getSession($name), $this->baseUrl);
}
}
<?php
namespace Drupal\FunctionalJavascriptTests;
/**
* Defines a JSWebAssert with no support for status code and header assertions.
*/
class WebDriverWebAssert extends JSWebAssert {
/**
* The use of statusCodeEquals() is not available.
*
* @param int $code
* The status code.
*/
public function statusCodeEquals($code) {
@trigger_error('Support for statusCodeEquals is to be dropped from Javascript tests. See https://www.drupal.org/node/2857562.');
parent::statusCodeEquals($code);
}
/**
* The use of statusCodeNotEquals() is not available.
*
* @param int $code
* The status code.
*/
public function statusCodeNotEquals($code) {
@trigger_error('Support for statusCodeNotEquals is to be dropped from Javascript tests. See https://www.drupal.org/node/2857562.');
parent::statusCodeNotEquals($code);
}
/**
* The use of responseHeaderEquals() is not available.
*
* @param string $name
* The name of the header.
* @param string $value
* The value to check the header against.
*/
public function responseHeaderEquals($name, $value) {
@trigger_error('Support for responseHeaderEquals is to be dropped from Javascript tests. See https://www.drupal.org/node/2857562.');
parent::responseHeaderEquals($name, $value);
}
/**
* The use of responseHeaderNotEquals() is not available.
*
* @param string $name
* The name of the header.
* @param string $value
* The value to check the header against.
*/
public function responseHeaderNotEquals($name, $value) {
@trigger_error('Support for responseHeaderNotEquals is to be dropped from Javascript tests. See https://www.drupal.org/node/2857562.');
parent::responseHeaderNotEquals($name, $value);
}
}
......@@ -736,7 +736,6 @@ protected function drupalLogin(AccountInterface $account) {
}
$this->drupalGet('user/login');
$this->assertSession()->statusCodeEquals(200);
$this->submitForm([
'name' => $account->getUsername(),
'pass' => $account->passRaw,
......@@ -761,7 +760,6 @@ protected function drupalLogout() {
// screen.
$assert_session = $this->assertSession();
$this->drupalGet('user/logout', ['query' => ['destination' => 'user']]);
$assert_session->statusCodeEquals(200);
$assert_session->fieldExists('name');
$assert_session->fieldExists('pass');
......
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