Problem/Motivation
The following PHPUnit tests in the Options module extend a Simpletest base class (\Drupal\field\Tests\FieldTestBase
):
\Drupal\Tests\options\Functional\OptionsDynamicValuesTestBase
\Drupal\Tests\options\Functional\OptionsFieldUITest
\Drupal\Tests\options\Functional\OptionsFloatFieldImportTest
\Drupal\Tests\options\FunctionalOptionsWidgetsTest
According to the instructions at #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase), these tests should extend the new version \Drupal\Tests\field\Functional\FieldTestBase
:
Any TestBase or Trait which is in the old /src/Tests/ location should remain there and be deprecated. Copy the TestBase or Trait file into the new location and alter the tests to use the new version. The deprecated class must not "use" the newly-moved class, but remain exactly as it is. Create a change record for the deprecation notice - one CR can cover all deprecations within a module.
Proposed resolution
Update the tests to extend the PHPUnit based \Drupal\Tests\field\Functional\FieldTestBase
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#10 | select-without-any-selected.png | 8.34 KB | idebr |
#5 | 2973827-5.patch | 12.44 KB | idebr |
#5 | interdiff-2-5.txt | 10.32 KB | idebr |
Comments
Comment #2
idebr CreditAttribution: idebr at ezCompany commentedAttached patch updates the tests in \Drupal\Tests\options\Functional\ to extend \Drupal\Tests\field\Functional\FieldTestBase instead.
Comment #4
dawehnerInteresting! Nice catch.
Comment #5
idebr CreditAttribution: idebr at ezCompany commented@dawehner Thanks! I was thoroughly confused for a minute why PHPStorm would not let me run the class as a PHPUnit test.
Replaced the assertOptionSelected() / assertNoOptionSelected() methods with assertSession()->optionExists()->isSelected() and updated the failing tests.
Comment #7
idebr CreditAttribution: idebr at ezCompany commentedSetting status back to 'Needs review' after #2973992: Permission issue in Nightwatch step marks all full testruns as unstable
Comment #8
borisson_Great work @idebr!
Comment #9
plachWhy are we switching the first assertion ("_none") from "not selected" to "selected"?
Comment #10
idebr CreditAttribution: idebr at ezCompany commented#9 Interesting observation indeed.
The generated code looks like this:
Note that the '_none' option is not explicitly selected in the html. However, visually the select element looks like this:
So the select value appears to be '_none' in the UI. Perhaps this assertion is handled differently between browser test drivers. The behavior in PHPUnit does match the DOM selected property, for example using jQuery:
Comment #11
plachMakes sense, thanks!
Comment #13
plachCommitted 48d2617 and pushed to 8.6.x. Thanks!