Commit 3f1d10e
[7.x] Fix failing tests (#1254)
* Fix undefined array key 'price' error in Product::variantOptions()
Between October and November 2024, PHPUnit was upgraded from 10.x to 11.x,
which introduced stricter error handling for undefined array keys. This caused
tests to fail when accessing $variantOption['price'] for variant options that
don't have a price key defined.
The fix uses the null coalescing operator to provide a default null value
when the 'price' key is not present, matching the pattern already used for
the 'stock' key on line 139.
This resolves 35 failing tests in the MigrateProductTypeTest suite and
other tests that create variant options without price values.
* Fix test failures caused by PHPUnit 11 strictness and test pollution
This commit resolves all code-related test failures that emerged between
October 16th and November 24th, 2025, reducing failures from 165 to 24.
The remaining 24 failures are environmental (missing PHP 8.4 PDO SQLite).
## Root Cause Analysis
Between October 16th and November 24th, PHPUnit was upgraded from 10.x to 11.x
(currently 11.5.33). PHPUnit 11 introduced much stricter error handling,
converting PHP warnings (including undefined array key access) into exceptions
during test execution.
## Fixes Applied
1. **Undefined Array Key Errors (135 failures → 0)**
- src/Products/Product.php:136 - Added null coalescing for 'price' key
- src/Orders/HasLineItems.php:37-38 - Added null coalescing for 'product'
and 'quantity' keys
2. **Test Pollution / Blueprint Artifacts (30 failures → 0)**
- tests/Listeners/EnforceEntryBlueprintFieldsTest.php - Added afterEach
cleanup to delete blueprint test artifacts that were persisting to disk
- tests/Helpers/RefreshContent.php - Added Stache entries store clearing
- tests/Orders/EntryOrderRepositoryTest.php - Added Stache clearing in
beforeEach to prevent data accumulation across tests
- tests/Products/EntryProductRepositoryTest.php - Added Stache clearing in
beforeEach to prevent data accumulation across tests
## Test Results
Before fixes: 165 failed, 3 incomplete, 30 skipped, 350 passed
After fixes: 24 failed, 3 incomplete, 30 skipped, 491 passed
The remaining 24 failures are all "could not find driver" (QueryException)
errors related to missing pdo_sqlite extension in PHP 8.4 environment. These
are EloquentOrderRepositoryTest, EloquentCustomerRepositoryTest, and
VerificationControllerEloquentTest failures that require database connectivity.
* Fix additional test pollution and Eloquent query builder issues
1. **EntryCustomerRepositoryTest** - Added Stache clearing in beforeEach to
prevent customer data accumulation across tests
2. **EloquentQueryBuilder::whereStatusLogDate** - Fixed "Relation statusLog
does not exist" error by using native Eloquent builder's whereHas instead
of Statamic's overridden version which expects blueprint-based relationships
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 985528b commit 3f1d10e
8 files changed
Lines changed: 27 additions & 4 deletions
File tree
- src
- Orders
- Products
- tests
- Customers
- Helpers
- Listeners
- Orders
- Products
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
0 commit comments