Skip to content

Commit 25f1c36

Browse files
committed
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into pr_2019_06_11_ce
2 parents ee998ce + 57ffbd9 commit 25f1c36

24 files changed

+1165
-149
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ $formName = $block->getFormName();
175175
<label class="admin__field-label">
176176
<span><?= $block->escapeHtml(__('Image Size')) ?></span>
177177
</label>
178-
<div class="admin__field-value" data-message="<?= $block->escapeHtmlAttr(_('{size}')) ?>"></div>
178+
<div class="admin__field-value" data-message="<?= $block->escapeHtmlAttr(__('{size}')) ?>"></div>
179179
</div>
180180

181181
<div class="admin__field admin__field-inline field-image-resolution" data-role="resolution">

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ type CustomizableAreaValue @doc(description: "CustomizableAreaValue defines the
118118
}
119119

120120
type CategoryTree implements CategoryInterface @doc(description: "Category Tree implementation.") {
121-
children: [CategoryTree] @doc(description: "Child categories tree.") @resolve(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree")
121+
children: [CategoryTree] @doc(description: "Child categories tree.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree")
122122
}
123123

124124
type CustomizableDateOption implements CustomizableOptionInterface @doc(description: "CustomizableDateOption contains information about a date picker that is defined as part of a customizable option.") {

app/code/Magento/CustomerGraphQl/Model/Resolver/IsEmailAvailable.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1414
use Magento\Framework\GraphQl\Query\ResolverInterface;
1515
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
16+
use Magento\Framework\Validator\EmailAddress as EmailValidator;
1617

1718
/**
1819
* Is Customer Email Available
@@ -24,13 +25,21 @@ class IsEmailAvailable implements ResolverInterface
2425
*/
2526
private $accountManagement;
2627

28+
/**
29+
* @var EmailValidator
30+
*/
31+
private $emailValidator;
32+
2733
/**
2834
* @param AccountManagementInterface $accountManagement
35+
* @param EmailValidator $emailValidator
2936
*/
3037
public function __construct(
31-
AccountManagementInterface $accountManagement
38+
AccountManagementInterface $accountManagement,
39+
EmailValidator $emailValidator
3240
) {
3341
$this->accountManagement = $accountManagement;
42+
$this->emailValidator = $emailValidator;
3443
}
3544

3645
/**
@@ -47,6 +56,10 @@ public function resolve(
4756
throw new GraphQlInputException(__('Email must be specified'));
4857
}
4958

59+
if (!$this->emailValidator->isValid($args['email'])) {
60+
throw new GraphQlInputException(__('Email is invalid'));
61+
}
62+
5063
try {
5164
$isEmailAvailable = $this->accountManagement->isEmailAvailable($args['email']);
5265
} catch (LocalizedException $e) {

app/code/Magento/Theme/etc/system.xml

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

app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1010

1111
/**
12+
* Base abstract form element.
13+
*
14+
* phpcs:disable Magento2.Classes.AbstractApi
1215
* @api
1316
* @since 100.1.0
1417
*/
@@ -59,7 +62,7 @@ public function prepare()
5962
if (empty($config['rawOptions'])) {
6063
$options = $this->convertOptionsValueToString($options);
6164
}
62-
$config['options'] = array_values(array_merge_recursive($config['options'], $options));
65+
$config['options'] = array_values(array_replace_recursive($config['options'], $options));
6366
}
6467
$this->setData('config', (array)$config);
6568
parent::prepare();
@@ -84,11 +87,14 @@ abstract public function getIsSelected($optionValue);
8487
*/
8588
protected function convertOptionsValueToString(array $options)
8689
{
87-
array_walk($options, function (&$value) {
88-
if (isset($value['value']) && is_scalar($value['value'])) {
89-
$value['value'] = (string)$value['value'];
90+
array_walk(
91+
$options,
92+
static function (&$value) {
93+
if (isset($value['value']) && is_scalar($value['value'])) {
94+
$value['value'] = (string)$value['value'];
95+
}
9096
}
91-
});
97+
);
9298
return $options;
9399
}
94100
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
381381
}
382382
QUERY;
383383
$this->expectException(\Exception::class);
384-
$this->expectExceptionMessage('GraphQL response contains errors: currentPage value 2 specified is greater ' .
385-
'than the 1 page(s) available');
384+
$this->expectExceptionMessage(
385+
'GraphQL response contains errors: currentPage value 2 specified is greater ' .
386+
'than the 1 page(s) available'
387+
);
386388
$this->graphQlQuery($query);
387389
}
388390

@@ -1043,8 +1045,10 @@ public function testQueryPageOutOfBoundException()
10431045
QUERY;
10441046

10451047
$this->expectException(\Exception::class);
1046-
$this->expectExceptionMessage('GraphQL response contains errors: currentPage value 2 specified is greater ' .
1047-
'than the 1 page(s) available.');
1048+
$this->expectExceptionMessage(
1049+
'GraphQL response contains errors: currentPage value 2 specified is greater ' .
1050+
'than the 1 page(s) available.'
1051+
);
10481052
$this->graphQlQuery($query);
10491053
}
10501054

@@ -1075,8 +1079,10 @@ public function testQueryWithNoSearchOrFilterArgumentException()
10751079
QUERY;
10761080

10771081
$this->expectException(\Exception::class);
1078-
$this->expectExceptionMessage('GraphQL response contains errors: \'search\' or \'filter\' input argument is ' .
1079-
'required.');
1082+
$this->expectExceptionMessage(
1083+
'GraphQL response contains errors: \'search\' or \'filter\' input argument is ' .
1084+
'required.'
1085+
);
10801086
$this->graphQlQuery($query);
10811087
}
10821088

@@ -1140,7 +1146,7 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
11401146
private function assertProductItems(array $filteredProducts, array $actualResponse)
11411147
{
11421148
$productItemsInResponse = array_map(null, $actualResponse['products']['items'], $filteredProducts);
1143-
1149+
// phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
11441150
for ($itemIndex = 0; $itemIndex < count($filteredProducts); $itemIndex++) {
11451151
$this->assertNotEmpty($productItemsInResponse[$itemIndex]);
11461152
$this->assertResponseFields(

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
namespace Magento\GraphQl\Customer;
99

1010
use Magento\TestFramework\TestCase\GraphQlAbstract;
11-
use PHPUnit\Framework\TestResult;
1211

1312
/**
14-
* Class GenerateCustomerTokenTest
15-
* @package Magento\GraphQl\Customer
13+
* API-functional tests cases for generateCustomerToken mutation
1614
*/
1715
class GenerateCustomerTokenTest extends GraphQlAbstract
1816
{
@@ -23,87 +21,95 @@ class GenerateCustomerTokenTest extends GraphQlAbstract
2321
*/
2422
public function testGenerateCustomerValidToken()
2523
{
26-
$userName = '[email protected]';
24+
$email = '[email protected]';
2725
$password = 'password';
2826

29-
$mutation
30-
= <<<MUTATION
31-
mutation {
32-
generateCustomerToken(
33-
email: "{$userName}"
34-
password: "{$password}"
35-
) {
36-
token
37-
}
38-
}
39-
MUTATION;
27+
$mutation = $this->getQuery($email, $password);
4028

4129
$response = $this->graphQlMutation($mutation);
4230
$this->assertArrayHasKey('generateCustomerToken', $response);
4331
$this->assertInternalType('array', $response['generateCustomerToken']);
4432
}
4533

4634
/**
47-
* Verify customer with invalid credentials
35+
* Test customer with invalid data.
36+
*
37+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
38+
* @expectedException \Exception
39+
*
40+
* @dataProvider dataProviderInvalidCustomerInfo
41+
* @param string $email
42+
* @param string $password
43+
* @param string $message
4844
*/
49-
public function testGenerateCustomerTokenWithInvalidCredentials()
45+
public function testGenerateCustomerTokenInvalidData(string $email, string $password, string $message)
5046
{
51-
$userName = '[email protected]';
52-
$password = 'bad-password';
53-
54-
$mutation
55-
= <<<MUTATION
56-
mutation {
57-
generateCustomerToken(
58-
email: "{$userName}"
59-
password: "{$password}"
60-
) {
61-
token
62-
}
63-
}
64-
MUTATION;
65-
66-
$this->expectException(\Exception::class);
67-
$this->expectExceptionMessage('GraphQL response contains errors: The account sign-in' . ' ' .
68-
'was incorrect or your account is disabled temporarily. Please wait and try again later.');
47+
$mutation = $this->getQuery($email, $password);
48+
$this->expectExceptionMessage($message);
6949
$this->graphQlMutation($mutation);
7050
}
7151

7252
/**
73-
* Verify customer with empty email
53+
* Test customer token regeneration.
54+
*
55+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
7456
*/
75-
public function testGenerateCustomerTokenWithEmptyEmail()
57+
public function testRegenerateCustomerToken()
7658
{
77-
$email = '';
78-
$password = 'bad-password';
59+
$email = '[email protected]';
60+
$password = 'password';
7961

80-
$mutation
81-
= <<<MUTATION
82-
mutation {
83-
generateCustomerToken(
84-
email: "{$email}"
85-
password: "{$password}"
86-
) {
87-
token
88-
}
89-
}
90-
MUTATION;
62+
$mutation = $this->getQuery($email, $password);
9163

92-
$this->expectException(\Exception::class);
93-
$this->expectExceptionMessage('GraphQL response contains errors: Specify the "email" value.');
94-
$this->graphQlMutation($mutation);
64+
$response1 = $this->graphQlMutation($mutation);
65+
$token1 = $response1['generateCustomerToken']['token'];
66+
67+
$response2 = $this->graphQlMutation($mutation);
68+
$token2 = $response2['generateCustomerToken']['token'];
69+
70+
$this->assertNotEquals($token1, $token2, 'Tokens should not be identical!');
9571
}
9672

9773
/**
98-
* Verify customer with empty password
74+
* @return array
9975
*/
100-
public function testGenerateCustomerTokenWithEmptyPassword()
76+
public function dataProviderInvalidCustomerInfo(): array
10177
{
102-
$email = '[email protected]';
103-
$password = '';
78+
return [
79+
'invalid_email' => [
80+
81+
'password',
82+
'The account sign-in was incorrect or your account is disabled temporarily. ' .
83+
'Please wait and try again later.'
84+
],
85+
'empty_email' => [
86+
'',
87+
'password',
88+
'Specify the "email" value.'
89+
],
90+
'invalid_password' => [
91+
92+
'invalid_password',
93+
'The account sign-in was incorrect or your account is disabled temporarily. ' .
94+
'Please wait and try again later.'
95+
],
96+
'empty_password' => [
97+
98+
'',
99+
'Specify the "password" value.'
100+
101+
]
102+
];
103+
}
104104

105-
$mutation
106-
= <<<MUTATION
105+
/**
106+
* @param string $email
107+
* @param string $password
108+
* @return string
109+
*/
110+
private function getQuery(string $email, string $password) : string
111+
{
112+
return <<<MUTATION
107113
mutation {
108114
generateCustomerToken(
109115
email: "{$email}"
@@ -113,9 +119,5 @@ public function testGenerateCustomerTokenWithEmptyPassword()
113119
}
114120
}
115121
MUTATION;
116-
117-
$this->expectException(\Exception::class);
118-
$this->expectExceptionMessage('GraphQL response contains errors: Specify the "password" value.');
119-
$this->graphQlMutation($mutation);
120122
}
121123
}

0 commit comments

Comments
 (0)