3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Catalog \Test \Unit \Block \Product \View ;
7
8
8
9
use \PHPUnit \Framework \TestCase ;
9
- use \Magento \Framework \Phrase ;
10
10
use \Magento \Eav \Model \Entity \Attribute \AbstractAttribute ;
11
11
use \Magento \Eav \Model \Entity \Attribute \Frontend \AbstractFrontend ;
12
12
use \Magento \Catalog \Model \Product ;
@@ -64,73 +64,58 @@ class AttributesTest extends TestCase
64
64
65
65
protected function setUp ()
66
66
{
67
- $ this ->phrase = new Phrase (__ ('' ));
68
-
69
67
$ this ->attribute = $ this
70
68
->getMockBuilder (AbstractAttribute::class)
71
69
->disableOriginalConstructor ()
72
70
->getMock ();
73
-
74
71
$ this ->attribute
75
72
->expects ($ this ->any ())
76
73
->method ('getIsVisibleOnFront ' )
77
74
->willReturn (true );
78
-
79
75
$ this ->attribute
80
76
->expects ($ this ->any ())
81
77
->method ('getAttributeCode ' )
82
78
->willReturn ('phrase ' );
83
-
84
79
$ this ->frontendAttribute = $ this
85
80
->getMockBuilder (AbstractFrontend::class)
86
81
->disableOriginalConstructor ()
87
82
->getMock ();
88
-
89
83
$ this ->attribute
90
84
->expects ($ this ->any ())
91
85
->method ('getFrontendInput ' )
92
86
->willReturn ('phrase ' );
93
-
94
87
$ this ->attribute
95
88
->expects ($ this ->any ())
96
89
->method ('getFrontend ' )
97
90
->willReturn ($ this ->frontendAttribute );
98
-
99
91
$ this ->product = $ this
100
92
->getMockBuilder (Product::class)
101
93
->disableOriginalConstructor ()
102
94
->getMock ();
103
-
104
95
$ this ->product
105
96
->expects ($ this ->any ())
106
97
->method ('getAttributes ' )
107
98
->willReturn ([$ this ->attribute ]);
108
-
109
99
$ this ->product
110
100
->expects ($ this ->any ())
111
101
->method ('hasData ' )
112
102
->willReturn (true );
113
-
114
103
$ this ->context = $ this
115
104
->getMockBuilder (Context::class)
116
105
->disableOriginalConstructor ()
117
106
->getMock ();
118
-
119
107
$ this ->registry = $ this
120
108
->getMockBuilder (Registry::class)
121
109
->disableOriginalConstructor ()
122
110
->getMock ();
123
-
124
111
$ this ->registry
125
112
->expects ($ this ->any ())
126
113
->method ('registry ' )
127
114
->willReturn ($ this ->product );
128
-
129
115
$ this ->priceCurrencyInterface = $ this
130
116
->getMockBuilder (PriceCurrencyInterface::class)
131
117
->disableOriginalConstructor ()
132
118
->getMock ();
133
-
134
119
$ this ->attributesBlock = new AttributesBlock (
135
120
$ this ->context ,
136
121
$ this ->registry ,
@@ -141,34 +126,28 @@ protected function setUp()
141
126
/**
142
127
* @return void
143
128
*/
144
- public function testGetAttributesBooleanNoValue ()
129
+ public function testGetAttributeNoValue ()
145
130
{
146
- $ this ->phrase = new Phrase (__ ('' ));
147
-
131
+ $ this ->phrase = '' ;
148
132
$ this ->frontendAttribute
149
133
->expects ($ this ->any ())
150
134
->method ('getValue ' )
151
135
->willReturn ($ this ->phrase );
152
-
153
136
$ attributes = $ this ->attributesBlock ->getAdditionalData ();
154
-
155
137
$ this ->assertTrue (empty ($ attributes ['phrase ' ]));
156
138
}
157
139
158
140
/**
159
141
* @return void
160
142
*/
161
- public function testGetAttributesBooleanHasValue ()
143
+ public function testGetAttributeHasValue ()
162
144
{
163
- $ this ->phrase = new Phrase (__ ('Yes ' ));
164
-
145
+ $ this ->phrase = __ ('Yes ' );
165
146
$ this ->frontendAttribute
166
147
->expects ($ this ->any ())
167
148
->method ('getValue ' )
168
149
->willReturn ($ this ->phrase );
169
-
170
150
$ attributes = $ this ->attributesBlock ->getAdditionalData ();
171
-
172
151
$ this ->assertNotTrue (empty ($ attributes ['phrase ' ]));
173
152
$ this ->assertNotTrue (empty ($ attributes ['phrase ' ]['value ' ]));
174
153
$ this ->assertEquals ('Yes ' , $ attributes ['phrase ' ]['value ' ]);
0 commit comments