Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 41711a8

Browse files
author
Jens Schulze
committed
refactor(ProductSearch): disable markMatchingVariants by default
BREAKING CHANGE: markMatchingVariants has been disabled by default For performance reasons the markMatchingVariants flag has been disabled by default. In order to use markMatchingVariants feature please enable it explicit. Before: ``` $request = ProductProjectionSearchRequest::of(); ``` After: ``` $request = ProductProjectionSearchRequest::of()->markMatchingVariants(true); ```
1 parent c3ceac7 commit 41711a8

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

src/Request/Products/ProductProjectionSearchRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ProductProjectionSearchRequest extends AbstractProjectionRequest implement
5353
public function __construct(Context $context = null)
5454
{
5555
parent::__construct(ProductProjectionEndpoint::endpoint(), $context);
56+
$this->markMatchingVariants(false);
5657
}
5758

5859
/**
@@ -173,7 +174,7 @@ public function fuzzy($level)
173174
public function markMatchingVariants($mark)
174175
{
175176
$this->addParamObject(new Parameter('markMatchingVariants', $mark));
176-
177+
177178
return $this;
178179
}
179180

tests/unit/Request/Products/ProductProjectionSearchRequestTest.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testFuzzy()
2727
$httpRequest = $request->httpRequest();
2828

2929
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
30-
$this->assertSame('fuzzy=true', (string)$httpRequest->getBody());
30+
$this->assertContains('fuzzy=true', (string)$httpRequest->getBody());
3131
}
3232

3333
public function testMarkMatchingVariant()
@@ -56,6 +56,18 @@ public function testDontMarkMatchingVariant()
5656
$this->assertSame('markMatchingVariants=false', (string)$httpRequest->getBody());
5757
}
5858

59+
public function testMarkMatchingVariantDefault()
60+
{
61+
/**
62+
* @var ProductProjectionSearchRequest $request
63+
*/
64+
$request = $this->getRequest(static::PRODUCT_PROJECTION_SEARCH_REQUEST);
65+
$httpRequest = $request->httpRequest();
66+
67+
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
68+
$this->assertSame('markMatchingVariants=false', (string)$httpRequest->getBody());
69+
}
70+
5971
public function fuzzyProvider()
6072
{
6173
return [
@@ -82,7 +94,7 @@ public function testFuzzyLevel($level, $expected)
8294
$httpRequest = $request->httpRequest();
8395

8496
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
85-
$this->assertSame($expected, (string)$httpRequest->getBody());
97+
$this->assertContains($expected, (string)$httpRequest->getBody());
8698
}
8799

88100
public function testMapResult()
@@ -114,7 +126,7 @@ public function testAddFilterString()
114126
$httpRequest = $request->httpRequest();
115127

116128
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
117-
$this->assertSame('filter=key%3A%22value%22', (string)$httpRequest->getBody());
129+
$this->assertContains('filter=key%3A%22value%22', (string)$httpRequest->getBody());
118130
}
119131

120132
public function testAddMultiFilterString()
@@ -128,7 +140,7 @@ public function testAddMultiFilterString()
128140
$httpRequest = $request->httpRequest();
129141

130142
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
131-
$this->assertSame('filter=foo%3A%22bar%22&filter=key%3A%22value%22', (string)$httpRequest->getBody());
143+
$this->assertContains('filter=foo%3A%22bar%22&filter=key%3A%22value%22', (string)$httpRequest->getBody());
132144
}
133145

134146
public function testAddFilterInt()
@@ -141,7 +153,7 @@ public function testAddFilterInt()
141153
$httpRequest = $request->httpRequest();
142154

143155
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
144-
$this->assertSame('filter=key%3A10', (string)$httpRequest->getBody());
156+
$this->assertContains('filter=key%3A10', (string)$httpRequest->getBody());
145157
}
146158

147159
public function testAddFilterArray()
@@ -154,7 +166,7 @@ public function testAddFilterArray()
154166
$httpRequest = $request->httpRequest();
155167

156168
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
157-
$this->assertSame('filter=key%3A10%2C20%2C30', (string)$httpRequest->getBody());
169+
$this->assertContains('filter=key%3A10%2C20%2C30', (string)$httpRequest->getBody());
158170
}
159171

160172
public function testAddFilterQuery()
@@ -167,7 +179,7 @@ public function testAddFilterQuery()
167179
$httpRequest = $request->httpRequest();
168180

169181
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
170-
$this->assertSame('filter.query=key%3A%22value%22', (string)$httpRequest->getBody());
182+
$this->assertContains('filter.query=key%3A%22value%22', (string)$httpRequest->getBody());
171183
}
172184

173185
public function testAddFilterQueryFacet()
@@ -181,7 +193,7 @@ public function testAddFilterQueryFacet()
181193
$httpRequest = $request->httpRequest();
182194

183195
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
184-
$this->assertSame('facet=key%3A%22value%22&filter.query=key%3A%22value%22', (string)$httpRequest->getBody());
196+
$this->assertContains('facet=key%3A%22value%22&filter.query=key%3A%22value%22', (string)$httpRequest->getBody());
185197
}
186198

187199
public function testAddMultiFilterQuery()
@@ -195,7 +207,7 @@ public function testAddMultiFilterQuery()
195207
$httpRequest = $request->httpRequest();
196208

197209
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
198-
$this->assertSame(
210+
$this->assertContains(
199211
'filter.query=foo%3A%22bar%22&filter.query=key%3A%22value%22',
200212
(string)$httpRequest->getBody()
201213
);
@@ -211,7 +223,7 @@ public function testAddFilterFacets()
211223
$httpRequest = $request->httpRequest();
212224

213225
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
214-
$this->assertSame('filter.facets=key%3A%22value%22', (string)$httpRequest->getBody());
226+
$this->assertContains('filter.facets=key%3A%22value%22', (string)$httpRequest->getBody());
215227
}
216228

217229
public function testAddMultiFilterFacets()
@@ -225,7 +237,7 @@ public function testAddMultiFilterFacets()
225237
$httpRequest = $request->httpRequest();
226238

227239
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
228-
$this->assertSame(
240+
$this->assertContains(
229241
'filter.facets=foo%3A%22bar%22&filter.facets=key%3A%22value%22',
230242
(string)$httpRequest->getBody()
231243
);
@@ -241,7 +253,7 @@ public function testAddFacet()
241253
$httpRequest = $request->httpRequest();
242254

243255
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
244-
$this->assertSame('facet=key%3A%22value%22', (string)$httpRequest->getBody());
256+
$this->assertContains('facet=key%3A%22value%22', (string)$httpRequest->getBody());
245257
}
246258

247259
public function testAddMultiFacet()
@@ -255,7 +267,7 @@ public function testAddMultiFacet()
255267
$httpRequest = $request->httpRequest();
256268

257269
$this->assertSame('product-projections/search', (string)$httpRequest->getUri());
258-
$this->assertSame('facet=foo%3A%22bar%22&facet=key%3A%22value%22', (string)$httpRequest->getBody());
270+
$this->assertContains('facet=foo%3A%22bar%22&facet=key%3A%22value%22', (string)$httpRequest->getBody());
259271
}
260272

261273
public function testHttpRequestMethod()
@@ -279,7 +291,7 @@ public function testHttpRequestObject()
279291
$request = ProductProjectionSearchRequest::of();
280292
$httpRequest = $request->httpRequest();
281293

282-
$this->assertEmpty((string)$httpRequest->getBody());
294+
$this->assertSame('markMatchingVariants=false', (string)$httpRequest->getBody());
283295
}
284296

285297
public function testBuildResponse()

0 commit comments

Comments
 (0)