- Issue created by @joseph.olstad
- 🇨🇦Canada joseph.olstad
Patch
https://patch-diff.githubusercontent.com/raw/drupalwxt/wxt/pull/315.diff
Pull request:
https://github.com/drupalwxt/wxt/pull/315
This needs testing.
- 🇨🇦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:3632) 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:293) 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:294) 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:29So 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, rathercore/phpcs.xml.dist
. Thanks! - 🇨🇦Canada joseph.olstad
To run those tests need to apply this patch:
https://www.drupal.org/files/issues/2025-02-23/3466676-tests-run.patch →
- 🇨🇦Canada smulvih2 Canada 🍁
Steps to reproduce:
- Copy core/phpunit.xml.dist to phpunit.xml
- Line 9 change to this:
bootstrap="html/core/tests/bootstrap.php"
<env name="SIMPLETEST_BASE_URL" value="http://localhost"/>
<env name="SIMPLETEST_DB" value="mysql://root:root@sitewxt_db/wxt"/>
(to get working with docker-scaffold)docker exec -ti sitewxt_web bash
../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.
- 🇨🇦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 theSIMPLETEST_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/installThen 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/installSo 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 00296408 on 6.1.x
-
smulvih2 →
committed f3c554cd on 5.4.x
Issue #3508590 by web247, ggh, joseph.olstad, smulvih2: Countries test...
-
smulvih2 →
committed f3c554cd on 5.4.x
- 🇨🇦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.