#2232861: Create BrowserTestBase for web-testing on top of Mink just landed let's use the brand new BrowserTestBase to extend DynamicEntityReferenceTest instead of WebTestBase.

CommentFileSizeAuthor
#41 convert_all_webtestbase-2469609-41.patch15.31 KBjibran
#41 interdiff.txt2.38 KBjibran
#39 convert_all_webtestbase-2469609-39.patch15.34 KBjibran
#39 interdiff.txt2.75 KBjibran
#35 convert_all_webtestbase-2469609-34.patch13.78 KBjibran
#29 convert-2469609-29.patch19.98 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 366 pass(es), 3 fail(s), and 0 exception(s). View
#26 convert-2469609-19-pass.patch19.99 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
#26 convert-2469609-19-fail.patch19.98 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
#19 convert-2469609-19-pass.patch19.99 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
#19 convert-2469609-19-fail.patch19.98 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
#16 convert-2469609-16-pass.patch19.99 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
#16 convert-2469609-16-fail.patch19.98 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
#3 convert-2469609-3-fail.patch19.97 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch convert-2469609-3-fail.patch. Unable to apply patch. See the log in the details link for more information. View
#3 convert-2469609-3.patch19.97 KBjibran
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch convert-2469609-3.patch. Unable to apply patch. See the log in the details link for more information. View
#3 interdiff.txt10.49 KBjibran
#1 convert-2469609-1.patch16.19 KBjibran
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 223 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

jibran’s picture

Status: Active » Needs review
FileSize
16.19 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 223 pass(es). View

Let's try this.

larowlan’s picture

  1. rename from src/Tests/DynamicEntityReferenceTest.php
    rename to tests/src/Functional/DynamicEntityReferenceTest.php
    

    Should there be a namespace update here too?

  2. +++ b/tests/src/Functional/DynamicEntityReferenceTest.php
    @@ -13,7 +13,7 @@ use Drupal\Core\Language\LanguageInterface;
    +use Drupal\simpletest\BrowserTestBase;
    
    @@ -22,8 +22,11 @@ use Symfony\Component\CssSelector\CssSelector;
    + * @preserveGlobalState disabled
    
    @@ -76,14 +79,14 @@ class DynamicEntityReferenceTest extends WebTestBase {
    +//    $this->assertSession()->fieldExistsByXPath(CssSelector::toXPath('select[name="default_value_input[field_foobar][0][target_type]"] > option[value=entity_test]'), 'entity_test');
    +//    $this->assertNoFieldByXPath(CssSelector::toXPath('select[name="default_value_input[field_foobar][0][target_type]"] > option[value=user]'), 'user');
    
    @@ -105,38 +108,38 @@ class DynamicEntityReferenceTest extends WebTestBase {
    +//    $this->assertSession()->fieldExistsByXPath(CssSelector::toXPath('select[name="default_value_input[field_foobar][0][target_type]"] > option[value=user]'), 'user');
    +//    $this->assertNoFieldByXPath(CssSelector::toXPath('select[name="default_value_input[field_foobar][0][target_type]"] > option[value=entity_test]'), 'entity_test');
    

    Still commented out?

jibran’s picture

FileSize
10.49 KB
19.97 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch convert-2469609-3.patch. Unable to apply patch. See the log in the details link for more information. View
19.97 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch convert-2469609-3-fail.patch. Unable to apply patch. See the log in the details link for more information. View
+//    $this->assertSame(count($entity->field_foobar), 3, 'Three items in field');
+//    $this->assertSame($entity->field_foobar[0]->entity->label(), $this->adminUser->label());
+//    $this->assertSame($entity->field_foobar[1]->entity->label(), 'tag');
+//    $this->assertSame($entity->field_foobar[2]->entity->label(), $term->label());

This fails locally. Perhaps, it has something to do with BTB.

jibran’s picture

I think we can improve conversion documentation. Here are some suggestions.

  1. +++ b/tests/src/Functional/DynamicEntityReferenceTest.php
    @@ -78,14 +80,14 @@ class DynamicEntityReferenceTest extends WebTestBase {
    -    $this->assertFieldByXPath(CssSelector::toXPath('select[name="default_value_input[field_foobar][0][target_type]"] > option[value=entity_test]'), 'entity_test');
    ...
    +    $this->assertSession()->elementTextContains('css', 'select[name="default_value_input[field_foobar][0][target_type]"] > option[value=entity_test]', 'Test entity');
    

    We can add this to https://www.drupal.org/node/2469723

  2. +++ b/tests/src/Functional/DynamicEntityReferenceTest.php
    @@ -78,14 +80,14 @@ class DynamicEntityReferenceTest extends WebTestBase {
    -    $this->assertNoFieldByXPath(CssSelector::toXPath('select[name="default_value_input[field_foobar][0][target_type]"] > option[value=user]'), 'user');
    ...
    +    $this->assertSession()->elementNotExists('css', 'select[name="default_value_input[field_foobar][0][target_type]"] > option[value=user]');
    

    We can add this to https://www.drupal.org/node/2469723

  3. +++ b/tests/src/Functional/DynamicEntityReferenceTest.php
    @@ -110,38 +112,38 @@ class DynamicEntityReferenceTest extends WebTestBase {
    -    $this->assertRaw(t('Saved %name configuration', array('%name' => 'Foobar')));
    ...
    +    $this->getSession()->getPage()->hasContent(t('Saved %name configuration', array('%name' => 'Foobar')));
    

    We can add this to https://www.drupal.org/node/2469723

  4. +++ b/tests/src/Functional/DynamicEntityReferenceTest.php
    @@ -202,11 +204,12 @@ class DynamicEntityReferenceTest extends WebTestBase {
    -    $input = $this->xpath('//input[@name=:name]', array(':name' => 'field_foobar[0][target_id]'))[0];
    +    $input = $this->getSession()->getPage()->findField('field_foobar[0][target_id]');
    

    Perhaps this can also be added to https://www.drupal.org/node/2469723

  5. +++ b/tests/src/Functional/DynamicEntityReferenceTest.php
    @@ -216,12 +219,11 @@ class DynamicEntityReferenceTest extends WebTestBase {
    -    $this->drupalPostAjaxForm(NULL, array(), array('field_foobar_add_more' => t('Add another item')), 'system/ajax', array(), array(), 'entity-test-entity-test-form');
    ...
    +    $this->getSession()->getPage()->findButton('field_foobar_add_more')->click();
    

    We can add this to https://www.drupal.org/node/2469723

The last submitted patch, 3: convert-2469609-3.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: convert-2469609-3-fail.patch, failed testing.

jibran queued 3: convert-2469609-3.patch for re-testing.

Status: Needs work » Needs review

The last submitted patch, 3: convert-2469609-3.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: convert-2469609-3-fail.patch, failed testing.

jibran’s picture

Status: Needs work » Postponed

jibran queued 3: convert-2469609-3.patch for re-testing.

Status: Postponed » Needs review

The last submitted patch, 3: convert-2469609-3.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: convert-2469609-3-fail.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
FileSize
19.98 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
19.99 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View

Reroll.

The last submitted patch, 16: convert-2469609-16-fail.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 16: convert-2469609-16-pass.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
FileSize
19.98 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
19.99 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View

Let's test on new CI.

The last submitted patch, 19: convert-2469609-19-fail.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 19: convert-2469609-19-pass.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: convert-2469609-19-pass.patch, failed testing.

The last submitted patch, 19: convert-2469609-19-fail.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
FileSize
19.98 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View
19.99 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 226 pass(es), 3 fail(s), and 0 exception(s). View

Re-uploading for Drupal CI.

Status: Needs review » Needs work

The last submitted patch, 26: convert-2469609-19-pass.patch, failed testing.

The last submitted patch, 26: convert-2469609-19-fail.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
FileSize
19.98 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 366 pass(es), 3 fail(s), and 0 exception(s). View

Re-uploading the patch to test #2503547: Contrib can't run Functional tests is fixed or not.

Status: Needs review » Needs work

The last submitted patch, 29: convert-2469609-29.patch, failed testing.

jibran’s picture

Title: Convert DynamicEntityReferenceTest to BrowserTestBase » Convert all WebTestBase to BrowserTestBase

We have four tests now which are extending WebTestBase.

anavarre’s picture

I'm curious: what is blocking this issue, if anything? I don't see BrowserTestBase being used in core except in \Drupal\Tests\simpletest\Functional\BrowserTestBaseTest and can hardly find any contrib module using them. Is there any reason for that, besides awareness?

jibran’s picture

I think you haven't seen #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase). We are making great progress in conversion over there in the child issues.

anavarre’s picture

Excellent, thanks.

jibran’s picture

Status: Needs work » Needs review
FileSize
13.78 KB

Let's start fresh.

Status: Needs review » Needs work

The last submitted patch, 35: convert_all_webtestbase-2469609-34.patch, failed testing.

The last submitted patch, 35: convert_all_webtestbase-2469609-34.patch, failed testing.

The last submitted patch, 35: convert_all_webtestbase-2469609-34.patch, failed testing.

jibran’s picture

Status: Needs review » Needs work

The last submitted patch, 39: convert_all_webtestbase-2469609-39.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
FileSize
2.38 KB
15.31 KB
jibran’s picture

Let's fix the deprecated function calls in follow up.

dawehner’s picture

  1. +++ b/tests/src/Functional/DynamicEntityReferenceBaseTest.php
    @@ -85,7 +85,7 @@ class DynamicEntityReferenceBaseTest extends WebTestBase {
    -    $this->assertTrue(strpos((string) $input['data-autocomplete-path'], $expected_autocomplete_path) !== FALSE);
    +    $this->assertTrue(strpos($input->getAttribute('data-autocomplete-path'), $expected_autocomplete_path) !== FALSE);
    
    @@ -234,10 +234,10 @@ class DynamicEntityReferenceBaseTest extends WebTestBase {
    -    $this->assertTrue(strpos((string) $input['data-autocomplete-path'], $expected_autocomplete_path) !== FALSE);
    +    $this->assertTrue(strpos($input->getAttribute('data-autocomplete-path'), $expected_autocomplete_path) !== FALSE);
    

    You could use $this->assertContains here

  2. +++ b/tests/src/Functional/DynamicEntityReferenceBaseTest.php
    @@ -234,10 +234,10 @@ class DynamicEntityReferenceBaseTest extends WebTestBase {
         // Add some extra dynamic entity reference fields.
    -    $this->drupalPostAjaxForm(NULL, array(), array('dynamic_references_add_more' => t('Add another item')), NULL, array(), array(), 'entity-test-entity-test-form');
    +    $this->getSession()->getPage()->findButton('Add another item')->click();
    

    If this is an ajax form, how does it work without the JavascripTestBase?

  3. +++ b/tests/src/Functional/DynamicEntityReferenceFieldDefaultValueTest.php
    @@ -107,8 +107,8 @@ class DynamicEntityReferenceFieldDefaultValueTest extends WebTestBase {
    +    $this->assertRaw('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')');
    

    there is responseContains

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Feel free to fix those points after commit

jibran’s picture

I'm planning to fix it 1 and 3 in follow up. For 2 we have a JTB already but if you are not using JTB then clicking the button will do the magic. Thanks for the RTBC.

  • jibran committed 56ddf79 on 8.x-1.x
    Issue #2469609 by jibran, dawehner, berdir: Convert all WebTestBase to...
jibran’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x-1.x and created #2751409: Remove the deprecated function calls from tests as follow up.

Status: Fixed » Closed (fixed)

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