File tree Expand file tree Collapse file tree 4 files changed +77
-1
lines changed
Model/Plugin/Store/Model/Validation
Test/Unit/Model/Plugin/Store/Model/Validation Expand file tree Collapse file tree 4 files changed +77
-1
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 80
80
</argument >
81
81
</arguments >
82
82
</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 >
83
86
</config >
Original file line number Diff line number Diff line change 63
63
</arguments >
64
64
</type >
65
65
<!-- 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 >
67
69
</config >
You can’t perform that action at this time.
0 commit comments