Skip to content

Commit aff93f9

Browse files
author
Sergey Semenov
committed
Merge remote-tracking branch 'origin/MAGETWO-65721' into MAGETWO-65721
2 parents 5b79455 + b7d447c commit aff93f9

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Widget\Test\Constraint;
8+
9+
use Magento\PageCache\Test\Page\Adminhtml\AdminCache;
10+
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11+
use Magento\Cms\Test\Page\CmsIndex;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
14+
use Magento\Mtf\Fixture\FixtureFactory;
15+
16+
/**
17+
* Check that created product appears in Catalog New Products List widget on frontend on Category Page.
18+
*/
19+
class AssertProductInCatalogNewProductsList extends AbstractConstraint
20+
{
21+
/**
22+
* Category Page on Frontend.
23+
*
24+
* @var CatalogCategoryView
25+
*/
26+
protected $catalogCategoryView;
27+
28+
/**
29+
* Assert that created product appears in Catalog New Products List widget on frontend on Category Page.
30+
*
31+
* @param CmsIndex $cmsIndex
32+
* @param CatalogCategoryView $catalogCategoryView
33+
* @param CatalogProductSimple $product
34+
* @param AdminCache $adminCache
35+
* @param FixtureFactory $fixtureFactory
36+
* @return void
37+
*/
38+
public function processAssert(
39+
CmsIndex $cmsIndex,
40+
CatalogCategoryView $catalogCategoryView,
41+
CatalogProductSimple $product,
42+
AdminCache $adminCache,
43+
FixtureFactory $fixtureFactory
44+
) {
45+
$this->catalogCategoryView = $catalogCategoryView;
46+
$widget = $fixtureFactory->createByCode('widget', ['dataset' => 'new_products_list_on_luma_theme']);
47+
$widget->persist();
48+
49+
// Flush cache
50+
$adminCache->open();
51+
$adminCache->getActionsBlock()->flushMagentoCache();
52+
$adminCache->getMessagesBlock()->waitSuccessMessage();
53+
54+
$cmsIndex->open();
55+
56+
\PHPUnit_Framework_Assert::assertContains(
57+
$product->getName(),
58+
$this->catalogCategoryView->getViewBlock()->getProductsFromCatalogNewProductsListBlock(),
59+
'Product is absent on Catalog New Products List block on Category page.'
60+
);
61+
}
62+
63+
/**
64+
* Returns a string representation of the object.
65+
*
66+
* @return string
67+
*/
68+
public function toString()
69+
{
70+
return "Product is present in Catalog New Products List widget on storefront Category page.";
71+
}
72+
}

dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Curl extends AbstractCurl
2828
'code' => [
2929
'CMS Page Link' => 'cms_page_link',
3030
'Recently Viewed Products' => 'recently_viewed',
31+
'Catalog New Products List' => 'new_products',
3132
],
3233
'block' => [
3334
'Main Content Area' => 'content',
@@ -42,10 +43,19 @@ class Curl extends AbstractCurl
4243
],
4344
'template' => [
4445
'CMS Page Link Block Template' => 'widget/link/link_block.phtml',
46+
'New Products List Template' => 'product/widget/new/content/new_grid.phtml',
4547
],
4648
'layout_handle' => [
4749
'Shopping Cart' => 'checkout_cart_index',
4850
],
51+
'display_type' => [
52+
'All products' => 'all_products',
53+
'New products' => 'new_products',
54+
],
55+
'show_pager' => [
56+
'No' => '0',
57+
'Yes' => '1',
58+
],
4959
];
5060

5161
/**

dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,20 @@
4040
<item name="dataset" xsi:type="string">recentlyViewedProducts</item>
4141
</field>
4242
</dataset>
43+
44+
<dataset name="new_products_list_on_luma_theme">
45+
<field name="code" xsi:type="string">Catalog New Products List</field>
46+
<field name="title" xsi:type="string">Title_%isolation%</field>
47+
<field name="theme_id" xsi:type="string">Magento Luma</field>
48+
<field name="store_ids" xsi:type="array">
49+
<item name="dataset" xsi:type="string">all_store_views</item>
50+
</field>
51+
<field name="widget_instance" xsi:type="array">
52+
<item name="dataset" xsi:type="string">for_new_products_all_pages</item>
53+
</field>
54+
<field name="parameters" xsi:type="array">
55+
<item name="dataset" xsi:type="string">catalogNewProductsListNewOnly</item>
56+
</field>
57+
</dataset>
4358
</repository>
4459
</config>

dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/Parameters.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,11 @@
5252
<dataset name="recentlyViewedProducts">
5353
<field name="page_size" xsi:type="string">4</field>
5454
</dataset>
55+
56+
<dataset name="catalogNewProductsListNewOnly">
57+
<field name="display_type" xsi:type="string">New products</field>
58+
<field name="show_pager" xsi:type="string">No</field>
59+
<field name="products_count" xsi:type="string">1</field>
60+
</dataset>
5561
</repository>
5662
</config>

dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/WidgetInstance.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,13 @@
7272
<item name="template" xsi:type="string">CMS Page Link Block Template</item>
7373
</field>
7474
</dataset>
75+
76+
<dataset name="for_new_products_all_pages">
77+
<field name="0" xsi:type="array">
78+
<item name="page_group" xsi:type="string">Generic Pages/All Pages</item>
79+
<item name="block" xsi:type="string">Main Content Area</item>
80+
<item name="template" xsi:type="string">New Products List Template</item>
81+
</field>
82+
</dataset>
7583
</repository>
7684
</config>

dev/tests/functional/tests/app/Magento/Widget/Test/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@
7676
<argument name="severity" xsi:type="string">S3</argument>
7777
</arguments>
7878
</type>
79+
<type name="Magento\Widget\Test\Constraint\AssertProductInCatalogNewProductsList">
80+
<arguments>
81+
<argument name="severity" xsi:type="string">S2</argument>
82+
</arguments>
83+
</type>
7984
</config>

0 commit comments

Comments
 (0)