Skip to content

Commit 2f08a3c

Browse files
committed
MAGETWO-47017: [Github] Add Configurable Product To Cart from Category Page #2574 #5850 #5882 #6572 #5558 #4184
1 parent 30883ea commit 2f08a3c

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Swatches\Test\Constraint;
7+
8+
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Mtf\Fixture\FixtureInterface;
11+
12+
/**
13+
* Assert product price is correct when swatches are selected on category page
14+
*/
15+
class AssertProductPriceWithSelectedSwatchOnCategoryPage extends AbstractConstraint
16+
{
17+
/**
18+
* @param CatalogCategoryView $catalogCategoryView
19+
* @param FixtureInterface $product
20+
* @return void
21+
*/
22+
public function processAssert(
23+
CatalogCategoryView $catalogCategoryView,
24+
FixtureInterface $product
25+
) {
26+
$priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock();
27+
$configuredPrice = $product->getCheckoutData()['cartItem']['subtotal'];
28+
\PHPUnit_Framework_Assert::assertEquals(
29+
number_format($configuredPrice, 2, '.', ''),
30+
$priceBlock->getPrice(),
31+
'Product configured price on category page is not correct.'
32+
);
33+
}
34+
35+
/**
36+
* Returns a string representation of the object
37+
*
38+
* @return string
39+
*/
40+
public function toString()
41+
{
42+
return 'Price with selected swatches is correct.';
43+
}
44+
}

dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<field name="cartItem" xsi:type="array">
2525
<item name="price" xsi:type="string">42</item>
2626
<item name="qty" xsi:type="string">1</item>
27-
<item name="subtotal" xsi:type="string">47</item>
27+
<item name="subtotal" xsi:type="string">48</item>
2828
</field>
2929
</dataset>
3030
<dataset name="swatches_with_dropdown">

dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShoppingCartTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<data name="attributeTypeAction" xsi:type="string">addOptions</data>
1212
<data name="product/dataset" xsi:type="string">product_with_text_swatch</data>
1313
<data name="addToCart" xsi:type="boolean">true</data>
14+
<constraint name="Magento\Swatches\Test\Constraint\AssertProductPriceWithSelectedSwatchOnCategoryPage" />
1415
<constraint name="Magento\Checkout\Test\Constraint\AssertCartItemsOptions" />
1516
</variation>
1617
<variation name="AddConfigurableProductWithSwatchToShoppingCartTest2" summary="Add configurable product to cart with mixed option types" ticketId="MAGETWO-59979">

0 commit comments

Comments
 (0)