Skip to content

Commit 9495a67

Browse files
author
Sergey Shvets
committed
Merge remote-tracking branch 'origin/MAGETWO-64924' into chaika-pr1
2 parents 1e30e42 + 4365529 commit 9495a67

File tree

7 files changed

+119
-2
lines changed

7 files changed

+119
-2
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 © 2013-2017 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
@@ -27,6 +27,7 @@ class Curl extends AbstractCurl
2727
protected $mappingData = [
2828
'code' => [
2929
'CMS Page Link' => 'cms_page_link',
30+
'Catalog New Products List' => 'new_products',
3031
],
3132
'block' => [
3233
'Main Content Area' => 'content',
@@ -41,10 +42,19 @@ class Curl extends AbstractCurl
4142
],
4243
'template' => [
4344
'CMS Page Link Block Template' => 'widget/link/link_block.phtml',
45+
'New Products List Template' => 'product/widget/new/content/new_grid.phtml',
4446
],
4547
'layout_handle' => [
4648
'Shopping Cart' => 'checkout_cart_index',
4749
],
50+
'display_type' => [
51+
'All products' => 'all_products',
52+
'New products' => 'new_products',
53+
],
54+
'show_pager' => [
55+
'No' => '0',
56+
'Yes' => '1',
57+
],
4858
];
4959

5060
/**

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
@@ -25,5 +25,20 @@
2525
<item name="dataset" xsi:type="string">cmsPageLink</item>
2626
</field>
2727
</dataset>
28+
29+
<dataset name="new_products_list_on_luma_theme">
30+
<field name="code" xsi:type="string">Catalog New Products List</field>
31+
<field name="title" xsi:type="string">Title_%isolation%</field>
32+
<field name="theme_id" xsi:type="string">Magento Luma</field>
33+
<field name="store_ids" xsi:type="array">
34+
<item name="dataset" xsi:type="string">all_store_views</item>
35+
</field>
36+
<field name="widget_instance" xsi:type="array">
37+
<item name="dataset" xsi:type="string">for_new_products_all_pages</item>
38+
</field>
39+
<field name="parameters" xsi:type="array">
40+
<item name="dataset" xsi:type="string">catalogNewProductsListNewOnly</item>
41+
</field>
42+
</dataset>
2843
</repository>
2944
</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
@@ -62,5 +62,13 @@
6262
<item name="template" xsi:type="string">CMS Page Link Block Template</item>
6363
</field>
6464
</dataset>
65+
66+
<dataset name="for_new_products_all_pages">
67+
<field name="0" xsi:type="array">
68+
<item name="page_group" xsi:type="string">Generic Pages/All Pages</item>
69+
<item name="block" xsi:type="string">Main Content Area</item>
70+
<item name="template" xsi:type="string">New Products List Template</item>
71+
</field>
72+
</dataset>
6573
</repository>
6674
</config>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<preference for="Magento\Widget\Test\Handler\Widget\WidgetInterface" type="\Magento\Widget\Test\Handler\Widget\Curl" />
10+
11+
<type name="Magento\Widget\Test\Constraint\AssertProductInCatalogNewProductsList">
12+
<arguments>
13+
<argument name="severity" xsi:type="string">S2</argument>
14+
</arguments>
15+
</type>
1016
</config>

dev/tests/integration/testsuite/Magento/Catalog/_files/products_new.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
/** @var $product \Magento\Catalog\Model\Product */
8-
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Product');
8+
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
99
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
1010
->setAttributeSetId(4)
1111
->setName('New Product')
@@ -15,7 +15,7 @@
1515
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
1616
->setWebsiteIds([1])
1717
->setStockData(['qty' => 100, 'is_in_stock' => 1])
18-
->setNewsFromDate(date('Y-m-d', strtotime('-2 day')))
18+
->setNewsToDate(date('Y-m-d', strtotime('+2 day')))
1919
->setNewsNewsToDate(date('Y-m-d', strtotime('+2 day')))
2020
->setDescription('description')
2121
->setShortDescription('short desc')

0 commit comments

Comments
 (0)