File tree Expand file tree Collapse file tree 5 files changed +92
-1
lines changed
dev/tests/integration/testsuite/Magento/Framework/DataObject
lib/internal/Magento/Framework Expand file tree Collapse file tree 5 files changed +92
-1
lines changed Original file line number Diff line number Diff line change 167
167
<preference for =" Magento\Framework\EntityManager\MapperInterface" type =" Magento\Framework\EntityManager\CompositeMapper" />
168
168
<preference for =" Magento\Framework\Console\CommandListInterface" type =" Magento\Framework\Console\CommandList" />
169
169
<preference for =" Magento\Framework\DataObject\IdentityGeneratorInterface" type =" Magento\Framework\DataObject\IdentityService" />
170
+ <preference for =" Magento\Framework\DataObject\IdentityValidatorInterface" type =" Magento\Framework\DataObject\IdentityValidator" />
170
171
<preference for =" Magento\Framework\Serialize\SerializerInterface" type =" Magento\Framework\Serialize\Serializer\Json" />
171
172
<preference for =" Magento\Framework\App\Scope\ValidatorInterface" type =" Magento\Framework\App\Scope\Validator" />
172
173
<preference for =" Magento\Framework\App\ScopeResolverInterface" type =" Magento\Framework\App\ScopeResolver" />
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
+ namespace Magento \Framework \DataObject ;
7
+
8
+ class IdentityValidatorTest extends \PHPUnit \Framework \TestCase
9
+ {
10
+ const VALID_UUID = 'fe563e12-cf9d-4faf-82cd-96e011b557b7 ' ;
11
+ const INVALID_UUID = 'abcdef ' ;
12
+
13
+ /**
14
+ * @var IdentityValidator
15
+ */
16
+ protected $ identityValidator ;
17
+
18
+ protected function setUp ()
19
+ {
20
+ $ this ->identityValidator = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
21
+ ->get (IdentityValidator::class);
22
+ }
23
+
24
+ public function testIsValid ()
25
+ {
26
+ $ isValid = $ this ->identityValidator ->isValid (self ::VALID_UUID );
27
+ $ this ->assertEquals (true , $ isValid );
28
+ }
29
+
30
+ public function testIsNotValid ()
31
+ {
32
+ $ isValid = $ this ->identityValidator ->isValid (self ::INVALID_UUID );
33
+ $ this ->assertEquals (false , $ isValid );
34
+ }
35
+
36
+ public function testEmptyValue ()
37
+ {
38
+ $ isValid = $ this ->identityValidator ->isValid ('' );
39
+ $ this ->assertEquals (false , $ isValid );
40
+ }
41
+ }
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 \Framework \DataObject ;
9
+
10
+ use Ramsey \Uuid \Uuid ;
11
+
12
+ /**
13
+ * Class IdentityValidator
14
+ *
15
+ * Class for validating Uuid's
16
+ */
17
+ class IdentityValidator implements IdentityValidatorInterface
18
+ {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ public function isValid (string $ value ): bool
23
+ {
24
+ $ isValid = Uuid::isValid ($ value );
25
+ return $ isValid ;
26
+ }
27
+ }
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
+ namespace Magento \Framework \DataObject ;
7
+
8
+ /**
9
+ * Interface IdentityValidatorInterface
10
+ */
11
+ interface IdentityValidatorInterface
12
+ {
13
+ /**
14
+ * Checks if uuid is valid
15
+ *
16
+ * @param string $value
17
+ *
18
+ * @return bool
19
+ */
20
+ public function isValid (string $ value ): bool ;
21
+ }
Original file line number Diff line number Diff line change 39
39
"zendframework/zend-validator" : " ^2.6.0" ,
40
40
"zendframework/zend-mail" : " ^2.9.0" ,
41
41
"zendframework/zend-mime" : " ^2.5.0" ,
42
- "guzzlehttp/guzzle" : " ^6.3.3"
42
+ "guzzlehttp/guzzle" : " ^6.3.3" ,
43
+ "ramsey/uuid" : " ~3.8.0"
43
44
},
44
45
"archive" : {
45
46
"exclude" : [
You can’t perform that action at this time.
0 commit comments