Problem/Motivation

  • Affects 5.4.x
  • Affects 6.1.x

Steps to reproduce

run the phpunit tests in the wxt profile.
screenshot of test run

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.

CommentFileSizeAuthor
#12 patch_install2.png72.57 KBweb247
#11 patch_install.png41.62 KBweb247
#2 3508590.PNG33.48 KBggh

Comments

joseph.olstad created an issue. See original summary.

ggh’s picture

Status: Active » Needs review
StatusFileSize
new33.48 KB

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

joseph.olstad’s picture

smulvih2’s picture

@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!

joseph.olstad’s picture

smulvih2’s picture

Steps to reproduce (using docker-scaffold):

  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://sitewxt_nginx"/>
  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/
joseph.olstad’s picture

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

web247’s picture

New patch worked fine for me.

joseph.olstad’s picture

@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
joseph.olstad’s picture

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
web247’s picture

StatusFileSize
new41.62 KB

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

Applying patch on install file

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

web247’s picture

StatusFileSize
new72.57 KB

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:

Screenshot of the phpunit test

smulvih2’s picture

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.

joseph.olstad’s picture

This patch actually resolves the countries issue: https://patch-diff.githubusercontent.com/raw/drupalwxt/wxt/pull/315.diff
what I'm saying is, there's another unrelated issue with the test.

I actually spent a lot of time working this 8205 hook update last year, what it does is it fixes what needs fixing related to countries settings.

All I'm doing here is calling it on the install, so that fresh installs get the fix also.

smulvih2’s picture

@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...
smulvih2’s picture

Status: Needs review » Fixed

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.

Status: Fixed » Closed (fixed)

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