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