5
5
*/
6
6
namespace Magento \Catalog \Helper ;
7
7
8
- class OutputTest extends \PHPUnit \Framework \TestCase
8
+ use Magento \Catalog \Model \Category ;
9
+ use Magento \Catalog \Model \Product ;
10
+ use Magento \Framework \Phrase ;
11
+ use Magento \TestFramework \Helper \Bootstrap ;
12
+ use PHPUnit \Framework \TestCase ;
13
+
14
+ class OutputTest extends TestCase
9
15
{
10
16
/**
11
- * @var \Magento\Catalog\Helper\ Output
17
+ * @var Output
12
18
*/
13
19
protected $ _helper ;
14
20
15
21
protected function setUp ()
16
22
{
17
- $ this ->_helper = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (
18
- \ Magento \ Catalog \ Helper \ Output::class
23
+ $ this ->_helper = Bootstrap::getObjectManager ()->get (
24
+ Output::class
19
25
);
20
26
}
21
27
@@ -50,7 +56,7 @@ public function testProductAttribute()
50
56
{
51
57
$ this ->_testAttribute (
52
58
'productAttribute ' ,
53
- \ Magento \ Catalog \ Model \ Product::ENTITY ,
59
+ Product::ENTITY ,
54
60
"<p>line1</p><br /> \nline2 "
55
61
);
56
62
}
@@ -59,41 +65,50 @@ public function testCategoryAttribute()
59
65
{
60
66
$ this ->_testAttribute (
61
67
'categoryAttribute ' ,
62
- \ Magento \ Catalog \ Model \ Category::ENTITY ,
68
+ Category::ENTITY ,
63
69
"<p>line1</p> \nline2 "
64
70
);
65
71
}
66
72
67
73
/**
74
+ * Tests if string has directives.
75
+ *
68
76
* @dataProvider isDirectiveDataProvider
77
+ * @param string|Phrase $html
78
+ * @param bool $expectedResult
69
79
*/
70
- public function testIsDirective ($ html , $ expectedResult )
80
+ public function testIsDirectivesExists ($ html , bool $ expectedResult ): void
71
81
{
72
82
$ this ->assertEquals ($ expectedResult , $ this ->_helper ->isDirectivesExists ($ html ));
73
83
}
74
84
75
- public function isDirectiveDataProvider ()
85
+ /**
86
+ * Data provider for testIsDirectivesExists()
87
+ *
88
+ * @return array
89
+ */
90
+ public function isDirectiveDataProvider (): array
76
91
{
77
92
return [
78
- [ ' {{ ' , false ],
79
- [ ' Test string ' , false ],
80
- ['{store url="customer/account/login"} ' , false ],
81
- [ '{{store url="customer/account/login"}} ' , true ],
93
+ ' attribute_html_without_directive ' => [ ' Test string ' , false ],
94
+ ' attribute_html_with_incorrect_directive ' => [ ' {store url="customer/account/login"} ' , false ],
95
+ ' attribute_html_with_correct_directive ' => ['{{ store url="customer/account/login"}} ' , true ],
96
+ ' attribute_html_with_object_type ' => [ __ ( '{{store url="%1"}} ' , ' customer/account/login ' ) , true ],
82
97
];
83
98
}
84
99
85
100
/**
86
101
* Helper method for testProcess()
87
102
*
88
- * @param \Magento\Catalog\Helper\ Output $helper
103
+ * @param Output $helper
89
104
* @param string $string
90
105
* @param mixed $params
91
106
* @return string
92
107
* @see testProcess()
93
108
*
94
109
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
95
110
*/
96
- public function sampleProcessor (\ Magento \ Catalog \ Helper \ Output $ helper , $ string , $ params )
111
+ public function sampleProcessor (Output $ helper , $ string , $ params )
97
112
{
98
113
return __CLASS__ . $ string ;
99
114
}
@@ -109,7 +124,7 @@ public function sampleProcessor(\Magento\Catalog\Helper\Output $helper, $string,
109
124
protected function _testAttribute ($ method , $ entityCode , $ expectedResult )
110
125
{
111
126
$ attributeName = 'description ' ;
112
- $ attribute = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (
127
+ $ attribute = Bootstrap::getObjectManager ()->get (
113
128
\Magento \Eav \Model \Config::class
114
129
)->getAttribute (
115
130
$ entityCode ,
0 commit comments