Skip to content

Commit 06d8348

Browse files
MTO-145: [Constraint] Check order grid date filter
- Defects fixed.
1 parent d57238c commit 06d8348

File tree

9 files changed

+178
-166
lines changed

9 files changed

+178
-166
lines changed

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/GetDashboardOrderStep.php renamed to dev/tests/functional/tests/app/Magento/Backend/Test/TestStep/GetDashboardOrderStep.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Checkout\Test\TestStep;
7+
namespace Magento\Backend\Test\TestStep;
88

99
use Magento\Mtf\TestStep\TestStepInterface;
1010
use Magento\Backend\Test\Page\Adminhtml\Dashboard;

dev/tests/functional/tests/app/Magento/Reports/Test/Repository/ConfigData.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,5 @@
4848
<item name="value" xsi:type="number">2</item>
4949
</field>
5050
</dataset>
51-
52-
<dataset name="notify_stock_quantity_2_rollback">
53-
<field name="cataloginventory/item_options/notify_stock_qty" xsi:type="array">
54-
<item name="scope" xsi:type="string">catalog</item>
55-
<item name="scope_id" xsi:type="number">1</item>
56-
<item name="label" xsi:type="string"/>
57-
<item name="value" xsi:type="number">1</item>
58-
</field>
59-
</dataset>
6051
</repository>
6152
</config>

dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/LowStockProductsReportEntityTest.php

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
namespace Magento\Reports\Test\TestCase;
88

9-
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
10-
use Magento\Mtf\TestCase\Injectable;
9+
use Magento\Mtf\TestCase\Scenario;
1110

1211
/**
1312
* Preconditions:
@@ -21,53 +20,19 @@
2120
* @group Reports
2221
* @ZephyrId MAGETWO-27193
2322
*/
24-
class LowStockProductsReportEntityTest extends Injectable
23+
class LowStockProductsReportEntityTest extends Scenario
2524
{
2625
/* tags */
2726
const MVP = 'no';
2827
/* end tags */
2928

3029
/**
31-
* Configuration data
32-
*
33-
* @var string
34-
*/
35-
private $configData;
36-
37-
/**
38-
* Create product
39-
*
40-
* @param CatalogProductSimple $product
41-
* @param string|null $configData
42-
* @return void
43-
*/
44-
public function test(CatalogProductSimple $product, $configData = null)
45-
{
46-
$this->configData = $configData;
47-
48-
if ($this->configData) {
49-
$this->objectManager->create(
50-
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
51-
['configData' => $this->configData, 'flushCache' => true]
52-
)->run();
53-
}
54-
55-
// Preconditions
56-
$product->persist();
57-
}
58-
59-
/**
60-
* Clear data after test.
30+
* Runs low stock products report test.
6131
*
6232
* @return void
6333
*/
64-
public function tearDown()
34+
public function test()
6535
{
66-
if ($this->configData) {
67-
$this->objectManager->create(
68-
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
69-
['configData' => $this->configData, 'rollback' => true, 'flushCache' => true]
70-
)->run();
71-
}
36+
$this->executeScenario();
7237
}
7338
}

dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/LowStockProductsReportEntityTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<testCase name="Magento\Reports\Test\TestCase\LowStockProductsReportEntityTest" summary="Generate &quot;Low Stock Products&quot; Report" ticketId="MAGETWO-27193">
1010
<variation name="LowStockProductsReportEntityTestVariation1" summary="Generate Low Stock Products Report and Set Notify for Quantity Below = 2" ticketId="MAGETWO-52213">
1111
<data name="issue" xsi:type="string">MAGETWO-62279: Low stock products report doesn't work</data>
12-
<data name="product/dataset" xsi:type="string">low_stock_product</data>
12+
<data name="product" xsi:type="string">catalogProductSimple::low_stock_product</data>
1313
<data name="configData" xsi:type="string">notify_stock_quantity_2</data>
14+
<data name="flushCache" xsi:type="boolean">true</data>
1415
<constraint name="Magento\Reports\Test\Constraint\AssertLowStockProductInGrid" />
1516
</variation>
1617
</testCase>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd">
9+
<scenario name="LowStockProductsReportEntityTest" firstStep="setupConfiguration">
10+
<step name="setupConfiguration" module="Magento_Config" next="createProduct" />
11+
<step name="createProduct" module="Magento_Catalog" />
12+
</scenario>
13+
</config>

dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertInvoicedOrderOnDashboard.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,38 @@
88

99
use Magento\Mtf\Constraint\AbstractConstraint;
1010
use Magento\Mtf\TestStep\TestStepFactory;
11-
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
1211

1312
/**
1413
* Assert invoiced order on admin dashboard.
1514
*/
1615
class AssertInvoicedOrderOnDashboard extends AbstractConstraint
1716
{
1817
/**
19-
* Invoiced orders quantity.
20-
*/
21-
const EXPECTED_ORDERS_QTY = 1;
22-
23-
/**
24-
* Assert orders quantity and graph image visibility on admin dashboard.
18+
* Assert orders quantity on admin dashboard.
2519
*
2620
* @param TestStepFactory $stepFactory
27-
* @param Dashboard $dashboard
2821
* @param array $dashboardOrder
2922
* @param array $argumentsList
23+
* @param int $expectedOrdersQuantityOnDashboard
3024
* @return void
3125
*/
3226
public function processAssert(
3327
TestStepFactory $stepFactory,
34-
Dashboard $dashboard,
3528
array $dashboardOrder,
36-
array $argumentsList
29+
array $argumentsList,
30+
$expectedOrdersQuantityOnDashboard
3731
) {
3832
$orderQty = $stepFactory->create(
39-
\Magento\Checkout\Test\TestStep\GetDashboardOrderStep::class,
33+
\Magento\Backend\Test\TestStep\GetDashboardOrderStep::class,
4034
['argumentsList' => $argumentsList]
4135
)->run()['dashboardOrder']['quantity'];
4236
$invoicedOrdersQty = $orderQty - $dashboardOrder['quantity'];
4337

4438
\PHPUnit_Framework_Assert::assertEquals(
4539
$invoicedOrdersQty,
46-
self::EXPECTED_ORDERS_QTY,
40+
$expectedOrdersQuantityOnDashboard,
4741
'Order quantity om admin dashboard is not correct.'
4842
);
49-
50-
\PHPUnit_Framework_Assert::assertTrue(
51-
$dashboard->getMainBlock()->isGraphImageVisible(),
52-
'Graph image is not visible on admin dashboard.'
53-
);
5443
}
5544

5645
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Mtf\TestStep\TestStepFactory;
11+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
12+
13+
/**
14+
* Assert order graph image is visible on admin dashboard.
15+
*/
16+
class AssertOrderGraphImageIsVisible extends AbstractConstraint
17+
{
18+
/**
19+
* Assert order graph image is visible on admin dashboard.
20+
*
21+
* @param TestStepFactory $stepFactory
22+
* @param Dashboard $dashboard
23+
* @param array $argumentsList
24+
* @return void
25+
*/
26+
public function processAssert(
27+
TestStepFactory $stepFactory,
28+
Dashboard $dashboard,
29+
array $argumentsList
30+
) {
31+
$stepFactory->create(
32+
\Magento\Backend\Test\TestStep\GetDashboardOrderStep::class,
33+
['argumentsList' => $argumentsList]
34+
)->run();
35+
36+
\PHPUnit_Framework_Assert::assertTrue(
37+
$dashboard->getMainBlock()->isGraphImageVisible(),
38+
'Graph image is not visible on admin dashboard.'
39+
);
40+
}
41+
42+
/**
43+
* Returns string representation of successful assertion.
44+
*
45+
* @return string
46+
*/
47+
public function toString()
48+
{
49+
return 'Order graph image is visible on the dashboard.';
50+
}
51+
}

0 commit comments

Comments
 (0)