File tree Expand file tree Collapse file tree 1 file changed +81
-0
lines changed
app/code/Magento/Backend/Test/Unit/Helper Expand file tree Collapse file tree 1 file changed +81
-0
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
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Backend \Test \Unit \Helper ;
9
+
10
+ use Magento \Backend \Helper \Js ;
11
+ use PHPUnit \Framework \TestCase ;
12
+
13
+ /**
14
+ * Class JsTest
15
+ */
16
+ class JsTest extends TestCase
17
+ {
18
+ /**
19
+ * @var Js
20
+ */
21
+ private $ helper ;
22
+
23
+ /**
24
+ * Set Up
25
+ */
26
+ protected function setUp ()
27
+ {
28
+ $ this ->helper = new Js ();
29
+ }
30
+
31
+ /**
32
+ * Test decoding the serialized input
33
+ *
34
+ * @dataProvider getEncodedDataProvider
35
+ *
36
+ * @param string $encoded
37
+ * @param array $expected
38
+ */
39
+ public function testDecodeGridSerializedInput (string $ encoded , array $ expected )
40
+ {
41
+ $ this ->assertEquals ($ expected , $ this ->helper ->decodeGridSerializedInput ($ encoded ));
42
+ }
43
+
44
+ /**
45
+ * Get serialized grid input
46
+ *
47
+ * @return array
48
+ */
49
+ public function getEncodedDataProvider (): array
50
+ {
51
+ return [
52
+ 'Decoding empty serialized string ' => [
53
+ '' ,
54
+ []
55
+ ],
56
+ 'Decoding a simplified serialized string ' => [
57
+ '1&2&3&4 ' ,
58
+ [1 , 2 , 3 , 4 ]
59
+ ],
60
+ 'Decoding encoded serialized string ' => [
61
+ '2=dGVzdC1zdHJpbmc= ' ,
62
+ [
63
+ 2 => [
64
+ 'test-string ' => ''
65
+ ]
66
+ ]
67
+ ],
68
+ 'Decoding multiple encoded serialized strings ' => [
69
+ '2=dGVzdC1zdHJpbmc=&3=bmV3LXN0cmluZw== ' ,
70
+ [
71
+ 2 => [
72
+ 'test-string ' => ''
73
+ ],
74
+ 3 => [
75
+ 'new-string ' => ''
76
+ ]
77
+ ]
78
+ ]
79
+ ];
80
+ }
81
+ }
You can’t perform that action at this time.
0 commit comments