Countries test failure in a vanilla install

Created on 24 February 2025, 2 months ago

Problem/Motivation

  • Affects 5.4.x
  • Affects 6.1.x

Steps to reproduce

run the phpunit tests in the wxt profile.

Proposed resolution

Might need to copy the wxt_core_update_8502 to a wxt_core install hook.
What this update hook is ensures the countries get created.

Remaining tasks

TBD

User interface changes

TBD

API changes

See proposed solution

Data model changes

Provide configuration baseline.

🐛 Bug report
Status

Active

Version

6.1

Component

Code

Created by

🇨🇦Canada joseph.olstad

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joseph.olstad
  • 🇮🇳India ggh

    looks likes its already included in 6.1.x branch please verify

  • 🇨🇦Canada smulvih2 Canada 🍁

    @joseph can you please give some instructions about how to run these tests? If I exec into the web container and run ../vendor/bin/phpunit -c core profiles/wxt/tests/ I get this:

    There were 4 errors:

    1) Drupal\Tests\wxt\Functional\WxTTest::testWxtLogin
    Exception: You must provide a SIMPLETEST_BASE_URL environment variable to run some PHPUnit based functional tests.

    /var/www/html/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:610
    /var/www/html/core/tests/Drupal/Tests/BrowserTestBase.php:363

    2) Drupal\Tests\wxt\Kernel\ComponentDiscoveryTest::testGetAll
    Exception: There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.

    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:461
    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:275
    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:256
    /var/www/html/profiles/wxt/tests/src/Kernel/ComponentDiscoveryTest.php:29

    3) Drupal\Tests\wxt\Kernel\ComponentDiscoveryTest::testGetMainComponents
    Exception: There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.

    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:461
    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:275
    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:256
    /var/www/html/profiles/wxt/tests/src/Kernel/ComponentDiscoveryTest.php:29

    4) Drupal\Tests\wxt\Kernel\ComponentDiscoveryTest::testGetSubComponents
    Exception: There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.

    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:461
    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:275
    /var/www/html/core/tests/Drupal/KernelTests/KernelTestBase.php:256
    /var/www/html/profiles/wxt/tests/src/Kernel/ComponentDiscoveryTest.php:29

    So it appears I need to provide some environment variables for this to work, please advise. Also I notice from the image in the ticket, you reference core/phpcs.xml but this file doesn't exist in 6.1.x, rather core/phpcs.xml.dist. Thanks!

  • 🇨🇦Canada smulvih2 Canada 🍁

    Steps to reproduce:

    1. Copy core/phpunit.xml.dist to phpunit.xml
    2. Line 9 change to this: bootstrap="html/core/tests/bootstrap.php"
    3. <env name="SIMPLETEST_BASE_URL" value="http://localhost"/>
    4. <env name="SIMPLETEST_DB" value="mysql://root:root@sitewxt_db/wxt"/> (to get working with docker-scaffold)
    5. docker exec -ti sitewxt_web bash
    6. ../vendor/bin/phpunit -c ../phpunit.xml profiles/wxt/tests/
  • 🇨🇦Canada joseph.olstad

    I've pushed up a pull request , we can follow up to this post request some entry into the README.md about this and maybe an entry into the official WxT documentation that basically has a small blurb saying that a test script exists and helps folks run this easily.

    https://github.com/drupalwxt/wxt/pull/316

  • 🇨🇦Canada web247 Toronto

    New patch worked fine for me.

  • 🇨🇦Canada joseph.olstad

    @web247, which patch?

    I'm still seeing this error:

    1) Drupal\Tests\wxt\Functional\WxTTest::testWxtLogin
    Drupal\Core\Config\Schema\SchemaIncompleteException: No schema for wxt_core.settings.countries
    
  • 🇨🇦Canada joseph.olstad

    When applying this patch: https://www.drupal.org/files/issues/2025-02-23/3466676-tests-run.patch no longer get the "No schema" error however get this error instead:

    There was 1 failure:
    
    1) Drupal\Tests\wxt\Functional\WxTTest::testWxtLogin
    User psxykwod successfully logged in.
    Failed asserting that false is true.
    
    /var/www/clients/client1/web1/web/docroot/html/core/tests/Drupal/Tests/UiHelperTrait.php:182
    /var/www/clients/client1/web1/web/docroot/html/profiles/wxt/tests/src/Functional/WxTTest.php:38
    
  • 🇨🇦Canada web247 Toronto

    @joseph.olstad I mean, I was able to apply the patch with no issues:

    Yeah, I am seeing that error now, didn't get that error before. Strange.

  • 🇨🇦Canada web247 Toronto

    Oh, I see what the problem is, in your phpunit.xml file, make sure the SIMPLETEST_BASE_URL setting points to http://localhost and NOT httpS, after that I was able to pass the tests with my patch:

  • 🇨🇦Canada smulvih2 Canada 🍁

    So the problem is not that the wxt_core.settings.countries.yml config file is not imported during install, because on a fresh install of 6.1.x I can see the values in the UI as expected, so updating wxt_core.install is not the solution here. I actually tried to fix the root cause of this issue, which is the wxt_core.settings.countries needs an entry in wxt_core.schema.yml. Once I made the correct entry in the schema file for this, I got another error about the schema for wxt_core.versions (all enabled modules), which will be difficult to deal with since this can change depending on enabled modules.

    After this, I tried the patch from @web247 and it successfully suppressed the errors about the schema. I think this is the best approach, and allows our phpunit to run fully against the defined tests.

  • 🇨🇦Canada joseph.olstad

    This PR actually resolves the countries issue: https://github.com/drupalwxt/wxt/pull/315
    what I'm saying is, there's another unrelated issue.

  • 🇨🇦Canada smulvih2 Canada 🍁

    @joseph I remember this issue for 5.0.x. The issue was introduced in 5.0.1 when the config file in question was introduced, called wxt_core_countries.settings.yml - https://github.com/drupalwxt/wxt/tree/5.0.1/modules/custom/wxt_core/config/install

    Then in 5.0.2 it was renamed wxt_core.settings.countries.yml - https://github.com/drupalwxt/wxt/tree/5.0.2/modules/custom/wxt_core/config/install

    So if a site was on 5.0.1 and gets updated, this update hook wxt_core_update_8502() is needed to fix the config name. But any site setup on 5.0.2+ will not have this issue since the config filename is now correct.

    • smulvih2 committed 00296408 on 6.1.x
      Issue #3508590 by web247, ggh, joseph.olstad, smulvih2: Countries test...
    • smulvih2 committed f3c554cd on 5.4.x
      Issue #3508590 by web247, ggh, joseph.olstad, smulvih2: Countries test...
  • 🇨🇦Canada smulvih2 Canada 🍁

    Pushed to 5.4.x and 6.1.x. This fixes the phpunit tests. Would be good to add documentation on how to setup and run these tests using docker-scaffold here - https://drupalwxt.github.io/docs/development/, but this can be done as a separate issue.

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

Production build 0.71.5 2024