Skip to content

Commit 377f126

Browse files
merge magento/2.3-develop into magento-honey-badgers/MC-21811-Test
2 parents c55bf60 + 71f9784 commit 377f126

File tree

198 files changed

+5407
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+5407
-366
lines changed
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AdvancedSearch\Test\Unit\Model\Recommendations;
9+
10+
use Magento\AdvancedSearch\Model\Recommendations\DataProvider;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
13+
use Magento\Catalog\Model\Layer\Resolver;
14+
use Magento\AdvancedSearch\Model\ResourceModel\Recommendations;
15+
use Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory;
16+
use Magento\Search\Model\QueryResult;
17+
use Magento\Search\Model\QueryResultFactory;
18+
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
19+
use Magento\Catalog\Model\Layer as SearchLayer;
20+
use Magento\Store\Model\ScopeInterface;
21+
use Magento\Search\Model\QueryInterface;
22+
23+
/**
24+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25+
*
26+
* Class \Magento\AdvancedSearch\Test\Unit\Model\Recommendations\DataProviderTest
27+
*/
28+
class DataProviderTest extends \PHPUnit\Framework\TestCase
29+
{
30+
/**
31+
* @var DataProvider;
32+
*/
33+
private $model;
34+
35+
/**
36+
* @var ObjectManagerHelper
37+
*/
38+
private $objectManagerHelper;
39+
40+
/**
41+
* @var \PHPUnit_Framework_MockObject_MockObject|ScopeConfigInterface
42+
*/
43+
private $scopeConfigMock;
44+
45+
/**
46+
* @var \PHPUnit_Framework_MockObject_MockObject|Resolver
47+
*/
48+
private $layerResolverMock;
49+
50+
/**
51+
* @var \PHPUnit_Framework_MockObject_MockObject|SearchLayer
52+
*/
53+
private $searchLayerMock;
54+
55+
/**
56+
* @var \PHPUnit_Framework_MockObject_MockObject|RecommendationsFactory
57+
*/
58+
private $recommendationsFactoryMock;
59+
60+
/**
61+
* @var \PHPUnit_Framework_MockObject_MockObject|Recommendations
62+
*/
63+
private $recommendationsMock;
64+
65+
/**
66+
* @var \PHPUnit_Framework_MockObject_MockObject|Resolver
67+
*/
68+
private $queryResultFactory;
69+
70+
/**
71+
* Set up test environment.
72+
*
73+
* @return void
74+
*/
75+
protected function setUp()
76+
{
77+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
78+
$this->layerResolverMock = $this->getMockBuilder(Resolver::class)
79+
->disableOriginalConstructor()
80+
->setMethods(['get'])
81+
->getMock();
82+
83+
$this->searchLayerMock = $this->createMock(SearchLayer::class);
84+
85+
$this->layerResolverMock->expects($this->any())
86+
->method('get')
87+
->will($this->returnValue($this->searchLayerMock));
88+
89+
$this->recommendationsFactoryMock = $this->getMockBuilder(RecommendationsFactory::class)
90+
->disableOriginalConstructor()
91+
->setMethods(['create'])
92+
->getMock();
93+
94+
$this->recommendationsMock = $this->createMock(Recommendations::class);
95+
96+
$this->queryResultFactory = $this->getMockBuilder(QueryResultFactory::class)
97+
->disableOriginalConstructor()
98+
->setMethods(['create'])
99+
->getMock();
100+
101+
$this->objectManagerHelper = new ObjectManagerHelper($this);
102+
$this->model = $this->objectManagerHelper->getObject(
103+
DataProvider::class,
104+
[
105+
'scopeConfig' => $this->scopeConfigMock,
106+
'layerResolver' => $this->layerResolverMock,
107+
'recommendationsFactory' => $this->recommendationsFactoryMock,
108+
'queryResultFactory' => $this->queryResultFactory
109+
]
110+
);
111+
}
112+
113+
/**
114+
* Test testGetItems() when Search Recommendations disabled.
115+
*
116+
* @return void
117+
*/
118+
public function testGetItemsWhenDisabledSearchRecommendations()
119+
{
120+
$isEnabledSearchRecommendations = false;
121+
122+
/** @var $queryInterfaceMock QueryInterface */
123+
$queryInterfaceMock = $this->createMock(QueryInterface::class);
124+
125+
$this->scopeConfigMock->expects($this->any())
126+
->method('isSetFlag')
127+
->with('catalog/search/search_recommendations_enabled', ScopeInterface::SCOPE_STORE)
128+
->willReturn($isEnabledSearchRecommendations);
129+
130+
$result = $this->model->getItems($queryInterfaceMock);
131+
$this->assertEquals([], $result);
132+
}
133+
134+
/**
135+
* Test testGetItems() when Search Recommendations enabled.
136+
*
137+
* @return void
138+
*/
139+
public function testGetItemsWhenEnabledSearchRecommendations()
140+
{
141+
$storeId = 1;
142+
$searchRecommendationsCountConfig = 2;
143+
$isEnabledSearchRecommendations = true;
144+
$queryText = 'test';
145+
146+
/** @var $queryInterfaceMock QueryInterface */
147+
$queryInterfaceMock = $this->createMock(QueryInterface::class);
148+
$queryInterfaceMock->expects($this->any())->method('getQueryText')->willReturn($queryText);
149+
150+
$this->scopeConfigMock->expects($this->any())
151+
->method('isSetFlag')
152+
->with('catalog/search/search_recommendations_enabled', ScopeInterface::SCOPE_STORE)
153+
->willReturn($isEnabledSearchRecommendations);
154+
155+
$this->scopeConfigMock->expects($this->any())
156+
->method('getValue')
157+
->with('catalog/search/search_recommendations_count', ScopeInterface::SCOPE_STORE)
158+
->willReturn($searchRecommendationsCountConfig);
159+
160+
$productCollectionMock = $this->createMock(ProductCollection::class);
161+
$productCollectionMock->expects($this->any())->method('getStoreId')->willReturn($storeId);
162+
163+
$this->searchLayerMock->expects($this->any())->method('getProductCollection')
164+
->willReturn($productCollectionMock);
165+
166+
$this->recommendationsFactoryMock->expects($this->any())->method('create')
167+
->willReturn($this->recommendationsMock);
168+
169+
$this->recommendationsMock->expects($this->any())->method('getRecommendationsByQuery')
170+
->with($queryText, ['store_id' => $storeId], $searchRecommendationsCountConfig)
171+
->willReturn(
172+
[
173+
[
174+
'query_text' => 'a',
175+
'num_results' => 3
176+
],
177+
[
178+
'query_text' => 'b',
179+
'num_results' => 2
180+
]
181+
]
182+
);
183+
$queryResultMock = $this->createMock(QueryResult::class);
184+
$this->queryResultFactory->expects($this->any())->method('create')->willReturn($queryResultMock);
185+
186+
$result = $this->model->getItems($queryInterfaceMock);
187+
$this->assertEquals(2, count($result));
188+
}
189+
}

app/code/Magento/Analytics/Test/Mftf/Data/UserRoleData.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
1111
<entity name="adminNoReportRole" type="user_role">
12+
<data key="all">0</data>
1213
<data key="rolename" unique="suffix">noreport</data>
1314
<data key="current_password">123123q</data>
1415
<array key="resource">
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminUserIsInGridActionGroup">
12+
<arguments>
13+
<argument name="user" type="entity"/>
14+
</arguments>
15+
<click selector="{{AdminUserGridSection.resetButton}}" stepKey="resetGridFilter"/>
16+
<waitForPageLoad stepKey="waitForFiltersReset" time="15"/>
17+
<fillField selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{user.username}}" stepKey="enterUserName"/>
18+
<click selector="{{AdminUserGridSection.searchButton}}" stepKey="clickSearch"/>
19+
<waitForPageLoad stepKey="waitForGridToLoad" time="15"/>
20+
<see selector="{{AdminUserGridSection.usernameInFirstRow}}" userInput="{{user.username}}" stepKey="seeUser"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertUserRoleRestrictedAccessActionGroup">
12+
<see selector="{{AdminHeaderSection.pageHeading}}" userInput="Sorry, you need permissions to view this content." stepKey="seeErrorMessage"/>
13+
</actionGroup>
14+
</actionGroups>

app/code/Magento/Backend/Test/Mftf/Data/CookieConfigData.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,20 @@
2020
<data key="scope_code">base</data>
2121
<data key="value">''</data>
2222
</entity>
23+
<entity name="ChangeWebCookieLifetimeConfigData">
24+
<data key="path">web/cookie/cookie_lifetime</data>
25+
<data key="value">60</data>
26+
</entity>
27+
<entity name="DefaultWebCookieLifetimeConfigData">
28+
<data key="path">web/cookie/cookie_lifetime</data>
29+
<data key="value">3600</data>
30+
</entity>
31+
<entity name="ChangeAdminSecuritySessionLifetimeConfigData">
32+
<data key="path">admin/security/session_lifetime</data>
33+
<data key="value">60</data>
34+
</entity>
35+
<entity name="DefaultAdminSecuritySessionLifetimeConfigData">
36+
<data key="path">admin/security/session_lifetime</data>
37+
<data key="value">7200</data>
38+
</entity>
2339
</entities>

app/code/Magento/Backend/Test/Mftf/Section/AdminLoginFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<element name="password" type="input" selector="#login"/>
1414
<element name="signIn" type="button" selector=".actions .action-primary" timeout="30"/>
1515
<element name="forgotPasswordLink" type="button" selector=".action-forgotpassword" timeout="10"/>
16+
<element name="loginBlock" type="block" selector=".adminhtml-auth-login"/>
1617
</section>
1718
</sections>

app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<test name="AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest">
1212
<annotations>
1313
<features value="Backend"/>
14+
<stories value="Menu Navigation"/>
1415
<title value="Check locale dropdown and developer configuration page are available in developer mode"/>
1516
<description value="Check locale dropdown and developer configuration page are available in developer mode"/>
1617
<group value="backend"/>

app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<test name="AdminCheckLocaleAndDeveloperConfigInProductionModeTest">
1212
<annotations>
1313
<features value="Backend"/>
14+
<stories value="Menu Navigation"/>
1415
<title value="Check locale dropdown and developer configuration page are not available in production mode"/>
1516
<description value="Check locale dropdown and developer configuration page are not available in production mode"/>
1617
<testCaseId value="MC-14106" />
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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="AdminExpireAdminSessionTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Admin Session Expire"/>
15+
<title value="Admin Session Expire"/>
16+
<description value="Admin Session Expire"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-14111"/>
19+
<group value="Backend"/>
20+
<group value="mtf_migrated"/>
21+
</annotations>
22+
<after>
23+
<!-- 4. Restore default configuration settings. -->
24+
<magentoCLI command="config:set {{DefaultAdminSecuritySessionLifetimeConfigData.path}} {{DefaultAdminSecuritySessionLifetimeConfigData.value}}" stepKey="setDefaultSessionLifetime"/>
25+
</after>
26+
<!-- 1. Apply configuration settings. -->
27+
<magentoCLI command="config:set {{ChangeAdminSecuritySessionLifetimeConfigData.path}} {{ChangeAdminSecuritySessionLifetimeConfigData.value}}" stepKey="changeCookieLifetime"/>
28+
29+
<!-- 2. Wait for session to expire. -->
30+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
31+
<wait time="60" stepKey="waitForSessionLifetime"/>
32+
<reloadPage stepKey="reloadPage"/>
33+
34+
<!-- 3. Perform asserts. -->
35+
<seeElement selector="{{AdminLoginFormSection.loginBlock}}" stepKey="assertAdminLoginPageIsAvailable"/>
36+
</test>
37+
</tests>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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="AdminExpireCustomerSessionTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Customer Session Expire"/>
15+
<title value="Customer Session Expireon"/>
16+
<description value="Customer Session Expire"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-14110"/>
19+
<group value="Backend"/>
20+
<group value="mtf_migrated"/>
21+
</annotations>
22+
<after>
23+
<!-- 6. Restore default configuration settings. -->
24+
<magentoCLI command="config:set {{DefaultWebCookieLifetimeConfigData.path}} {{DefaultWebCookieLifetimeConfigData.value}}" stepKey="setDefaultCookieLifetime"/>
25+
<!-- Delete data -->
26+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
27+
<actionGroup ref="logout" stepKey="logout"/>
28+
</after>
29+
<!-- 1. Login to Admin. -->
30+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
31+
32+
<!-- 2. Create customer if needed. -->
33+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
34+
35+
<!-- 3. Apply configuration settings. -->
36+
<magentoCLI command="config:set {{ChangeWebCookieLifetimeConfigData.path}} {{ChangeWebCookieLifetimeConfigData.value}}" stepKey="changeCookieLifetime"/>
37+
38+
<!-- 4. Wait for session to expire. -->
39+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin">
40+
<argument name="Customer" value="$$createCustomer$$" />
41+
</actionGroup>
42+
<wait time="60" stepKey="waitForCookieLifetime"/>
43+
<reloadPage stepKey="reloadPage"/>
44+
45+
<!-- 5. Perform asserts. -->
46+
<seeElement selector="{{StorefrontPanelHeaderSection.customerLoginLink}}" stepKey="assertAuthorizationLinkIsVisibleOnStoreFront"/>
47+
</test>
48+
</tests>

app/code/Magento/Braintree/Model/Ui/ConfigProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ public function __construct(
6767
public function getConfig()
6868
{
6969
$storeId = $this->session->getStoreId();
70+
$isActive = $this->config->isActive($storeId);
7071
return [
7172
'payment' => [
7273
self::CODE => [
73-
'isActive' => $this->config->isActive($storeId),
74-
'clientToken' => $this->getClientToken(),
74+
'isActive' => $isActive,
75+
'clientToken' => $isActive ? $this->getClientToken() : null,
7576
'ccTypesMapper' => $this->config->getCcTypesMapper(),
7677
'sdkUrl' => $this->config->getSdkUrl(),
7778
'hostedFieldsSdkUrl' => $this->config->getHostedFieldsSdkUrl(),

0 commit comments

Comments
 (0)