From 72fbc680f2f7b07dea4471e8ba53498ade7f8d47 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Wed, 26 Jul 2023 11:06:36 +0100 Subject: [PATCH 1/7] Create product query tests --- .../elements/product/ProductQueryTest.php | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 tests/unit/elements/product/ProductQueryTest.php diff --git a/tests/unit/elements/product/ProductQueryTest.php b/tests/unit/elements/product/ProductQueryTest.php new file mode 100644 index 0000000000..45b6685752 --- /dev/null +++ b/tests/unit/elements/product/ProductQueryTest.php @@ -0,0 +1,112 @@ + + * @since 4.3.0 + */ +class ProductQueryTest extends Unit +{ + /** + * @var UnitTester + */ + protected $tester; + + /** + * @return array + */ + public function _fixtures(): array + { + return [ + 'products' => [ + 'class' => ProductFixture::class, + ], + ]; + } + + /** + * @return void + */ + public function testQuery(): void + { + self::assertInstanceOf(ProductQuery::class, Product::find()); + } + + /** + * @param mixed $price + * @param int $count + * @return void + * @dataProvider defaultPriceDataProvider + */ + public function testDefaultPrice(mixed $price, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'defaultPrice')); + $query->defaultPrice($price); + + self::assertCount($count, $query->all()); + } + + /** + * @return array[] + */ + public function defaultPriceDataProvider(): array + { + return [ + 'exact-results' => [123.99, 1], + 'exact-no-results' => [999, 0], + 'greater-than-results' => ['> 1', 2], + 'greater-than-no-results' => ['> 999', 0], + 'less-than-results' => ['< 150', 2], + 'less-than-no-results' => ['< 1', 0], + 'range-results' => [['and', '> 5', '< 200'], 2], + 'range-no-results' => [['and', '> 500', '< 2000'], 0], + 'in-results' => [[123.99, 19.99], 2], + 'in-no-results' => [[1, 2], 0], + ]; + } + + /** + * @param VariantQuery $variantQuery + * @param int $count + * @return void + * @dataProvider hasVariantDataProvider + */ + public function testHasVariant(VariantQuery $variantQuery, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'hasVariant')); + $query->hasVariant($variantQuery); + + self::assertCount($count, $query->all()); + } + + /** + * @return array[] + */ + public function hasVariantDataProvider(): array + { + return [ + 'no-params' => [Variant::find(), 2], + 'specific-variant' => [Variant::find()->sku('rad-hood'), 1], + ]; + } +} From fcd91dd143c36e53d3d0a84f98f9aef2a40eb424 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Thu, 27 Jul 2023 08:31:50 +0100 Subject: [PATCH 2/7] Add `shippingCategory()` and `shippingCategoryId()` to the product query --- src/elements/db/ProductQuery.php | 104 ++++++++++++++++++ tests/fixtures/ProductTypeFixture.php | 7 +- tests/fixtures/data/shipping-category.php | 8 +- .../elements/product/ProductQueryTest.php | 82 ++++++++++++++ 4 files changed, 196 insertions(+), 5 deletions(-) diff --git a/src/elements/db/ProductQuery.php b/src/elements/db/ProductQuery.php index 22cdd69ca2..de30416c06 100644 --- a/src/elements/db/ProductQuery.php +++ b/src/elements/db/ProductQuery.php @@ -12,6 +12,7 @@ use craft\commerce\elements\Product; use craft\commerce\elements\Variant; use craft\commerce\models\ProductType; +use craft\commerce\models\ShippingCategory; use craft\commerce\Plugin; use craft\db\Query; use craft\db\QueryAbortedException; @@ -20,6 +21,7 @@ use craft\helpers\Db; use DateTime; use yii\db\Connection; +use yii\db\Expression; /** * ProductQuery represents a SELECT SQL statement for products in a way that is independent of DBMS. @@ -104,6 +106,11 @@ class ProductQuery extends ElementQuery */ public mixed $typeId = null; + /** + * @var mixed The shipping category ID(s) that the resulting products must have. + */ + public mixed $shippingCategoryId = null; + /** * @inheritdoc */ @@ -152,6 +159,9 @@ public function __set($name, $value) case 'defaultSku': $this->defaultSku($value); break; + case 'shippingCategory': + $this->shippingCategory($value); + break; default: parent::__set($name, $value); } @@ -432,6 +442,90 @@ public function type(mixed $value): ProductQuery return $this; } + /** + * Narrows the query results based on the products’ shipping categories, per the shipping categories’ IDs. + * + * Possible values include: + * + * | Value | Fetches {elements}… + * | - | - + * | `1` | of a shipping category with an ID of 1. + * | `'not 1'` | not of a shipping category with an ID of 1. + * | `[1, 2]` | of a shipping category with an ID of 1 or 2. + * | `['not', 1, 2]` | not of a shipping category with an ID of 1 or 2. + * + * --- + * + * ```twig + * {# Fetch {elements} of the shipping category with an ID of 1 #} + * {% set {elements-var} = {twig-method} + * .shippingCategoryId(1) + * .all() %} + * ``` + * + * ```php + * // Fetch {elements} of the shipping category with an ID of 1 + * ${elements-var} = {php-method} + * ->shippingCategoryId(1) + * ->all(); + * ``` + * + * @param mixed $value The property value + * @return static self reference + */ + public function shippingCategoryId(mixed $value): ProductQuery + { + $this->shippingCategoryId = $value; + return $this; + } + + /** + * Narrows the query results based on the products’ shipping category. + * + * Possible values include: + * + * | Value | Fetches {elements}… + * | - | - + * | `'foo'` | of a shipping category with a handle of `foo`. + * | `'not foo'` | not of a shipping category with a handle of `foo`. + * | `['foo', 'bar']` | of a shipping category with a handle of `foo` or `bar`. + * | `['not', 'foo', 'bar']` | not of a shipping category with a handle of `foo` or `bar`. + * | an [[ShippingCategory|ShippingCategory]] object | of a shipping category represented by the object. + * + * --- + * + * ```twig + * {# Fetch {elements} with a Foo shipping category #} + * {% set {elements-var} = {twig-method} + * .shippingCategory('foo') + * .all() %} + * ``` + * + * ```php + * // Fetch {elements} with a Foo shipping category + * ${elements-var} = {php-method} + * ->shippingCategory('foo') + * ->all(); + * ``` + * + * @param ProductType|string|null|array $value The property value + * @return static self reference + */ + public function shippingCategory(mixed $value): ProductQuery + { + if ($value instanceof ShippingCategory) { + $this->shippingCategoryId = [$value->id]; + } elseif ($value !== null) { + $this->shippingCategoryId = (new Query()) + ->from(['shippingcategories' => Table::SHIPPINGCATEGORIES]) + ->where(['shippingcategories.id' => new Expression('[[commerce_products.shippingCategoryId]]')]) + ->andWhere(Db::parseParam('handle', $value)); + } else { + $this->shippingCategoryId = null; + } + + return $this; + } /** * Narrows the query results to only products that were posted before a certain date. * @@ -786,6 +880,16 @@ protected function beforePrepare(): bool $this->subQuery->andWhere(['commerce_products.typeId' => $this->typeId]); } + if (isset($this->shippingCategoryId)) { + if ($this->shippingCategoryId instanceof Query) { + $shippingCategoryWhere = ['exists', $this->shippingCategoryId]; + } else { + $shippingCategoryWhere = Db::parseParam('commerce_products.shippingCategoryId', $this->shippingCategoryId); + } + + $this->subQuery->andWhere($shippingCategoryWhere); + } + if (isset($this->defaultPrice)) { $this->subQuery->andWhere(Db::parseParam('commerce_products.defaultPrice', $this->defaultPrice)); } diff --git a/tests/fixtures/ProductTypeFixture.php b/tests/fixtures/ProductTypeFixture.php index 86a37856b5..51368e3f32 100644 --- a/tests/fixtures/ProductTypeFixture.php +++ b/tests/fixtures/ProductTypeFixture.php @@ -31,5 +31,10 @@ class ProductTypeFixture extends ActiveFixture /** * @inheritdoc */ - public $depends = [ProductTypeSitesFixture::class]; + public $depends = [ + ShippingCategoryFixture::class, + ProductTypesShippingCategoriesFixture::class, + TaxCategoryFixture::class, + ProductTypeSitesFixture::class, + ]; } diff --git a/tests/fixtures/data/shipping-category.php b/tests/fixtures/data/shipping-category.php index bec54858db..c8d0d8baec 100644 --- a/tests/fixtures/data/shipping-category.php +++ b/tests/fixtures/data/shipping-category.php @@ -8,10 +8,10 @@ return [ [ 'id' => 101, - 'name' => 'General 1', - 'handle' => 'general_1', - 'description' => 'this is the default shipping category', - 'default' => '1', + 'name' => 'Another Shipping Category', + 'handle' => 'anotherShippingCategory', + 'description' => 'this is another shipping category', + 'default' => 0, 'uid' => 'xx-xx-xx', ], ]; diff --git a/tests/unit/elements/product/ProductQueryTest.php b/tests/unit/elements/product/ProductQueryTest.php index 45b6685752..9b36eefeae 100644 --- a/tests/unit/elements/product/ProductQueryTest.php +++ b/tests/unit/elements/product/ProductQueryTest.php @@ -12,6 +12,7 @@ use craft\commerce\elements\db\VariantQuery; use craft\commerce\elements\Product; use craft\commerce\elements\Variant; +use craft\commerce\models\ShippingCategory; use craftcommercetests\fixtures\ProductFixture; use UnitTester; @@ -109,4 +110,85 @@ public function hasVariantDataProvider(): array 'specific-variant' => [Variant::find()->sku('rad-hood'), 1], ]; } + + /** + * @param mixed $shippingCategoryId + * @param int $count + * @return void + * @dataProvider shippingCategoryIdDataProvider + */ + public function testShippingCategoryId(mixed $shippingCategoryId, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'shippingCategoryId')); + $query->shippingCategoryId($shippingCategoryId); + + self::assertCount($count, $query->all()); + } + + /** + * @param mixed $shippingCategoryId + * @param int $count + * @return void + * @dataProvider shippingCategoryIdDataProvider + */ + public function testShippingCategoryIdProperty(mixed $shippingCategoryId, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'shippingCategoryId')); + $query->shippingCategoryId = $shippingCategoryId; + + self::assertCount($count, $query->all()); + } + + /** + * @return array + */ + public function shippingCategoryIdDataProvider(): array + { + return [ + 'no-params' => [null, 2], + 'specific-id' => [101, 1], + 'in' => [[101, 102], 1], + 'not-in' => [['not', 102, 103], 2], + 'greater-than' => ['> 100', 1], + 'less-than' => ['< 100', 1], + ]; + } + + /** + * @param mixed $shippingCategory + * @param int $count + * @return void + * @dataProvider shippingCategoryDataProvider + */ + public function testShippingCategory(mixed $shippingCategory, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'shippingCategoryId')); + $query->shippingCategory($shippingCategory); + + self::assertCount($count, $query->all()); + } + + /** + * @return array + */ + public function shippingCategoryDataProvider(): array + { + $matchingShippingCategory = new ShippingCategory(['id' => 101]); + $nonMatchingShippingCategory = new ShippingCategory(['id' => 999]); + + return [ + 'no-params' => [null, 2], + 'specific-handle' => ['anotherShippingCategory', 1], + 'in' => [['anotherShippingCategory', 'general'], 2], + 'not-in' => [['not', 'foo', 'bar'], 2], + 'matching-shipping-category' => [$matchingShippingCategory, 1], + 'non-matching-shipping-category' => [$nonMatchingShippingCategory, 0], + ]; + } } From 811eb7802ba489568c68ee64e341b3d0ddc2b900 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Thu, 27 Jul 2023 08:34:43 +0100 Subject: [PATCH 3/7] Fix doc block --- src/elements/db/ProductQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/elements/db/ProductQuery.php b/src/elements/db/ProductQuery.php index de30416c06..8354a0cef8 100644 --- a/src/elements/db/ProductQuery.php +++ b/src/elements/db/ProductQuery.php @@ -508,7 +508,7 @@ public function shippingCategoryId(mixed $value): ProductQuery * ->all(); * ``` * - * @param ProductType|string|null|array $value The property value + * @param ShippingCategory|string|null|array $value The property value * @return static self reference */ public function shippingCategory(mixed $value): ProductQuery From d61ca35020139f0924e0d45d759b30aae51606ed Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Thu, 27 Jul 2023 08:58:54 +0100 Subject: [PATCH 4/7] update uid --- tests/fixtures/data/shipping-category.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/data/shipping-category.php b/tests/fixtures/data/shipping-category.php index c8d0d8baec..3fc4e6b142 100644 --- a/tests/fixtures/data/shipping-category.php +++ b/tests/fixtures/data/shipping-category.php @@ -12,6 +12,6 @@ 'handle' => 'anotherShippingCategory', 'description' => 'this is another shipping category', 'default' => 0, - 'uid' => 'xx-xx-xx', + 'uid' => 'ship-category-1001---------------uid', ], ]; From fe0f852c9b91d550425d652d300e42cfe6042be2 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Thu, 27 Jul 2023 08:59:40 +0100 Subject: [PATCH 5/7] Add `taxCategory()` and `taxCategoryId()` to the product query --- src/elements/db/ProductQuery.php | 102 ++++++++++++++++++ tests/fixtures/ProductTypeFixture.php | 1 + tests/fixtures/data/tax-category.php | 8 +- .../elements/product/ProductQueryTest.php | 82 ++++++++++++++ 4 files changed, 189 insertions(+), 4 deletions(-) diff --git a/src/elements/db/ProductQuery.php b/src/elements/db/ProductQuery.php index 8354a0cef8..9bd6d6e935 100644 --- a/src/elements/db/ProductQuery.php +++ b/src/elements/db/ProductQuery.php @@ -13,6 +13,7 @@ use craft\commerce\elements\Variant; use craft\commerce\models\ProductType; use craft\commerce\models\ShippingCategory; +use craft\commerce\models\TaxCategory; use craft\commerce\Plugin; use craft\db\Query; use craft\db\QueryAbortedException; @@ -111,6 +112,11 @@ class ProductQuery extends ElementQuery */ public mixed $shippingCategoryId = null; + /** + * @var mixed The tax category ID(s) that the resulting products must have. + */ + public mixed $taxCategoryId = null; + /** * @inheritdoc */ @@ -526,6 +532,92 @@ public function shippingCategory(mixed $value): ProductQuery return $this; } + + /** + * Narrows the query results based on the products’ tax categories, per the tax categories’ IDs. + * + * Possible values include: + * + * | Value | Fetches {elements}… + * | - | - + * | `1` | of a tax category with an ID of 1. + * | `'not 1'` | not of a tax category with an ID of 1. + * | `[1, 2]` | of a tax category with an ID of 1 or 2. + * | `['not', 1, 2]` | not of a tax category with an ID of 1 or 2. + * + * --- + * + * ```twig + * {# Fetch {elements} of the tax category with an ID of 1 #} + * {% set {elements-var} = {twig-method} + * .taxCategoryId(1) + * .all() %} + * ``` + * + * ```php + * // Fetch {elements} of the tax category with an ID of 1 + * ${elements-var} = {php-method} + * ->taxCategoryId(1) + * ->all(); + * ``` + * + * @param mixed $value The property value + * @return static self reference + */ + public function taxCategoryId(mixed $value): ProductQuery + { + $this->taxCategoryId = $value; + return $this; + } + + /** + * Narrows the query results based on the products’ tax category. + * + * Possible values include: + * + * | Value | Fetches {elements}… + * | - | - + * | `'foo'` | of a tax category with a handle of `foo`. + * | `'not foo'` | not of a tax category with a handle of `foo`. + * | `['foo', 'bar']` | of a tax category with a handle of `foo` or `bar`. + * | `['not', 'foo', 'bar']` | not of a tax category with a handle of `foo` or `bar`. + * | an [[ShippingCategory|ShippingCategory]] object | of a tax category represented by the object. + * + * --- + * + * ```twig + * {# Fetch {elements} with a Foo tax category #} + * {% set {elements-var} = {twig-method} + * .taxCategory('foo') + * .all() %} + * ``` + * + * ```php + * // Fetch {elements} with a Foo tax category + * ${elements-var} = {php-method} + * ->taxCategory('foo') + * ->all(); + * ``` + * + * @param TaxCategory|string|null|array $value The property value + * @return static self reference + */ + public function taxCategory(mixed $value): ProductQuery + { + if ($value instanceof TaxCategory) { + $this->taxCategoryId = [$value->id]; + } elseif ($value !== null) { + $this->taxCategoryId = (new Query()) + ->from(['taxcategories' => Table::TAXCATEGORIES]) + ->where(['taxcategories.id' => new Expression('[[commerce_products.taxCategoryId]]')]) + ->andWhere(Db::parseParam('handle', $value)); + } else { + $this->taxCategoryId = null; + } + + return $this; + } + /** * Narrows the query results to only products that were posted before a certain date. * @@ -890,6 +982,16 @@ protected function beforePrepare(): bool $this->subQuery->andWhere($shippingCategoryWhere); } + if (isset($this->taxCategoryId)) { + if ($this->taxCategoryId instanceof Query) { + $taxCategoryWhere = ['exists', $this->taxCategoryId]; + } else { + $taxCategoryWhere = Db::parseParam('commerce_products.taxCategoryId', $this->taxCategoryId); + } + + $this->subQuery->andWhere($taxCategoryWhere); + } + if (isset($this->defaultPrice)) { $this->subQuery->andWhere(Db::parseParam('commerce_products.defaultPrice', $this->defaultPrice)); } diff --git a/tests/fixtures/ProductTypeFixture.php b/tests/fixtures/ProductTypeFixture.php index 51368e3f32..9e14ed7852 100644 --- a/tests/fixtures/ProductTypeFixture.php +++ b/tests/fixtures/ProductTypeFixture.php @@ -35,6 +35,7 @@ class ProductTypeFixture extends ActiveFixture ShippingCategoryFixture::class, ProductTypesShippingCategoriesFixture::class, TaxCategoryFixture::class, + ProductTypesTaxCategoriesFixture::class, ProductTypeSitesFixture::class, ]; } diff --git a/tests/fixtures/data/tax-category.php b/tests/fixtures/data/tax-category.php index 3ac7330120..d6b683b2f7 100644 --- a/tests/fixtures/data/tax-category.php +++ b/tests/fixtures/data/tax-category.php @@ -8,10 +8,10 @@ return [ [ 'id' => 101, - 'name' => 'General 1', - 'handle' => 'general_1', - 'description' => 'this is the default tax category', + 'name' => 'Another Tax Category', + 'handle' => 'anotherTaxCategory', + 'description' => 'this is another tax category', 'default' => '1', - 'uid' => 'xx-xx-xx', + 'uid' => 'tax--category-1001---------------uid', ], ]; diff --git a/tests/unit/elements/product/ProductQueryTest.php b/tests/unit/elements/product/ProductQueryTest.php index 9b36eefeae..ea18067f8c 100644 --- a/tests/unit/elements/product/ProductQueryTest.php +++ b/tests/unit/elements/product/ProductQueryTest.php @@ -13,6 +13,7 @@ use craft\commerce\elements\Product; use craft\commerce\elements\Variant; use craft\commerce\models\ShippingCategory; +use craft\commerce\models\TaxCategory; use craftcommercetests\fixtures\ProductFixture; use UnitTester; @@ -191,4 +192,85 @@ public function shippingCategoryDataProvider(): array 'non-matching-shipping-category' => [$nonMatchingShippingCategory, 0], ]; } + + /** + * @param mixed $taxCategoryId + * @param int $count + * @return void + * @dataProvider taxCategoryIdDataProvider + */ + public function testTaxCategoryId(mixed $taxCategoryId, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'taxCategoryId')); + $query->taxCategoryId($taxCategoryId); + + self::assertCount($count, $query->all()); + } + + /** + * @param mixed $taxCategoryId + * @param int $count + * @return void + * @dataProvider taxCategoryIdDataProvider + */ + public function testTaxCategoryIdProperty(mixed $taxCategoryId, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'taxCategoryId')); + $query->taxCategoryId = $taxCategoryId; + + self::assertCount($count, $query->all()); + } + + /** + * @return array + */ + public function taxCategoryIdDataProvider(): array + { + return [ + 'no-params' => [null, 2], + 'specific-id' => [101, 1], + 'in' => [[101, 102], 1], + 'not-in' => [['not', 102, 103], 2], + 'greater-than' => ['> 100', 1], + 'less-than' => ['< 100', 1], + ]; + } + + /** + * @param mixed $taxCategory + * @param int $count + * @return void + * @dataProvider taxCategoryDataProvider + */ + public function testTaxCategory(mixed $taxCategory, int $count): void + { + $query = Product::find(); + + self::assertTrue(method_exists($query, 'taxCategoryId')); + $query->taxCategory($taxCategory); + + self::assertCount($count, $query->all()); + } + + /** + * @return array + */ + public function taxCategoryDataProvider(): array + { + $matchingTaxCategory = new TaxCategory(['id' => 101]); + $nonMatchingTaxCategory = new TaxCategory(['id' => 999]); + + return [ + 'no-params' => [null, 2], + 'specific-handle' => ['anotherTaxCategory', 1], + 'in' => [['anotherTaxCategory', 'general'], 2], + 'not-in' => [['not', 'foo', 'bar'], 2], + 'matching-tax-category' => [$matchingTaxCategory, 1], + 'non-matching-tax-category' => [$nonMatchingTaxCategory, 0], + ]; + } } From 143ca380ba42ef935a307a6f15ade5e3185d9c08 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Thu, 27 Jul 2023 09:02:31 +0100 Subject: [PATCH 6/7] Update readme --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad763345a3..c442e4b18e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,18 @@ ## 4.3.0 - Unreleased +- It’s now possible to query products by shipping category and tax category. ([#3219](https://github.com/craftcms/commerce/issues/3219)) - It’s now possible to modify the purchasables shown in the add line item table on the Edit Order page. ([#3194](https://github.com/craftcms/commerce/issues/3194)) - Added `craft\commerce\events\ModifyPurchasablesQueryEvent`. - Added `craft\commerce\controllers\OrdersController::EVENT_MODIFY_PURCHASABLES_QUERY`. - Guest customers registering during checkout now have their addresses saved to their account. - Deprecated `craft\commerce\elements\Order::setEmail()`. `Order::setCustomer()` should be used instead. +- Added `craft\commerce\elements\db\ProductQuery::$shippingCategoryId`. +- Added `craft\commerce\elements\db\ProductQuery::$taxCategoryId`. +- Added `craft\commerce\elements\db\ProductQuery::shippingCategory()`. +- Added `craft\commerce\elements\db\ProductQuery::shippingCategoryId()`. +- Added `craft\commerce\elements\db\ProductQuery::taxCategory()`. +- Added `craft\commerce\elements\db\ProductQuery::taxCategoryId()`. ## Unreleased From bab1b7c3e4f61fe9ae7207dd2a3db9971e2475dc Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Thu, 27 Jul 2023 09:02:55 +0100 Subject: [PATCH 7/7] fix cs --- tests/unit/elements/product/ProductQueryTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/elements/product/ProductQueryTest.php b/tests/unit/elements/product/ProductQueryTest.php index ea18067f8c..a4db81ec0e 100644 --- a/tests/unit/elements/product/ProductQueryTest.php +++ b/tests/unit/elements/product/ProductQueryTest.php @@ -93,12 +93,12 @@ public function defaultPriceDataProvider(): array */ public function testHasVariant(VariantQuery $variantQuery, int $count): void { - $query = Product::find(); + $query = Product::find(); - self::assertTrue(method_exists($query, 'hasVariant')); - $query->hasVariant($variantQuery); + self::assertTrue(method_exists($query, 'hasVariant')); + $query->hasVariant($variantQuery); - self::assertCount($count, $query->all()); + self::assertCount($count, $query->all()); } /**