Skip to content

Commit e8b5bf0

Browse files
committed
MTA-4096: Ignore functional test failures caused by Magento issues
- merge develop
2 parents b99cd70 + 7599c36 commit e8b5bf0

29 files changed

+405
-486
lines changed

app/code/Magento/Catalog/Model/ProductIdLocator.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88

99
/**
1010
* Product ID locator provides all product IDs by SKUs.
11-
* @api
1211
*/
1312
class ProductIdLocator implements \Magento\Catalog\Model\ProductIdLocatorInterface
1413
{
14+
/**
15+
* Limit values for array IDs by SKU.
16+
*
17+
* @var int
18+
*/
19+
private $idsLimit;
20+
1521
/**
1622
* Metadata pool.
1723
*
@@ -34,13 +40,16 @@ class ProductIdLocator implements \Magento\Catalog\Model\ProductIdLocatorInterfa
3440
/**
3541
* @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
3642
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory
43+
* @param string $limitIdsBySkuValues
3744
*/
3845
public function __construct(
3946
\Magento\Framework\EntityManager\MetadataPool $metadataPool,
40-
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory
47+
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory,
48+
$idsLimit
4149
) {
4250
$this->metadataPool = $metadataPool;
4351
$this->collectionFactory = $collectionFactory;
52+
$this->idsLimit = (int)$idsLimit;
4453
}
4554

4655
/**
@@ -75,7 +84,19 @@ public function retrieveProductIdsBySkus(array $skus)
7584
$productIds[$sku] = $this->idsBySku[$unifiedSku];
7685
}
7786
}
78-
87+
$this->truncateToLimit();
7988
return $productIds;
8089
}
90+
91+
/**
92+
* Cleanup IDs by SKU cache more than some limit.
93+
*
94+
* @return void
95+
*/
96+
private function truncateToLimit()
97+
{
98+
if (count($this->idsBySku) > $this->idsLimit) {
99+
$this->idsBySku = array_slice($this->idsBySku, round($this->idsLimit / -2));
100+
}
101+
}
81102
}

app/code/Magento/Catalog/Model/ProductIdLocatorInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* Product ID locator provides all product IDs by SKU.
10+
* @api
1011
*/
1112
interface ProductIdLocatorInterface
1213
{

app/code/Magento/Catalog/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@
157157
<argument name="perPageValues" xsi:type="string">9,15,30</argument>
158158
</arguments>
159159
</type>
160+
<type name="Magento\Catalog\Model\ProductIdLocator">
161+
<arguments>
162+
<argument name="idsLimit" xsi:type="number">1000</argument>
163+
</arguments>
164+
</type>
160165
<type name="Magento\Catalog\Model\Config\Source\ListPerPage">
161166
<arguments>
162167
<argument name="options" xsi:type="string">5,10,15,20,25</argument>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Test\Constraint;
7+
8+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
11+
/**
12+
* Verify that admin user chose to accept subscription in Analytics pop-up.
13+
*/
14+
class AssertAcceptSubscriptionPopup extends AbstractConstraint
15+
{
16+
/**
17+
* Verify that admin user chose to accept subscription in Analytics pop-up.
18+
*
19+
* @param Dashboard $dashboard
20+
* @return void
21+
*/
22+
public function processAssert(Dashboard $dashboard)
23+
{
24+
$dashboard->open();
25+
$dashboard->getSubscriptionBlock()->enableCheckbox();
26+
$dashboard->getModalBlock()->acceptWarning();
27+
\PHPUnit_Framework_Assert::assertFalse(
28+
$dashboard->getSubscriptionBlock()->isVisible(),
29+
'Subscription pop-up was not accepted'
30+
);
31+
}
32+
33+
/**
34+
* Returns a string representation of the object.
35+
*
36+
* @return string
37+
*/
38+
public function toString()
39+
{
40+
return 'Subscription pop-up was accepted';
41+
}
42+
}

dev/tests/functional/tests/app/Magento/Analytics/Test/Constraint/AssertConfigAnalyticsDisabled.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Mtf\Constraint\AbstractConstraint;
99
use Magento\Analytics\Test\Page\Adminhtml\ConfigAnalytics;
10+
use Magento\Analytics\Test\TestStep\OpenAnalyticsConfigStep;
1011

1112
/**
1213
* Assert Analytics is disabled in Stores>Configuration>General>Analytics->General menu.
@@ -17,13 +18,21 @@ class AssertConfigAnalyticsDisabled extends AbstractConstraint
1718
* Assert Analytics is disabled in Stores > Configuration > General > Analytics menu.
1819
*
1920
* @param ConfigAnalytics $configAnalytics
21+
* @param OpenAnalyticsConfigStep $openAnalyticsConfigStep
2022
* @return void
2123
*/
22-
public function processAssert(ConfigAnalytics $configAnalytics)
24+
public function processAssert(ConfigAnalytics $configAnalytics, OpenAnalyticsConfigStep $openAnalyticsConfigStep)
2325
{
26+
$openAnalyticsConfigStep->run();
27+
2428
\PHPUnit_Framework_Assert::assertFalse(
2529
(bool)$configAnalytics->getAnalyticsForm()->isAnalyticsEnabled(),
26-
'Magento Analytics is enabled'
30+
'Magento Analytics is not disabled.'
31+
);
32+
\PHPUnit_Framework_Assert::assertEquals(
33+
$configAnalytics->getAnalyticsForm()->getAnalyticsStatus(),
34+
'Subscription status: Disabled',
35+
'Magento Analytics status is not disabled.'
2736
);
2837
}
2938

@@ -34,6 +43,7 @@ public function processAssert(ConfigAnalytics $configAnalytics)
3443
*/
3544
public function toString()
3645
{
37-
return 'Magento Analytics is disabled in Stores > Configuration > General > Analytics > General menu.';
46+
return 'Magento Analytics is disabled in Stores > Configuration > General > Analytics > General menu'
47+
. ' and has Disabled status.';
3848
}
3949
}

dev/tests/functional/tests/app/Magento/Analytics/Test/Constraint/AssertConfigAnalyticsEnabled.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Mtf\Constraint\AbstractConstraint;
99
use Magento\Analytics\Test\Page\Adminhtml\ConfigAnalytics;
10+
use Magento\Analytics\Test\TestStep\OpenAnalyticsConfigStep;
1011

1112
/**
1213
* Assert Analytics is enabled in Stores > Configuration > General > Analytics > General menu.
@@ -15,13 +16,24 @@ class AssertConfigAnalyticsEnabled extends AbstractConstraint
1516
{
1617
/**
1718
* Assert Analytics is enabled in Stores > Configuration > General > Analytics menu.
19+
*
1820
* @param ConfigAnalytics $configAnalytics
21+
* @param OpenAnalyticsConfigStep $openAnalyticsConfigStep
22+
* @return void
1923
*/
20-
public function processAssert(ConfigAnalytics $configAnalytics)
24+
public function processAssert(ConfigAnalytics $configAnalytics, OpenAnalyticsConfigStep $openAnalyticsConfigStep)
2125
{
26+
$openAnalyticsConfigStep->run();
27+
2228
\PHPUnit_Framework_Assert::assertTrue(
2329
(bool)$configAnalytics->getAnalyticsForm()->isAnalyticsEnabled(),
24-
'Magento Analytics is disabled'
30+
'Magento Analytics is not enabled.'
31+
);
32+
33+
\PHPUnit_Framework_Assert::assertEquals(
34+
$configAnalytics->getAnalyticsForm()->getAnalyticsStatus(),
35+
'Subscription status: Pending',
36+
'Magento Analytics status is not pending.'
2537
);
2638
}
2739

@@ -32,6 +44,7 @@ public function processAssert(ConfigAnalytics $configAnalytics)
3244
*/
3345
public function toString()
3446
{
35-
return 'Magento Analytics is enabled in Stores > Configuration > General > Analytics > General menu.';
47+
return 'Magento Analytics is enabled and has Pending status in'
48+
. ' Stores > Configuration > General > Analytics > General menu.';
3649
}
3750
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Test\Constraint;
7+
8+
use Magento\Mtf\Constraint\AbstractConstraint;
9+
use Magento\Analytics\Test\Page\Adminhtml\ConfigAnalytics;
10+
use Magento\Analytics\Test\TestStep\OpenAnalyticsConfigStep;
11+
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
12+
13+
/**
14+
* Assert sending data to the Analytics is restored.
15+
*/
16+
class AssertConfigAnalyticsRestored extends AbstractConstraint
17+
{
18+
/**
19+
* Assert sending data to the Analytics is restored.
20+
*
21+
* @param ConfigAnalytics $configAnalytics
22+
* @param OpenAnalyticsConfigStep $openAnalyticsConfigStep
23+
* @param SystemConfigEdit $systemConfigPage
24+
* @param string $vertical
25+
* @return void
26+
*/
27+
public function processAssert(
28+
ConfigAnalytics $configAnalytics,
29+
OpenAnalyticsConfigStep $openAnalyticsConfigStep,
30+
SystemConfigEdit $systemConfigPage,
31+
$vertical
32+
) {
33+
$openAnalyticsConfigStep->run();
34+
35+
$configAnalytics->getAnalyticsForm()->enableAnalytics();
36+
$configAnalytics->getAnalyticsForm()->setAnalyticsVertical($vertical);
37+
$configAnalytics->getAnalyticsForm()->saveConfig();
38+
39+
\PHPUnit_Framework_Assert::assertTrue(
40+
$systemConfigPage->getMessagesBlock()->assertSuccessMessage(),
41+
'Sending data to the Analytics is not saved.'
42+
);
43+
}
44+
45+
/**
46+
* Returns a string representation of the object.
47+
*
48+
* @return string
49+
*/
50+
public function toString()
51+
{
52+
return 'Sending data to the Analytics is saved.';
53+
}
54+
}

dev/tests/functional/tests/app/Magento/Analytics/Test/Constraint/AssertConfigAnalyticsStatusDisabled.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

dev/tests/functional/tests/app/Magento/Analytics/Test/Constraint/AssertConfigAnalyticsStatusPending.php

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Test\Constraint;
7+
8+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
11+
/**
12+
* Verify that admin user chose to decline subscription in Analytics pop-up.
13+
*/
14+
class AssertDeclineSubscriptionPopup extends AbstractConstraint
15+
{
16+
/**
17+
* Verify that admin user chose to decline subscription in Analytics pop-up.
18+
*
19+
* @param Dashboard $dashboard
20+
* @return void
21+
*/
22+
public function processAssert(Dashboard $dashboard)
23+
{
24+
$dashboard->open();
25+
$dashboard->getSubscriptionBlock()->enableCheckbox();
26+
$dashboard->getModalBlock()->dismissWarning();
27+
\PHPUnit_Framework_Assert::assertFalse(
28+
$dashboard->getSubscriptionBlock()->isVisible(),
29+
'Subscription pop-up was not declined'
30+
);
31+
}
32+
33+
/**
34+
* Returns a string representation of the object.
35+
*
36+
* @return string
37+
*/
38+
public function toString()
39+
{
40+
return 'Subscription pop-up was declined';
41+
}
42+
}

0 commit comments

Comments
 (0)