Skip to content

Commit b23b9e5

Browse files
committed
ACP2E-1634: added integration test
1 parent 33bdbc2 commit b23b9e5

File tree

2 files changed

+79
-58
lines changed

2 files changed

+79
-58
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListProduct/CheckProductPriceTest.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99

1010
use Magento\Catalog\Api\ProductRepositoryInterface;
1111
use Magento\Catalog\Block\Product\ListProduct;
12+
use Magento\Catalog\Test\Fixture\Category as CategoryFixture;
13+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
14+
use Magento\Customer\Model\Group;
1215
use Magento\Customer\Model\Session;
1316
use Magento\Framework\View\Element\Template;
1417
use Magento\Framework\View\Result\PageFactory;
18+
use Magento\Tax\Model\Config as TaxConfig;
19+
use Magento\Tax\Test\Fixture\TaxRate as TaxRateFixture;
20+
use Magento\Tax\Test\Fixture\TaxRule as TaxRuleFixture;
21+
use Magento\TestFramework\Fixture\Config as ConfigFixture;
22+
use Magento\TestFramework\Fixture\DataFixture;
23+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1524
use Magento\TestFramework\Helper\Bootstrap;
1625
use Magento\TestFramework\ObjectManager;
1726
use PHPUnit\Framework\TestCase;
@@ -242,6 +251,27 @@ private function assertAsLowAsPrice(string $priceHtml, float $expectedPrice): vo
242251
);
243252
}
244253

254+
/**
255+
* Assert that price html contain "As low as" label and expected price amount.
256+
*
257+
* @param string $priceHtml
258+
* @param float $expectedPriceWithTaxes
259+
* @param float $expectedPriceWithoutTaxes
260+
* @return void
261+
*/
262+
private function assertAsLowAsPriceWithTaxes(string $priceHtml, float $expectedPriceWithTaxes, float $expectedPriceWithoutTaxes): void
263+
{
264+
$this->assertMatchesRegularExpression(
265+
sprintf(
266+
'/<span class="price-label">As low as<\/span> (.)+<span.*data-price-amount="%s".*>\\$%01.2f<\/span>(.)+<span class="price">\$%01.2f<\/span>/',
267+
$expectedPriceWithTaxes,
268+
$expectedPriceWithTaxes,
269+
$expectedPriceWithoutTaxes
270+
),
271+
$priceHtml
272+
);
273+
}
274+
245275
/**
246276
* Assert that price html contain expected final price amount.
247277
*
@@ -307,4 +337,44 @@ private function getListProductBlock(): ListProduct
307337

308338
return $categoryProductsBlock->getChildBlock('product_list');
309339
}
340+
341+
#[
342+
ConfigFixture(TaxConfig::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, 0, 'store', 'default'),
343+
ConfigFixture(TaxConfig::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, 3, 'store', 'default'),
344+
DataFixture(
345+
TaxRateFixture::class,
346+
[],
347+
'rate'
348+
),
349+
DataFixture(
350+
TaxRuleFixture::class,
351+
[
352+
'customer_tax_class_ids' => [3],
353+
'product_tax_class_ids' => [2],
354+
'tax_rate_ids' => ['$rate.id$']
355+
],
356+
'rule'
357+
),
358+
DataFixture(CategoryFixture::class, as: 'category'),
359+
DataFixture(
360+
ProductFixture::class,
361+
[
362+
'sku' => 'simple-product-tax-both',
363+
'category_ids' => ['1', '$category.id$'],
364+
'tier_prices' => [
365+
[
366+
'customer_group_id' => Group::NOT_LOGGED_IN_ID,
367+
'qty' => 2,
368+
'value' => 5
369+
]
370+
]
371+
]
372+
)
373+
]
374+
public function testRenderAmountMinimalProductWithTierPricesShouldShowMinTierPriceWithTaxes()
375+
{
376+
$priceHtml = $this->getProductPriceHtml('simple-product-tax-both');
377+
$this->assertFinalPrice($priceHtml, 10.00);
378+
$this->assertAsLowAsPriceWithTaxes($priceHtml, 5.500001, 5.00);
379+
}
310380
}

dev/tests/integration/testsuite/Magento/Catalog/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,17 @@
66

77
namespace Magento\Catalog\Pricing\Render;
88

9-
use Magento\Catalog\Api\Data\ProductInterface;
10-
use Magento\Catalog\Api\ProductRepositoryInterface;
11-
use Magento\Catalog\Pricing\Price\FinalPrice;
12-
use Magento\Catalog\Test\Fixture\Category as CategoryFixture;
13-
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
14-
use Magento\Customer\Model\Group;
15-
use Magento\Framework\App\Area;
16-
use Magento\Framework\App\State;
9+
use Magento\TestFramework\Helper\Bootstrap;
1710
use Magento\Framework\ObjectManagerInterface;
18-
use Magento\Framework\Pricing\Render\Amount;
11+
use Magento\Catalog\Pricing\Price\FinalPrice;
1912
use Magento\Framework\Pricing\Render\RendererPool;
13+
use Magento\Catalog\Api\ProductRepositoryInterface;
14+
use Magento\Framework\Pricing\Render\Amount;
15+
use Magento\Framework\App\State;
16+
use Magento\Framework\App\Area;
2017
use Magento\Framework\View\TemplateEngine\Php;
2118
use Magento\Framework\View\TemplateEnginePool;
22-
use Magento\Tax\Helper\Data;
23-
use Magento\Tax\Model\Config as TaxConfig;
24-
use Magento\Tax\Test\Fixture\CustomerTaxClass as CustomerTaxClassFixture;
25-
use Magento\Tax\Test\Fixture\ProductTaxClass as ProductTaxClassFixture;
26-
use Magento\Tax\Test\Fixture\TaxRate as TaxRateFixture;
27-
use Magento\Tax\Test\Fixture\TaxRule as TaxRuleFixture;
28-
use Magento\TestFramework\Fixture\Config as ConfigFixture;
29-
use Magento\TestFramework\Fixture\DataFixture;
30-
use Magento\TestFramework\Helper\Bootstrap;
19+
use Magento\Catalog\Api\Data\ProductInterface;
3120

3221
/**
3322
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -108,7 +97,8 @@ protected function setUp(): void
10897

10998
$this->rendererPool->setData(
11099
[
111-
'default' => [
100+
'default' =>
101+
[
112102
'default_amount_render_class' => Amount::class,
113103
'default_amount_render_template' => 'Magento_Catalog::product/price/amount/default.phtml'
114104
]
@@ -157,43 +147,4 @@ public function testProductSetDifferentStorePricesWithoutTierPriceShouldNotShowA
157147
{
158148
$this->assertEmpty($this->finalPriceBox->renderAmountMinimal());
159149
}
160-
161-
#[
162-
ConfigFixture(TaxConfig::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, 0, 'store', 'default'),
163-
ConfigFixture(TaxConfig::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, 3, 'store', 'default'),
164-
DataFixture(
165-
TaxRateFixture::class,
166-
[],
167-
'rate'
168-
),
169-
DataFixture(
170-
TaxRuleFixture::class,
171-
[
172-
'customer_tax_class_ids' => [3],
173-
'product_tax_class_ids' => [2],
174-
'tax_rate_ids' => ['$rate.id$']
175-
],
176-
'rule'
177-
),
178-
DataFixture(CategoryFixture::class, as: 'category'),
179-
DataFixture(
180-
ProductFixture::class,
181-
[
182-
'sku' => 'tier_prices',
183-
'category_ids' => ['1', '$category.id$'],
184-
'tier_prices' => [
185-
[
186-
'customer_group_id' => Group::NOT_LOGGED_IN_ID,
187-
'qty' => 2,
188-
'value' => 5
189-
]
190-
]
191-
]
192-
)
193-
]
194-
public function testRenderAmountMinimalProductWithTierPricesShouldShowMinTierPriceWithTaxes()
195-
{
196-
$result = $this->finalPriceBox->renderAmountMinimal();
197-
$this->assertStringContainsString('$5.00', $result);
198-
}
199150
}

0 commit comments

Comments
 (0)