Skip to content

Commit d25eccc

Browse files
committed
Merge branch 'ACP2E-91' of https://github.com/magento-l3/magento2ce into PR-2-2021-25-11
2 parents 4cab163 + 0e0d314 commit d25eccc

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Webapi\Model\Plugin\Store\Model\Validation;
10+
11+
use Magento\Store\Model\Validation\StoreCodeValidator as Subject;
12+
13+
/**
14+
* Suppress using code parsed from url first path for api calls.
15+
*/
16+
class StoreCodeValidator
17+
{
18+
/**
19+
* Validate if store code parsed incorrectly.
20+
*
21+
* @param Subject $subject
22+
* @param bool $result
23+
* @param string $value
24+
* @return bool
25+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
26+
*/
27+
public function afterIsValid(Subject $subject, bool $result, string $value): bool
28+
{
29+
return false;
30+
}
31+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\Webapi\Test\Unit\Model\Plugin\Store\Model\Validation;
9+
10+
use Magento\Store\Model\Validation\StoreCodeValidator as Subject;
11+
use Magento\Webapi\Model\Plugin\Store\Model\Validation\StoreCodeValidator;
12+
use PHPUnit\Framework\MockObject\MockObject;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class StoreCodeValidatorTest extends TestCase
16+
{
17+
/**
18+
* @var Subject|MockObject
19+
*/
20+
private $subjectMock;
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
protected function setUp(): void
26+
{
27+
$this->subjectMock = $this->getMockBuilder(Subject::class)
28+
->disableOriginalConstructor()
29+
->getMock();
30+
}
31+
32+
/**
33+
* @return void
34+
*/
35+
public function testAfterIsValidStore(): void
36+
{
37+
$storeCodeValidator = new StoreCodeValidator();
38+
$this->assertFalse($storeCodeValidator->afterIsValid($this->subjectMock, true, 'rest'));
39+
}
40+
}

app/code/Magento/Webapi/etc/webapi_rest/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,7 @@
8080
</argument>
8181
</arguments>
8282
</type>
83+
<type name="Magento\Store\Model\Validation\StoreCodeValidator">
84+
<plugin name="check_if_parsed_store_code_is_valid" type="Magento\Webapi\Model\Plugin\Store\Model\Validation\StoreCodeValidator"/>
85+
</type>
8386
</config>

app/code/Magento/Webapi/etc/webapi_soap/di.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,7 @@
6363
</arguments>
6464
</type>
6565
<!-- End of configuration to check that permissions are checked on fields -->
66-
66+
<type name="Magento\Store\Model\Validation\StoreCodeValidator">
67+
<plugin name="check_if_parsed_store_code_is_valid" type="Magento\Webapi\Model\Plugin\Store\Model\Validation\StoreCodeValidator"/>
68+
</type>
6769
</config>

0 commit comments

Comments
 (0)