3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Framework \Filter \Template \Tokenizer ;
7
9
8
- class ParameterTest extends \PHPUnit \Framework \TestCase
10
+ use Magento \Catalog \Block \Product \Widget \NewWidget ;
11
+ use Magento \TestFramework \Helper \Bootstrap ;
12
+ use PHPUnit \Framework \TestCase ;
13
+
14
+ /**
15
+ * Test for \Magento\Framework\Filter\Template\Tokenizer\Parameter.
16
+ */
17
+ class ParameterTest extends TestCase
9
18
{
10
19
/**
20
+ * Test for getValue
21
+ *
22
+ * @dataProvider getValueDataProvider
23
+ *
11
24
* @param string $string
12
25
* @param array $values
13
- * @dataProvider getValueDataProvider
26
+ * @return void
14
27
*/
15
- public function testGetValue ($ string , $ values )
28
+ public function testGetValue ($ string , $ values ): void
16
29
{
17
- $ objectManager = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ();
18
- /** @var \Magento\Framework\Filter\Template\Tokenizer\ Parameter $parameter */
19
- $ parameter = $ objectManager ->create (\ Magento \ Framework \ Filter \ Template \ Tokenizer \ Parameter::class);
30
+ $ objectManager = Bootstrap::getObjectManager ();
31
+ /** @var Parameter $parameter */
32
+ $ parameter = $ objectManager ->create (Parameter::class);
20
33
$ parameter ->setString ($ string );
21
34
22
35
foreach ($ values as $ value ) {
@@ -25,30 +38,36 @@ public function testGetValue($string, $values)
25
38
}
26
39
27
40
/**
41
+ * Test for tokenize
42
+ *
28
43
* @dataProvider tokenizeDataProvider
44
+ *
29
45
* @param string $string
30
46
* @param array $params
47
+ * @return void
31
48
*/
32
- public function testTokenize ($ string , $ params )
49
+ public function testTokenize (string $ string , array $ params ): void
33
50
{
34
- $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
35
- /** @var \Magento\Framework\Filter\Template\Tokenizer\Parameter $parameter */
36
- $ parameter = $ objectManager ->create (\Magento \Framework \Filter \Template \Tokenizer \Parameter::class);
51
+ $ objectManager = Bootstrap::getObjectManager ();
52
+ $ parameter = $ objectManager ->create (Parameter::class);
37
53
$ parameter ->setString ($ string );
54
+
38
55
$ this ->assertEquals ($ params , $ parameter ->tokenize ());
39
56
}
40
57
41
58
/**
59
+ * DataProvider for testTokenize
60
+ *
42
61
* @return array
43
62
*/
44
- public function tokenizeDataProvider ()
63
+ public function tokenizeDataProvider (): array
45
64
{
46
65
return [
47
66
[
48
67
' type="Magento \\Catalog \\Block \\Product \\Widget \\NewWidget" display_type="all_products" '
49
68
. ' products_count="10" template="product/widget/new/content/new_grid.phtml" ' ,
50
69
[
51
- 'type ' => \ Magento \ Catalog \ Block \ Product \ Widget \ NewWidget::class,
70
+ 'type ' => NewWidget::class,
52
71
'display_type ' => 'all_products ' ,
53
72
'products_count ' => 10 ,
54
73
'template ' => 'product/widget/new/content/new_grid.phtml '
@@ -58,12 +77,24 @@ public function tokenizeDataProvider()
58
77
' type="Magento\Catalog\Block\Product\Widget\NewWidget" display_type="all_products" '
59
78
. ' products_count="10" template="product/widget/new/content/new_grid.phtml" ' ,
60
79
[
61
- 'type ' => \ Magento \ Catalog \ Block \ Product \ Widget \ NewWidget::class,
80
+ 'type ' => NewWidget::class,
62
81
'display_type ' => 'all_products ' ,
63
82
'products_count ' => 10 ,
64
83
'template ' => 'product/widget/new/content/new_grid.phtml '
65
84
]
66
- ]
85
+ ],
86
+ [
87
+ sprintf (
88
+ 'type="%s" display_type="all_products" products_count="1" template="content/new_grid.phtml" ' ,
89
+ NewWidget::class
90
+ ),
91
+ [
92
+ 'type ' => NewWidget::class,
93
+ 'display_type ' => 'all_products ' ,
94
+ 'products_count ' => 1 ,
95
+ 'template ' => 'content/new_grid.phtml '
96
+ ],
97
+ ],
67
98
];
68
99
}
69
100
0 commit comments