Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We'll probably want to wait on #2675836: Expand the add to cart form test coverage to introduce some helpers for creating sets of attributes (Color/Size, for example).
Comment | File | Size | Author |
---|---|---|---|
#8 | commerce-2689915-variation_title_with_attributes-8.patch | 11.89 KB | czigor |
| |||
#6 | commerce-2689915-variation_title_with_attributes-6.patch | 12.07 KB | czigor |
|
Comments
Comment #2
czigor CreditAttribution: czigor at Centarro commentedComment #3
bojanz CreditAttribution: bojanz at Centarro commentedWe're now using CartBrowserTestTrait, belonging to commerce_cart, in commerce_product, even though commerce_product doesn't depend on commerce_cart. For some reason this works, but it's still ugly.
Let's create a ProductAttributeTestTrait next to ProductBrowserTestBase and then use it from both this test and the cart tests.
This trait should have createAttributeSet and createAttributeValue.
Comment #4
czigor CreditAttribution: czigor at Centarro commentedDone. Let's see what the testbot says.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedGreat!
One last thing. The trait has a dependency:
The pattern that we use for this is to let the trait define the property as well (protected $attributeFieldManager;), and then just assign that property in the constructor/setUp of classes that use the trait.
Comment #6
czigor CreditAttribution: czigor at Centarro commentedFixed that too
Comment #7
mglamanDrupal actually supports
Drupal\Tests\$module\Traits
as a namespace for test traits, so they can be shared between test suites.See: http://cgit.drupalcode.org/drupal/tree/core/tests/bootstrap.php#n98
Maybe we should place this trait there? I might be useful elsewhere.
We're in a test and should use
$this->container
.Comment #8
czigor CreditAttribution: czigor at Centarro commentedFixed 1. We should fix the other traits in a followup issue.
@2: Everywhere in tests we use \Drupal::service() instead of $this->container. Maybe we should open a different issue to fix that.
Comment #9
czigor CreditAttribution: czigor at Centarro commentedOpened #3020704: Move test Traits to a Traits folder and namespace to fix @1.
Comment #11
bojanz CreditAttribution: bojanz at Centarro commentedThank you Andras, this looks great.