Describe your bug or feature request.

I've been investigating some of the D9 test failures today (See https://www.drupal.org/pift-ci-job/2140511), and investigated the following error message:

Error: Call to a member function id() on null

/var/www/html/modules/contrib/commerce/modules/cart/src/CartProvider.php:82

It appears this is due to the current store service being accessed really early (before a store actually gets created in our tests).

See the following backtrace to understand what's going on:

modules/contrib/commerce/modules/store/src/CurrentStore.php:65
modules/contrib/commerce/modules/store/src/Resolver/StoreCountryResolver.php:43
modules/contrib/commerce/src/Resolver/ChainCountryResolver.php:46
modules/contrib/commerce/src/CurrentCountry.php:62
modules/contrib/commerce/src/Resolver/DefaultLocaleResolver.php:54
modules/contrib/commerce/src/Resolver/ChainLocaleResolver.php:46
modules/contrib/commerce/src/CurrentLocale.php:62
modules/contrib/commerce/modules/price/src/CurrencyFormatter.php:29
core/lib/Drupal/Component/DependencyInjection/Container.php:262
core/lib/Drupal/Component/DependencyInjection/Container.php:176
modules/contrib/commerce/modules/price/src/Plugin/Field/FieldFormatter/PriceDefaultFormatter.php:72
core/lib/Drupal/Core/Field/FormatterPluginManager.php:64
core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php:81
core/lib/Drupal/Component/Plugin/LazyPluginCollection.php:80
core/lib/Drupal/Component/Plugin/LazyPluginCollection.php:148
core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php:114
core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:293
core/lib/Drupal/Core/Entity/EntityDisplayBase.php:259
core/lib/Drupal/Core/Entity/EntityStorageBase.php:494
core/lib/Drupal/Core/Entity/EntityStorageBase.php:449
core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:252
core/lib/Drupal/Core/Entity/EntityBase.php:339
core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:592
core/lib/Drupal/Core/Config/ConfigInstaller.php:373
core/lib/Drupal/Core/Config/ConfigInstaller.php:137
core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php:75
core/lib/Drupal/Core/Extension/ModuleInstaller.php:305
core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:470
core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:70
core/tests/Drupal/Tests/BrowserTestBase.php:562
core/tests/Drupal/Tests/BrowserTestBase.php:381
modules/contrib/commerce/tests/src/FunctionalJavascript/CommerceWebDriverTestBase.php:72
modules/contrib/commerce/modules/order/tests/src/FunctionalJavascript/OrderWebDriverTestBase.php:46
modules/contrib/commerce/modules/cart/tests/src/FunctionalJavascript/CartWebDriverTestBase.php:57
modules/contrib/commerce/modules/cart/tests/src/FunctionalJavascript/AddToCartMultilingualTest.php:61

I don't really understand why this isn't a problem with d8 tests though...

Calling $this->rebuildContainer(); in CommerceWebDriverTestBase::setup() seems to fix the issue, but I wonder if we should fix this differently.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jsacksick created an issue. See original summary.

jsacksick’s picture

Issue summary: View changes
jsacksick’s picture

Status: Needs review » Needs work

The last submitted patch, 3: 3227375-3.patch, failed testing. View results

jsacksick’s picture

Another approach, which skips calling the current store by passing the store to the cart provider.

jsacksick’s picture

Status: Needs review » Fixed

This removes 6 test failures, committing.

jsacksick’s picture

Status: Fixed » Needs review

Not yet committed, cannot push to d.org atm.

  • jsacksick committed cb0ad00 on 8.x-2.x
    Issue #3227375 by jsacksick: Fix a test error due to an early...
jsacksick’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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