Skip to content

Commit 5a04ed5

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MAGETWO-98584' into EPAM-PR-52
2 parents 5117399 + eb81913 commit 5a04ed5

File tree

39 files changed

+688
-59
lines changed

39 files changed

+688
-59
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminDashboardSection">
12+
<element name="dashboardDiagramContent" type="button" selector="#diagram_tab_content"/>
13+
<element name="dashboardDiagramOrderContentTab" type="block" selector="#diagram_tab_orders_content"/>
14+
<element name="dashboardDiagramAmounts" type="button" selector="#diagram_tab_amounts"/>
15+
<element name="dashboardDiagramAmountsContentTab" type="block" selector="#diagram_tab_amounts_content"/>
16+
<element name="dashboardDiagramTotals" type="text" selector="#diagram_tab_amounts_content"/>
17+
<element name="dashboardTotals" type="text" selector="//*[@class='dashboard-totals-label' and contains(text(), '{{columnName}}')]/../*[@class='dashboard-totals-value']" parameterized="true"/>
18+
</section>
19+
</sections>
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminDashboardWithChartsTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<title value="Google chart on Magento dashboard"/>
15+
<description value="Google chart on Magento dashboard page is not broken"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-98934"/>
18+
<useCaseId value="MAGETWO-98584"/>
19+
<group value="backend"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts" />
23+
<createData entity="SimpleProduct2" stepKey="createProduct">
24+
<field key="price">150</field>
25+
</createData>
26+
<createData entity="Simple_US_Customer" stepKey="createCustomer">
27+
<field key="firstname">John1</field>
28+
<field key="lastname">Doe1</field>
29+
</createData>
30+
</before>
31+
<after>
32+
<!-- Reset admin order filter -->
33+
<comment userInput="Reset admin order filter" stepKey="resetAdminOrderFilter"/>
34+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
35+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingOrderGrid"/>
36+
<magentoCLI command="config:set admin/dashboard/enable_charts 0" stepKey="setDisableChartsAsDefault" />
37+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
38+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
39+
<actionGroup ref="logout" stepKey="logout"/>
40+
</after>
41+
<!-- Login as admin -->
42+
<comment userInput="Login as admin" stepKey="adminLogin"/>
43+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
44+
<!-- Grab quantity value -->
45+
<comment userInput="Grab quantity value from dashboard" stepKey="grabQuantityFromDashboard"/>
46+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabStartQuantity"/>
47+
<!-- Login as customer -->
48+
<comment userInput="Login as customer" stepKey="loginAsCustomer"/>
49+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin">
50+
<argument name="Customer" value="$$createCustomer$$" />
51+
</actionGroup>
52+
<!-- Add Product to Shopping Cart-->
53+
<comment userInput="Add product to the shopping cart" stepKey="addProductToCart"/>
54+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="navigateToSimpleProductPage"/>
55+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
56+
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage">
57+
<argument name="productName" value="$$createProduct.name$$"/>
58+
</actionGroup>
59+
<!--Go to Checkout-->
60+
<comment userInput="Go to checkout" stepKey="goToCheckout"/>
61+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
62+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingCheckoutPageWithShippingMethod"/>
63+
<click selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
64+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask1"/>
65+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/>
66+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
67+
<!-- Checkout select Check/Money Order payment -->
68+
<comment userInput="Select Check/Money payment" stepKey="checkoutSelectCheckMoneyPayment"/>
69+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/>
70+
<!-- Place Order -->
71+
<comment userInput="Place order" stepKey="placeOrder"/>
72+
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder"/>
73+
<see selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="seeSuccessTitle"/>
74+
<see selector="{{CheckoutSuccessMainSection.orderNumberText}}" userInput="Your order number is: " stepKey="seeOrderNumber"/>
75+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderNumber"/>
76+
<!-- Search for Order in the order grid -->
77+
<comment userInput="Search for Order in the order grid" stepKey="searchOrderInGrid"/>
78+
<actionGroup ref="filterOrderGridById" stepKey="filterOrderGridById">
79+
<argument name="orderId" value="$grabOrderNumber"/>
80+
</actionGroup>
81+
<waitForLoadingMaskToDisappear stepKey="waitForSearchingOrder"/>
82+
<!-- Create invoice -->
83+
<comment userInput="Create invoice" stepKey="createInvoice"/>
84+
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
85+
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/>
86+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/>
87+
<see selector="{{AdminInvoiceTotalSection.total('Subtotal')}}" userInput="$150.00" stepKey="seeCorrectGrandTotal"/>
88+
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/>
89+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeSuccessInvoiceMessage"/>
90+
<!--Create Shipment for the order-->
91+
<comment userInput="Create Shipment for the order" stepKey="createShipmentForOrder"/>
92+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage2"/>
93+
<waitForPageLoad time="30" stepKey="waitForOrderListPageLoading"/>
94+
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="openOrderPageForShip"/>
95+
<waitForPageLoad stepKey="waitForOrderDetailsPage"/>
96+
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/>
97+
<waitForPageLoad stepKey="waitForShipmentPagePage"/>
98+
<seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl"/>
99+
<!--Submit Shipment-->
100+
<comment userInput="Submit Shipment" stepKey="submitShipment"/>
101+
<click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment"/>
102+
<waitForPageLoad stepKey="waitForShipmentSubmit"/>
103+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The shipment has been created." stepKey="seeShipmentCreateSuccess"/>
104+
<!-- Go to dashboard page -->
105+
<comment userInput="Go to dashboard page" stepKey="goToDashboardPage"/>
106+
<amOnPage url="{{AdminDashboardPage.url}}" stepKey="amOnDashboardPage"/>
107+
<waitForPageLoad stepKey="waitForDashboardPageLoad4"/>
108+
<!-- Grab quantity value -->
109+
<comment userInput="Grab quantity value from dashboard at the end" stepKey="grabQuantityFromDashboardAtTheEnd"/>
110+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabEndQuantity"/>
111+
<!-- Assert that page is not broken -->
112+
<comment userInput="Assert that dashboard page is not broken" stepKey="assertDashboardPageIsNotBroken"/>
113+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramOrderContentTab}}" stepKey="seeOrderContentTab"/>
114+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramContent}}" stepKey="seeDiagramContent"/>
115+
<click selector="{{AdminDashboardSection.dashboardDiagramAmounts}}" stepKey="clickDashboardAmount"/>
116+
<waitForLoadingMaskToDisappear stepKey="waitForDashboardAmountLoading"/>
117+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramAmountsContentTab}}" stepKey="seeDiagramAmountContent"/>
118+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramTotals}}" stepKey="seeAmountTotals"/>
119+
<dontSeeJsError stepKey="dontSeeJsError"/>
120+
<assertGreaterThan expected="$grabStartQuantity" actual="$grabEndQuantity" stepKey="checkQuantityWasChanged"/>
121+
</test>
122+
</tests>

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use Magento\Catalog\Api\Data\ProductInterface;
99
use Magento\Catalog\Model\Product;
1010
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\CatalogSearch\Model\Search\FilterMapper\VisibilityFilter;
1112
use Magento\CatalogSearch\Model\Search\TableMapper;
13+
use Magento\Customer\Model\Session;
1214
use Magento\Eav\Model\Config;
1315
use Magento\Framework\App\Config\ScopeConfigInterface;
1416
use Magento\Framework\App\ObjectManager;
@@ -20,10 +22,11 @@
2022
use Magento\Framework\Search\Adapter\Mysql\Filter\PreprocessorInterface;
2123
use Magento\Framework\Search\Request\FilterInterface;
2224
use Magento\Store\Model\Store;
23-
use Magento\Customer\Model\Session;
24-
use Magento\CatalogSearch\Model\Search\FilterMapper\VisibilityFilter;
2525

2626
/**
27+
* ElasticSearch search filter pre-processor.
28+
*
29+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2730
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2831
* @deprecated
2932
* @see \Magento\ElasticSearch
@@ -128,18 +131,21 @@ public function __construct(
128131
}
129132

130133
/**
131-
* {@inheritdoc}
134+
* @inheritdoc
132135
*/
133136
public function process(FilterInterface $filter, $isNegation, $query)
134137
{
135138
return $this->processQueryWithField($filter, $isNegation, $query);
136139
}
137140

138141
/**
142+
* Process query with field.
143+
*
139144
* @param FilterInterface $filter
140145
* @param bool $isNegation
141146
* @param string $query
142147
* @return string
148+
* @throws \Magento\Framework\Exception\LocalizedException
143149
*/
144150
private function processQueryWithField(FilterInterface $filter, $isNegation, $query)
145151
{
@@ -170,7 +176,7 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
170176
} elseif ($filter->getField() === VisibilityFilter::VISIBILITY_FILTER_FIELD) {
171177
return '';
172178
} elseif ($filter->getType() === FilterInterface::TYPE_TERM &&
173-
in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)
179+
in_array($attribute->getFrontendInput(), ['select', 'multiselect', 'boolean'], true)
174180
) {
175181
$resultQuery = $this->processTermSelect($filter, $isNegation);
176182
} elseif ($filter->getType() === FilterInterface::TYPE_RANGE &&
@@ -204,19 +210,23 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
204210
->where('main_table.store_id = ?', Store::DEFAULT_STORE_ID)
205211
->having($query);
206212

207-
$resultQuery = 'search_index.entity_id IN (
208-
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
209-
)';
213+
$resultQuery = 'search_index.entity_id IN ('
214+
. 'select entity_id from '
215+
. $this->conditionManager->wrapBrackets($select)
216+
. ' as filter)';
210217
}
211218

212219
return $resultQuery;
213220
}
214221

215222
/**
223+
* Process range numeric.
224+
*
216225
* @param FilterInterface $filter
217226
* @param string $query
218227
* @param Attribute $attribute
219228
* @return string
229+
* @throws \Exception
220230
*/
221231
private function processRangeNumeric(FilterInterface $filter, $query, $attribute)
222232
{
@@ -238,14 +248,17 @@ private function processRangeNumeric(FilterInterface $filter, $query, $attribute
238248
->where('main_table.store_id = ?', $currentStoreId)
239249
->having($query);
240250

241-
$resultQuery = 'search_index.entity_id IN (
242-
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
243-
)';
251+
$resultQuery = 'search_index.entity_id IN ('
252+
. 'select entity_id from '
253+
. $this->conditionManager->wrapBrackets($select)
254+
. ' as filter)';
244255

245256
return $resultQuery;
246257
}
247258

248259
/**
260+
* Process term select.
261+
*
249262
* @param FilterInterface $filter
250263
* @param bool $isNegation
251264
* @return string

app/code/Magento/CatalogSearch/Model/Search/CustomAttributeFilterCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function isCustom(FilterInterface $filter)
4444

4545
return $attribute
4646
&& $filter->getType() === FilterInterface::TYPE_TERM
47-
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true);
47+
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect', 'boolean'], true);
4848
}
4949

5050
/**

app/code/Magento/Downloadable/Model/SampleRepository.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* Class SampleRepository
26+
*
2627
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2728
*/
2829
class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInterface
@@ -100,7 +101,7 @@ public function __construct(
100101
}
101102

102103
/**
103-
* {@inheritdoc}
104+
* @inheritdoc
104105
*/
105106
public function getList($sku)
106107
{
@@ -209,6 +210,8 @@ public function save(
209210
}
210211

211212
/**
213+
* Save sample.
214+
*
212215
* @param \Magento\Catalog\Api\Data\ProductInterface $product
213216
* @param SampleInterface $sample
214217
* @param bool $isGlobalScopeContent
@@ -257,6 +260,8 @@ protected function saveSample(
257260
}
258261

259262
/**
263+
* Update sample.
264+
*
260265
* @param \Magento\Catalog\Api\Data\ProductInterface $product
261266
* @param SampleInterface $sample
262267
* @param bool $isGlobalScopeContent
@@ -308,15 +313,18 @@ protected function updateSample(
308313
$existingSample->setTitle($sample->getTitle());
309314
}
310315

311-
if ($sample->getSampleType() === 'file' && $sample->getSampleFileContent() === null) {
312-
$sample->setSampleFile($existingSample->getSampleFile());
316+
if ($sample->getSampleType() === 'file'
317+
&& $sample->getSampleFileContent() === null
318+
&& $sample->getSampleFile() !== null
319+
) {
320+
$existingSample->setSampleFile($sample->getSampleFile());
313321
}
314322
$this->saveSample($product, $sample, $isGlobalScopeContent);
315323
return $existingSample->getId();
316324
}
317325

318326
/**
319-
* {@inheritdoc}
327+
* @inheritdoc
320328
*/
321329
public function delete($id)
322330
{

app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Eav\Model\Entity\Attribute\Source;
78

89
/**
910
* Entity/Attribute/Model - attribute selection source abstract
10-
*
11+
* phpcs:disable Magento2.Classes.AbstractApi
1112
* @api
1213
* @author Magento Core Team <[email protected]>
1314
* @SuppressWarnings(PHPMD.NumberOfChildren)
@@ -65,7 +66,7 @@ public function getOptionText($value)
6566
{
6667
$options = $this->getAllOptions();
6768
// Fixed for tax_class_id and custom_design
68-
if (sizeof($options) > 0) {
69+
if (count($options) > 0) {
6970
foreach ($options as $option) {
7071
if (isset($option['value']) && $option['value'] == $value) {
7172
return isset($option['label']) ? $option['label'] : $option['value'];
@@ -88,7 +89,7 @@ public function getOptionText($value)
8889
public function getOptionId($value)
8990
{
9091
foreach ($this->getAllOptions() as $option) {
91-
if (strcasecmp($option['label'], $value) == 0 || $option['value'] == $value) {
92+
if ($this->mbStrcasecmp($option['label'], $value) == 0 || $option['value'] == $value) {
9293
return $option['value'];
9394
}
9495
}
@@ -166,4 +167,20 @@ public function toOptionArray()
166167
{
167168
return $this->getAllOptions();
168169
}
170+
171+
/**
172+
* Multibyte support strcasecmp function version.
173+
*
174+
* @param string $str1
175+
* @param string $str2
176+
* @return int
177+
*/
178+
private function mbStrcasecmp($str1, $str2)
179+
{
180+
$encoding = mb_internal_encoding();
181+
return strcmp(
182+
mb_strtoupper($str1, $encoding),
183+
mb_strtoupper($str2, $encoding)
184+
);
185+
}
169186
}

0 commit comments

Comments
 (0)