See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)

Postponed on

Needs partial conversion to JavaScriptTestBase: #2809481: Convert AJAX part of \Drupal\editor\Tests\EditorAdminTest to JavascriptTestBase

Tests do be converted:

\Drupal\editor\Tests\EditorLoadingTest
\Drupal\editor\Tests\EditorSecurityTest
\Drupal\editor\Tests\EditorUploadImageScaleTest
\Drupal\editor\Tests\QuickEditIntegrationLoadingTest
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michielnugter created an issue. See original summary.

michielnugter’s picture

Issue summary: View changes
Status: Active » Postponed
michielnugter’s picture

dawehner’s picture

Issue summary: View changes
Status: Postponed » Active
michielnugter’s picture

Component: phpunit » editor.module
Issue tags: +phpunit initiative

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

claudiu.cristea’s picture

Status: Active » Postponed
Related issues: +#2795041: BrowserTestBase: Add drupalPostWithFormat

This is blocked on #2795041: BrowserTestBase: Add drupalPostWithFormat because of EditorSecurityTest test.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nlisgo’s picture

Status: Postponed » Active

Since #2795041: BrowserTestBase: Add drupalPostWithFormat is closed (won't fix) I am switching this back to active.

Lendude’s picture

Status: Active » Needs review
FileSize
10.63 KB

first roll, just moving stuff around and fixing node element stuff.

This will fail on the ajaxy stuff.

Status: Needs review » Needs work

The last submitted patch, 11: 2870443-11.patch, failed testing. View results

Lendude’s picture

and now rolled against 8.6.x

Lendude’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 13: 2870443-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Tess Bakker’s picture

Assigned: Unassigned » Tess Bakker
Tess Bakker’s picture

Status: Needs work » Needs review
FileSize
22.23 KB
14.91 KB

New patch with changes to work with BrowserTestBase.

Done:
* Fixed all the "ajax/post" calls
* replaced t() with FormattableMarkup() when needed
* few other minor changes

Tess Bakker’s picture

Assigned: Tess Bakker » Unassigned
Tess Bakker’s picture

Issue tags: +DevDaysLisbon
Lendude’s picture

Status: Needs review » Needs work

@Tessa Bakker this is looking really good already, just some nits:

  1. +++ b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
    @@ -1,18 +1,21 @@
    +use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
    

    unused use

  2. +++ b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
    @@ -1,18 +1,21 @@
    +use GuzzleHttp\Exception\ClientException;
    

    unused use

  3. +++ b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
    @@ -108,13 +124,30 @@ public function testUserWithPermission() {
    +  protected function getCookies() {
    

    this needs a docblock

  4. +++ b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
    @@ -389,13 +390,18 @@ public function testSwitchingSecurity() {
    +    $domain = parse_url($this->getUrl(), PHP_URL_HOST);
    +    $session_id = $this->getSession()->getCookie($this->getSessionName());
    +    $cookies = CookieJar::fromArray([$this->getSessionName() => $session_id], $domain);
    
    +++ b/core/modules/editor/tests/src/Functional/QuickEditIntegrationLoadingTest.php
    @@ -108,13 +124,30 @@ public function testUserWithPermission() {
    +      'cookies' => $this->getCookies(),
    

    two tests with two different ways of setting the needed cookies, can we do this in one consistent way?

Tess Bakker’s picture

Status: Needs work » Needs review
FileSize
22.49 KB
2.49 KB

Thanks for the review!

dawehner’s picture

This looks great!

  1. +++ b/core/modules/editor/tests/src/Functional/EditorAdminTest.php
    @@ -64,8 +65,8 @@ public function testNoEditorAvailable() {
    -    $this->assertTrue(((string) $options[0]) === 'None', 'Option 1 in the Text Editor select is "None".');
    ...
    +    $this->assertTrue(($options[0]->getText()) === 'None', 'Option 1 in the Text Editor select is "None".');
    

    This is already so much nicer!

  2. +++ b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
    @@ -433,7 +448,21 @@ public function testEditorXssFilterOverride() {
    +  /**
    +   * Get session cookies from current session.
    +   *
    +   * @return \GuzzleHttp\Cookie\CookieJar
    +   *   A cookie jar with the current session.
    +   */
    +  protected function getCookies() {
    +    $domain = parse_url($this->getUrl(), PHP_URL_HOST);
    +    $session_id = $this->getSession()->getCookie($this->getSessionName());
    +    $cookies = CookieJar::fromArray([$this->getSessionName() => $session_id], $domain);
    +
    +    return $cookies;
       }
    

    Should we create a follow up to make this process easier for people? Maybe it would it be worth to moving this to BrowserTestBase?

Lendude’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Crediting reviewers and @michielnugter for the original issue creation / management.

Committed 0b8ffb4 and pushed to 8.6.x. Thanks!

  • alexpott committed 0b8ffb4 on 8.6.x
    Issue #2870443 by Tessa Bakker, Lendude, michielnugter, dawehner:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.