Skip to content

Commit e935b80

Browse files
committed
Merge branch 'MAGETWO-65821' of github.com:magento-troll/magento2ce into MAGETWO-65622
2 parents 8e84545 + 6d436bc commit e935b80

File tree

36 files changed

+1265
-163
lines changed

36 files changed

+1265
-163
lines changed

app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*/
77
namespace Magento\Webapi\Model;
88

9-
use Magento\Webapi\Controller\Rest;
109
use Magento\Webapi\Model\Cache\Type\Webapi;
11-
use Magento\Webapi\Model\ServiceMetadata;
1210
use Magento\Framework\Webapi\Authorization;
11+
use Magento\Framework\Serialize\Serializer\Json;
12+
use Magento\Framework\App\ObjectManager;
1313

1414
/**
1515
* Abstract API schema generator.
@@ -41,6 +41,13 @@ abstract class AbstractSchemaGenerator
4141
*/
4242
protected $authorization;
4343

44+
/**
45+
* Instance of serializer.
46+
*
47+
* @var Json
48+
*/
49+
private $serializer;
50+
4451
/**
4552
* Initialize dependencies.
4653
*
@@ -49,19 +56,22 @@ abstract class AbstractSchemaGenerator
4956
* @param \Magento\Framework\Webapi\CustomAttributeTypeLocatorInterface $customAttributeTypeLocator
5057
* @param \Magento\Webapi\Model\ServiceMetadata $serviceMetadata
5158
* @param Authorization $authorization
59+
* @param Json|null $serializer
5260
*/
5361
public function __construct(
5462
Webapi $cache,
5563
\Magento\Framework\Reflection\TypeProcessor $typeProcessor,
5664
\Magento\Framework\Webapi\CustomAttributeTypeLocatorInterface $customAttributeTypeLocator,
5765
ServiceMetadata $serviceMetadata,
58-
Authorization $authorization
66+
Authorization $authorization,
67+
Json $serializer = null
5968
) {
6069
$this->cache = $cache;
6170
$this->typeProcessor = $typeProcessor;
6271
$this->customAttributeTypeLocator = $customAttributeTypeLocator;
6372
$this->serviceMetadata = $serviceMetadata;
6473
$this->authorization = $authorization;
74+
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
6575
}
6676

6777
/**
@@ -96,7 +106,8 @@ public function generate($requestedServices, $requestScheme, $requestHost, $endP
96106
{
97107
/** Sort requested services by names to prevent caching of the same schema file more than once. */
98108
ksort($requestedServices);
99-
$cacheId = $this->cache->generateCacheIdUsingContext(get_class($this) . serialize($requestedServices));
109+
$prefix = get_class($this) . $this->serializer->serialize($requestedServices);
110+
$cacheId = $this->cache->generateCacheIdUsingContext($prefix);
100111
$cachedSchemaContent = $this->cache->load($cacheId);
101112
if ($cachedSchemaContent !== false) {
102113
return $cachedSchemaContent;

app/code/Magento/Webapi/Test/Unit/Model/Rest/Swagger/GeneratorTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase
3939
*/
4040
protected $objectManager;
4141

42+
/**
43+
* @var \PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
private $serializer;
46+
4247
protected function setUp()
4348
{
4449
$this->serviceMetadataMock = $this->getMockBuilder(
@@ -90,6 +95,17 @@ protected function setUp()
9095
->getMock();
9196
$authorizationMock->expects($this->any())->method('isAllowed')->willReturn(true);
9297

98+
$this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
99+
->disableOriginalConstructor()
100+
->getMock();
101+
$this->serializer->expects($this->any())
102+
->method('serialize')
103+
->willReturnCallback(
104+
function ($value) {
105+
return json_encode($value);
106+
}
107+
);
108+
93109
$this->generator = $this->objectManager->getObject(
94110
\Magento\Webapi\Model\Rest\Swagger\Generator::class,
95111
[
@@ -98,12 +114,14 @@ protected function setUp()
98114
'typeProcessor' => $this->typeProcessorMock,
99115
'serviceMetadata' => $this->serviceMetadataMock,
100116
'customAttributeTypeLocator' => $this->customAttributeTypeLocatorMock,
101-
'authorization' => $authorizationMock
117+
'authorization' => $authorizationMock,
118+
'serializer' => $this->serializer
102119
]
103120
);
104121
}
105122

106123
/**
124+
* @covers \Magento\Webapi\Model\AbstractSchemaGenerator::generate()
107125
* @param string[] $serviceMetadata
108126
* @param string[] $typeData
109127
* @param string $schema

app/code/Magento/Webapi/Test/Unit/Model/Soap/Wsdl/GeneratorTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase
2929
/** @var \Magento\Framework\Reflection\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */
3030
protected $_typeProcessor;
3131

32+
/**
33+
* @var \PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
private $serializer;
36+
3237
protected function setUp()
3338
{
3439
$this->serviceMetadata = $this->getMockBuilder(
@@ -85,6 +90,24 @@ protected function setUp()
8590
$this->customAttributeTypeLocator = $objectManager
8691
->getObject(\Magento\Eav\Model\EavCustomAttributeTypeLocator::class);
8792

93+
$this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)
94+
->disableOriginalConstructor()
95+
->getMock();
96+
$this->serializer->expects($this->any())
97+
->method('serialize')
98+
->willReturnCallback(
99+
function ($value) {
100+
return json_encode($value);
101+
}
102+
);
103+
$objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class);
104+
$objectManagerMock->expects($this->any())
105+
->method('get')
106+
->willReturnMap([
107+
[\Magento\Framework\Serialize\Serializer\Json::class, $this->serializer]
108+
]);
109+
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
110+
88111
$this->_wsdlGenerator = $objectManager->getObject(
89112
\Magento\Webapi\Model\Soap\Wsdl\Generator::class,
90113
[
@@ -93,7 +116,8 @@ protected function setUp()
93116
'typeProcessor' => $this->_typeProcessor,
94117
'customAttributeTypeLocator' => $this->customAttributeTypeLocator,
95118
'serviceMetadata' => $this->serviceMetadata,
96-
'authorization' => $authorizationMock
119+
'authorization' => $authorizationMock,
120+
'serializer' => $this->serializer
97121
]
98122
);
99123

@@ -159,6 +183,7 @@ public function testGetOutputMessageName()
159183
/**
160184
* Test exception for handle
161185
*
186+
* @covers \Magento\Webapi\Model\AbstractSchemaGenerator::generate()
162187
* @expectedException \Magento\Framework\Webapi\Exception
163188
* @expectedExceptionMessage exception message
164189
*/

dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<item name="import_multiple_value_separator" xsi:type="string">,</item>
1919
<item name="import_file" xsi:type="array">
2020
<item name="entities" xsi:type="array">
21-
<item name="0" xsi:type="string">catalogProductSimple::default</item>
21+
<item name="0" xsi:type="string">catalogProductSimple::johndoe_with_addresses</item>
2222
</item>
2323
<item name="template" xsi:type="array">
2424
<item name="filename" xsi:type="string">Magento/AdvancedPricingImportExport/Test/_files/template/pricing/advanced_price_variation_1</item>

dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/etc/di.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313
</arguments>
1414
</type>
1515

16-
<type name="Magento\Mtf\Util\Command\File\ExportInterface">
16+
<virtualType name="Magento\Mtf\Util\Command\File\AdvancedPricingExport" type="Magento\Mtf\Util\Command\File\Export">
1717
<arguments>
1818
<argument name="type" xsi:type="string">advancedPricing</argument>
1919
</arguments>
20+
</virtualType>
21+
22+
<type name="Magento\AdvancedPricingImportExport\Test\Constraint\AssertExportAdvancedPricing">
23+
<arguments>
24+
<argument name="export" xsi:type="object">Magento\Mtf\Util\Command\File\AdvancedPricingExport</argument>
25+
</arguments>
2026
</type>
2127

2228
<virtualType name="Magento\Mtf\Util\Command\File\Export\AdvancedPricingReader" type="Magento\Mtf\Util\Command\File\Export\Reader">

dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertAdminLoginPageIsAvailable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AssertAdminLoginPageIsAvailable extends AbstractConstraint
2222
*/
2323
public function processAssert(AdminAuthLogin $adminAuthLogin)
2424
{
25+
$adminAuthLogin->open();
2526
\PHPUnit_Framework_Assert::assertTrue(
2627
$adminAuthLogin->getLoginBlock()->isVisible(),
2728
'Admin session does not expire properly.'

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<item name="value" xsi:type="number">3600</item>
125125
</field>
126126
</dataset>
127+
127128
<dataset name="admin_session_lifetime_60_seconds">
128129
<field name="admin/security/session_lifetime" xsi:type="array">
129130
<item name="scope" xsi:type="string">default</item>
@@ -133,6 +134,29 @@
133134
</field>
134135
</dataset>
135136

137+
<dataset name="admin_session_lifetime_60_seconds_rollback">
138+
<field name="admin/security/session_lifetime" xsi:type="array">
139+
<item name="scope" xsi:type="string">default</item>
140+
<item name="scope_id" xsi:type="number">0</item>
141+
<item name="label" xsi:type="number">3600</item>
142+
<item name="value" xsi:type="number">3600</item>
143+
</field>
144+
</dataset>
145+
146+
<dataset name="default_cookie_lifetime_60_seconds">
147+
<field name="web/cookie/cookie_lifetime" xsi:type="array">
148+
<item name="label" xsi:type="string"/>
149+
<item name="value" xsi:type="number">60</item>
150+
</field>
151+
</dataset>
152+
153+
<dataset name="default_cookie_lifetime_60_seconds_rollback">
154+
<field name="web/cookie/cookie_lifetime" xsi:type="array">
155+
<item name="label" xsi:type="string"/>
156+
<item name="value" xsi:type="number">3600</item>
157+
</field>
158+
</dataset>
159+
136160
<dataset name="admin_account_sharing_enable">
137161
<field name="admin/security/admin_account_sharing" xsi:type="array">
138162
<item name="scope" xsi:type="string">default</item>

dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.php

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

dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.xml

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

0 commit comments

Comments
 (0)