33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+
67namespace Magento \Catalog \Test \Unit \Block \Product \View ;
78
89use \PHPUnit \Framework \TestCase ;
9- use \Magento \Framework \Phrase ;
1010use \Magento \Eav \Model \Entity \Attribute \AbstractAttribute ;
1111use \Magento \Eav \Model \Entity \Attribute \Frontend \AbstractFrontend ;
1212use \Magento \Catalog \Model \Product ;
@@ -64,73 +64,58 @@ class AttributesTest extends TestCase
6464
6565 protected function setUp ()
6666 {
67- $ this ->phrase = new Phrase (__ ('' ));
68-
6967 $ this ->attribute = $ this
7068 ->getMockBuilder (AbstractAttribute::class)
7169 ->disableOriginalConstructor ()
7270 ->getMock ();
73-
7471 $ this ->attribute
7572 ->expects ($ this ->any ())
7673 ->method ('getIsVisibleOnFront ' )
7774 ->willReturn (true );
78-
7975 $ this ->attribute
8076 ->expects ($ this ->any ())
8177 ->method ('getAttributeCode ' )
8278 ->willReturn ('phrase ' );
83-
8479 $ this ->frontendAttribute = $ this
8580 ->getMockBuilder (AbstractFrontend::class)
8681 ->disableOriginalConstructor ()
8782 ->getMock ();
88-
8983 $ this ->attribute
9084 ->expects ($ this ->any ())
9185 ->method ('getFrontendInput ' )
9286 ->willReturn ('phrase ' );
93-
9487 $ this ->attribute
9588 ->expects ($ this ->any ())
9689 ->method ('getFrontend ' )
9790 ->willReturn ($ this ->frontendAttribute );
98-
9991 $ this ->product = $ this
10092 ->getMockBuilder (Product::class)
10193 ->disableOriginalConstructor ()
10294 ->getMock ();
103-
10495 $ this ->product
10596 ->expects ($ this ->any ())
10697 ->method ('getAttributes ' )
10798 ->willReturn ([$ this ->attribute ]);
108-
10999 $ this ->product
110100 ->expects ($ this ->any ())
111101 ->method ('hasData ' )
112102 ->willReturn (true );
113-
114103 $ this ->context = $ this
115104 ->getMockBuilder (Context::class)
116105 ->disableOriginalConstructor ()
117106 ->getMock ();
118-
119107 $ this ->registry = $ this
120108 ->getMockBuilder (Registry::class)
121109 ->disableOriginalConstructor ()
122110 ->getMock ();
123-
124111 $ this ->registry
125112 ->expects ($ this ->any ())
126113 ->method ('registry ' )
127114 ->willReturn ($ this ->product );
128-
129115 $ this ->priceCurrencyInterface = $ this
130116 ->getMockBuilder (PriceCurrencyInterface::class)
131117 ->disableOriginalConstructor ()
132118 ->getMock ();
133-
134119 $ this ->attributesBlock = new AttributesBlock (
135120 $ this ->context ,
136121 $ this ->registry ,
@@ -141,34 +126,28 @@ protected function setUp()
141126 /**
142127 * @return void
143128 */
144- public function testGetAttributesBooleanNoValue ()
129+ public function testGetAttributeNoValue ()
145130 {
146- $ this ->phrase = new Phrase (__ ('' ));
147-
131+ $ this ->phrase = '' ;
148132 $ this ->frontendAttribute
149133 ->expects ($ this ->any ())
150134 ->method ('getValue ' )
151135 ->willReturn ($ this ->phrase );
152-
153136 $ attributes = $ this ->attributesBlock ->getAdditionalData ();
154-
155137 $ this ->assertTrue (empty ($ attributes ['phrase ' ]));
156138 }
157139
158140 /**
159141 * @return void
160142 */
161- public function testGetAttributesBooleanHasValue ()
143+ public function testGetAttributeHasValue ()
162144 {
163- $ this ->phrase = new Phrase (__ ('Yes ' ));
164-
145+ $ this ->phrase = __ ('Yes ' );
165146 $ this ->frontendAttribute
166147 ->expects ($ this ->any ())
167148 ->method ('getValue ' )
168149 ->willReturn ($ this ->phrase );
169-
170150 $ attributes = $ this ->attributesBlock ->getAdditionalData ();
171-
172151 $ this ->assertNotTrue (empty ($ attributes ['phrase ' ]));
173152 $ this ->assertNotTrue (empty ($ attributes ['phrase ' ]['value ' ]));
174153 $ this ->assertEquals ('Yes ' , $ attributes ['phrase ' ]['value ' ]);
0 commit comments