55 */
66namespace Magento \Catalog \Helper ;
77
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
915{
1016 /**
11- * @var \Magento\Catalog\Helper\ Output
17+ * @var Output
1218 */
1319 protected $ _helper ;
1420
1521 protected function setUp ()
1622 {
17- $ this ->_helper = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (
18- \ Magento \ Catalog \ Helper \ Output::class
23+ $ this ->_helper = Bootstrap::getObjectManager ()->get (
24+ Output::class
1925 );
2026 }
2127
@@ -50,7 +56,7 @@ public function testProductAttribute()
5056 {
5157 $ this ->_testAttribute (
5258 'productAttribute ' ,
53- \ Magento \ Catalog \ Model \ Product::ENTITY ,
59+ Product::ENTITY ,
5460 "<p>line1</p><br /> \nline2 "
5561 );
5662 }
@@ -59,41 +65,50 @@ public function testCategoryAttribute()
5965 {
6066 $ this ->_testAttribute (
6167 'categoryAttribute ' ,
62- \ Magento \ Catalog \ Model \ Category::ENTITY ,
68+ Category::ENTITY ,
6369 "<p>line1</p> \nline2 "
6470 );
6571 }
6672
6773 /**
74+ * Tests if string has directives.
75+ *
6876 * @dataProvider isDirectiveDataProvider
77+ * @param string|Phrase $html
78+ * @param bool $expectedResult
6979 */
70- public function testIsDirective ($ html , $ expectedResult )
80+ public function testIsDirectivesExists ($ html , bool $ expectedResult ): void
7181 {
7282 $ this ->assertEquals ($ expectedResult , $ this ->_helper ->isDirectivesExists ($ html ));
7383 }
7484
75- public function isDirectiveDataProvider ()
85+ /**
86+ * Data provider for testIsDirectivesExists()
87+ *
88+ * @return array
89+ */
90+ public function isDirectiveDataProvider (): array
7691 {
7792 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 ],
8297 ];
8398 }
8499
85100 /**
86101 * Helper method for testProcess()
87102 *
88- * @param \Magento\Catalog\Helper\ Output $helper
103+ * @param Output $helper
89104 * @param string $string
90105 * @param mixed $params
91106 * @return string
92107 * @see testProcess()
93108 *
94109 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
95110 */
96- public function sampleProcessor (\ Magento \ Catalog \ Helper \ Output $ helper , $ string , $ params )
111+ public function sampleProcessor (Output $ helper , $ string , $ params )
97112 {
98113 return __CLASS__ . $ string ;
99114 }
@@ -109,7 +124,7 @@ public function sampleProcessor(\Magento\Catalog\Helper\Output $helper, $string,
109124 protected function _testAttribute ($ method , $ entityCode , $ expectedResult )
110125 {
111126 $ attributeName = 'description ' ;
112- $ attribute = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (
127+ $ attribute = Bootstrap::getObjectManager ()->get (
113128 \Magento \Eav \Model \Config::class
114129 )->getAttribute (
115130 $ entityCode ,
0 commit comments