Problem/Motivation
We want to get rid of simpletest.module in Drupal 9. We want to prepare the latest Drupal 8 development branch as much as possible before opening the Drupal 9 development branch (see #2608062: [policy, no patch] Pre-requisites for opening Drupal 9). Therefore we need to convert all web tests to BrowserTestBase or UnitTestBase or KernelTestBase and deprecate WebTestBase.
Proposed resolution
1) Convert a small part of Drupal core web tests to Browser tests to get them battle tested. See all the conversion child issues that have been opened here before 2016-Sept-01.
2) Implement a backward compatibility layer as AssertLegacyTrait used by BrowserTestBase. Ideally a test conversion should only be the change of the namespace and used base class. Everything else should be covered by backwards compatible methods as far as possible/reasonable.
3) Prepare one big bang patch of test conversions in #2770921: Feb 21st: Convert chunk of WTB to BTB by just moving classes, changing use statements adding traits. Commit it during code freeze of the next Drupal minor release (likely March 2017 for 8.3).
4) In the meantime open child issues to convert web tests for each core module. While doing so we should also check if the test cases actually require a browser or can be converted to unit/kernel tests. They will be postponed until #2770921: Feb 21st: Convert chunk of WTB to BTB by just moving classes, changing use statements adding traits is committed.
Remaining tasks
Resolve all the child issues. Convert web tests in child issues per module/component in Drupal core.
Instructions for converting a Simpletest web test:
- Read https://www.drupal.org/phpunit and all subpages, especially https://www.drupal.org/node/2783189 .
- Move the test file to a tests/src/Functional folder in the module.
- Rename the namespace, make the class extends BrowserTestBase and fix the use statement.
- Try to run the single test with phpunit, example for HelpTest (replace the path with the file you converted):
cd core ../vendor/bin/phpunit modules/help/tests/src/Functional/HelpTest.php --stop-on-failure
- You can download the helper script browsertest-convert.php to your Drupal root directory and do a primitive conversion for all web tests of a core module with
php browsertest-convert.php <MODULENAME>
- Fatal error: undefined function assertNoLink(): not all legacy assertion methods are implemented yet, check #2750941: Additional BC assertions from WebTestBase to BrowserTestBase to borrow from there.
- If there is a test method which does not perform a web request (for example no ->drupalGet() or ->drupalPostForm() calls) then that method should be extracted to a unit test or kernel test.
- Otherwise try to change as little things as possible in the converted web test. The conversion should be easy to review and further cleanup can be done in a follow-up issue.
- If you get stuck checkout the other child issues that do conversions - they can give you a hint what needs to be changed.
Conversions
Note: don't convert the following bits:
- Tour tests
- Update path tests
- Views tests
- action: #2736109: Convert web tests to browser tests for action module
- aggregator: #2757023: Convert all aggregator web tests to BrowserTestBase
- automated_cron: Doesn't contain any tests: ¯\_(ツ)_/¯
- ban: #2742497: Convert web tests to browser tests for ban module
- basic_auth: #2862494: Convert web tests to browser tests for basic_auth module
- big_pipe: Issue to be created
- block: Issue to be created
- block_content: Issue to be created
- block_place: Already converted initially
- book: #2757007: Convert all book web tests to BrowserTestBase
- breakpoint: No webtests
- ckeditor: To be created
- color: #2753179: Convert all color web tests to BrowserTestBase
- comment: To be created
- config: To be created
- config_translation: To be created
- contact: #2742995: Convert web tests to browser tests for contact module
- content_moderation: To be created
- content_translation: To be created
- contextual: To be created
- datetime & datetime_range: #2780063: Convert web tests to browser tests for datetime and datetime_range modules
- dblog: To be created
- dynamic_page_cache
- editor
- entity_reference
- field
- field_layout
- field_ui: #2794347: Convert web tests to browser tests for field_ui module
- file
- filter
- forum: #2737805: Convert web tests to browser tests for forum module
- hal
- help: #2735199: Convert web tests to browser tests for help module
- history: #2795049: Convert web tests to browser tests for history module
- image
- inline_form_errors
- language: #2756059: Convert web tests to browser tests for language module
- layout_discovery
- link: #2763013: Convert web tests to browser tests for link module
- locale
- media
- menu_link_content
- menu_link_node
- menu_ui
- migrate
- migrate_drupal
- migrate_drupal_ui
- node
- options
- outside_in
- page_cache
- path
- quickedit
- rdf
- responsive_image
- rest: #2775553: Convert web tests to browser tests for rest module
- search
- serialization
- shortcut
- simpletest
- statistics
- syslog: #2782663: Convert web tests to browser tests for syslog module
- system
- taxonomy
- telephone: #2755991: Convert web tests to browser tests for telephone module
- text
- toolbar
- tour: #2767275: Convert web tests to browser tests for tour module
- tracker
- update
- user
- views
- views_ui: #2747167: Convert web tests of views_ui
- workflows
User interface changes
None.
API changes
Simpletest and WebTestBase will be deprecated.
Data model changes
None.