Skip to content

Commit 5e87343

Browse files
authored
Merge pull request #82 from magento-epam/2.3-develop
Merge 2.3-develop to EPAM-PR-4
2 parents 05f0d9b + 1131a21 commit 5e87343

File tree

191 files changed

+10954
-7274
lines changed

Some content is hidden

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

191 files changed

+10954
-7274
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"adminnotification_inbox": {
3-
"column": {
4-
"notification_id": true,
5-
"severity": true,
6-
"date_added": true,
7-
"title": true,
8-
"description": true,
9-
"url": true,
10-
"is_read": true,
11-
"is_remove": true
2+
"adminnotification_inbox": {
3+
"column": {
4+
"notification_id": true,
5+
"severity": true,
6+
"date_added": true,
7+
"title": true,
8+
"description": true,
9+
"url": true,
10+
"is_read": true,
11+
"is_remove": true
12+
},
13+
"index": {
14+
"ADMINNOTIFICATION_INBOX_SEVERITY": true,
15+
"ADMINNOTIFICATION_INBOX_IS_READ": true,
16+
"ADMINNOTIFICATION_INBOX_IS_REMOVE": true
17+
},
18+
"constraint": {
19+
"PRIMARY": true
20+
}
1221
},
13-
"index": {
14-
"ADMINNOTIFICATION_INBOX_SEVERITY": true,
15-
"ADMINNOTIFICATION_INBOX_IS_READ": true,
16-
"ADMINNOTIFICATION_INBOX_IS_REMOVE": true
17-
},
18-
"constraint": {
19-
"PRIMARY": true
20-
}
21-
},
22-
"admin_system_messages": {
23-
"column": {
24-
"identity": true,
25-
"severity": true,
26-
"created_at": true
27-
},
28-
"constraint": {
29-
"PRIMARY": true
22+
"admin_system_messages": {
23+
"column": {
24+
"identity": true,
25+
"severity": true,
26+
"created_at": true
27+
},
28+
"constraint": {
29+
"PRIMARY": true
30+
}
3031
}
31-
}
3232
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"catalogsearch_recommendations": {
3-
"column": {
4-
"id": true,
5-
"query_id": true,
6-
"relation_id": true
7-
},
8-
"constraint": {
9-
"PRIMARY": true,
10-
"CATALOGSEARCH_RECOMMENDATIONS_QUERY_ID_SEARCH_QUERY_QUERY_ID": true,
11-
"CATALOGSEARCH_RECOMMENDATIONS_RELATION_ID_SEARCH_QUERY_QUERY_ID": true
2+
"catalogsearch_recommendations": {
3+
"column": {
4+
"id": true,
5+
"query_id": true,
6+
"relation_id": true
7+
},
8+
"constraint": {
9+
"PRIMARY": true,
10+
"CATALOGSEARCH_RECOMMENDATIONS_QUERY_ID_SEARCH_QUERY_QUERY_ID": true,
11+
"CATALOGSEARCH_RECOMMENDATIONS_RELATION_ID_SEARCH_QUERY_QUERY_ID": true
12+
}
1213
}
13-
}
1414
}

app/code/Magento/Analytics/Model/Connector/Http/ConverterInterface.php

+5
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public function toBody(array $data);
3030
* @return string
3131
*/
3232
public function getContentTypeHeader();
33+
34+
/**
35+
* @return string
36+
*/
37+
public function getContentMediaType(): string;
3338
}

app/code/Magento/Analytics/Model/Connector/Http/JsonConverter.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Analytics\Model\Connector\Http;
79

810
use Magento\Framework\Serialize\Serializer\Json;
@@ -14,9 +16,16 @@ class JsonConverter implements ConverterInterface
1416
{
1517
/**
1618
* Content-Type HTTP header for json.
19+
* @deprecated
20+
* @see CONTENT_MEDIA_TYPE
1721
*/
1822
const CONTENT_TYPE_HEADER = 'Content-Type: application/json';
1923

24+
/**
25+
* Media-Type corresponding to this converter.
26+
*/
27+
const CONTENT_MEDIA_TYPE = 'application/json';
28+
2029
/**
2130
* @var Json
2231
*/
@@ -56,6 +65,14 @@ public function toBody(array $data)
5665
*/
5766
public function getContentTypeHeader()
5867
{
59-
return self::CONTENT_TYPE_HEADER;
68+
return sprintf('Content-Type: %s', self::CONTENT_MEDIA_TYPE);
69+
}
70+
71+
/**
72+
* @inheritdoc
73+
*/
74+
public function getContentMediaType(): string
75+
{
76+
return self::CONTENT_MEDIA_TYPE;
6077
}
6178
}

app/code/Magento/Analytics/Model/Connector/Http/ResponseResolver.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ public function __construct(ConverterInterface $converter, array $responseHandle
3838
public function getResult(\Zend_Http_Response $response)
3939
{
4040
$result = false;
41-
$responseBody = $this->converter->fromBody($response->getBody());
41+
$converterMediaType = $this->converter->getContentMediaType();
42+
43+
/** Content-Type header may not only contain media-type declaration */
44+
if ($response->getBody() && is_int(strripos($response->getHeader('Content-Type'), $converterMediaType))) {
45+
$responseBody = $this->converter->fromBody($response->getBody());
46+
} else {
47+
$responseBody = [];
48+
}
49+
4250
if (array_key_exists($response->getStatus(), $this->responseHandlers)) {
4351
$result = $this->responseHandlers[$response->getStatus()]->handleResponse($responseBody);
4452
}

app/code/Magento/Analytics/Model/Connector/OTPRequest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ public function call()
103103
if (!$result) {
104104
$this->logger->warning(
105105
sprintf(
106-
'Obtaining of an OTP from the MBI service has been failed: %s',
107-
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty.'
106+
'Obtaining of an OTP from the MBI service has been failed: %s. Content-Type: %s',
107+
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty',
108+
$response->getHeader('Content-Type')
108109
)
109110
);
110111
}

app/code/Magento/Analytics/Model/Connector/SignUpCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ public function execute()
110110
if (!$result) {
111111
$this->logger->warning(
112112
sprintf(
113-
'Subscription for MBI service has been failed. An error occurred during token exchange: %s',
114-
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty.'
113+
'Subscription for MBI service has been failed. An error occurred during token exchange: %s.'
114+
. ' Content-Type: %s',
115+
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty',
116+
$response->getHeader('Content-Type')
115117
)
116118
);
117119
}

app/code/Magento/Analytics/Model/Connector/UpdateCommand.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ public function execute()
101101
if (!$result) {
102102
$this->logger->warning(
103103
sprintf(
104-
'Update of the subscription for MBI service has been failed: %s',
105-
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty.'
104+
'Update of the subscription for MBI service has been failed: %s. Content-Type: %s',
105+
!empty($response->getBody()) ? $response->getBody() : 'Response body is empty',
106+
$response->getHeader('Content-Type')
106107
)
107108
);
108109
}

app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php

+13-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/**
1414
* A unit test for testing of the CURL HTTP client.
15+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1516
*/
1617
class CurlTest extends \PHPUnit\Framework\TestCase
1718
{
@@ -97,15 +98,16 @@ public function getTestData()
9798
'version' => '1.1',
9899
'body'=> ['name' => 'value'],
99100
'url' => 'http://www.mystore.com',
100-
'headers' => [JsonConverter::CONTENT_TYPE_HEADER],
101101
'method' => \Magento\Framework\HTTP\ZendClient::POST,
102102
]
103103
]
104104
];
105105
}
106106

107107
/**
108+
* @param array $data
108109
* @return void
110+
* @throws \Zend_Http_Exception
109111
* @dataProvider getTestData
110112
*/
111113
public function testRequestSuccess(array $data)
@@ -118,7 +120,7 @@ public function testRequestSuccess(array $data)
118120
$data['method'],
119121
$data['url'],
120122
$data['version'],
121-
$data['headers'],
123+
[$this->converterMock->getContentTypeHeader()],
122124
json_encode($data['body'])
123125
);
124126
$this->curlAdapterMock->expects($this->once())
@@ -139,14 +141,16 @@ public function testRequestSuccess(array $data)
139141
$data['method'],
140142
$data['url'],
141143
$data['body'],
142-
$data['headers'],
144+
[$this->converterMock->getContentTypeHeader()],
143145
$data['version']
144146
)
145147
);
146148
}
147149

148150
/**
151+
* @param array $data
149152
* @return void
153+
* @throws \Zend_Http_Exception
150154
* @dataProvider getTestData
151155
*/
152156
public function testRequestError(array $data)
@@ -158,7 +162,7 @@ public function testRequestError(array $data)
158162
$data['method'],
159163
$data['url'],
160164
$data['version'],
161-
$data['headers'],
165+
[$this->converterMock->getContentTypeHeader()],
162166
json_encode($data['body'])
163167
);
164168
$this->curlAdapterMock->expects($this->once())
@@ -184,7 +188,7 @@ public function testRequestError(array $data)
184188
$data['method'],
185189
$data['url'],
186190
$data['body'],
187-
$data['headers'],
191+
[$this->converterMock->getContentTypeHeader()],
188192
$data['version']
189193
)
190194
);
@@ -195,14 +199,13 @@ public function testRequestError(array $data)
195199
*/
196200
private function createJsonConverter()
197201
{
198-
$converterMock = $this->getMockBuilder(ConverterInterface::class)
199-
->getMockForAbstractClass();
202+
$converterMock = $this->getMockBuilder(JsonConverter::class)
203+
->setMethodsExcept(['getContentTypeHeader'])
204+
->disableOriginalConstructor()
205+
->getMock();
200206
$converterMock->expects($this->any())->method('toBody')->willReturnCallback(function ($value) {
201207
return json_encode($value);
202208
});
203-
$converterMock->expects($this->any())
204-
->method('getContentTypeHeader')
205-
->willReturn(JsonConverter::CONTENT_TYPE_HEADER);
206209
return $converterMock;
207210
}
208211
}

app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class JsonConverterTest extends \PHPUnit\Framework\TestCase
2525
*/
2626
private $converter;
2727

28+
/**
29+
* @return void
30+
*/
2831
protected function setUp()
2932
{
3033
$this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -37,9 +40,15 @@ protected function setUp()
3740
);
3841
}
3942

43+
/**
44+
* @return void
45+
*/
4046
public function testConverterContainsHeader()
4147
{
42-
$this->assertEquals(JsonConverter::CONTENT_TYPE_HEADER, $this->converter->getContentTypeHeader());
48+
$this->assertEquals(
49+
'Content-Type: ' . JsonConverter::CONTENT_MEDIA_TYPE,
50+
$this->converter->getContentTypeHeader()
51+
);
4352
}
4453

4554
/**
@@ -66,6 +75,9 @@ public function convertBodyDataProvider()
6675
];
6776
}
6877

78+
/**
79+
* return void
80+
*/
6981
public function testConvertData()
7082
{
7183
$this->serializerMock->expects($this->once())

0 commit comments

Comments
 (0)