13
13
use Magento \Customer \Ui \Component \DataProvider \Document ;
14
14
use Magento \Framework \Api \AttributeValue ;
15
15
use Magento \Framework \Api \AttributeValueFactory ;
16
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
17
+ use Magento \Framework \Phrase ;
16
18
use Magento \Store \Api \Data \WebsiteInterface ;
17
19
use Magento \Store \Model \StoreManagerInterface ;
18
20
use PHPUnit_Framework_MockObject_MockObject as MockObject ;
@@ -44,6 +46,11 @@ class DocumentTest extends \PHPUnit\Framework\TestCase
44
46
*/
45
47
private $ storeManager ;
46
48
49
+ /**
50
+ * @var ScopeConfigInterface|MockObject
51
+ */
52
+ private $ scopeConfig ;
53
+
47
54
/**
48
55
* @var Document
49
56
*/
@@ -59,11 +66,14 @@ protected function setUp()
59
66
60
67
$ this ->storeManager = $ this ->getMockForAbstractClass (StoreManagerInterface::class);
61
68
69
+ $ this ->scopeConfig = $ this ->getMockForAbstractClass (ScopeConfigInterface::class);
70
+
62
71
$ this ->document = new Document (
63
72
$ this ->attributeValueFactory ,
64
73
$ this ->groupRepository ,
65
74
$ this ->customerMetadata ,
66
- $ this ->storeManager
75
+ $ this ->storeManager ,
76
+ $ this ->scopeConfig
67
77
);
68
78
}
69
79
@@ -156,6 +166,42 @@ public function testGetWebsiteAttribute()
156
166
static ::assertEquals ('Main Website ' , $ attribute ->getValue ());
157
167
}
158
168
169
+ /**
170
+ * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute
171
+ */
172
+ public function testGetConfirmationAttribute ()
173
+ {
174
+ $ websiteId = 1 ;
175
+ $ this ->document ->setData ('original_website_id ' , $ websiteId );
176
+
177
+ $ this ->scopeConfig ->expects (static ::once ())
178
+ ->method ('getValue ' )
179
+ ->with ()
180
+ ->willReturn (true );
181
+
182
+ $ this ->document ->setData ('confirmation ' , null );
183
+ $ attribute = $ this ->document ->getCustomAttribute ('confirmation ' );
184
+
185
+ $ value = $ attribute ->getValue ();
186
+ static ::assertInstanceOf (Phrase::class, $ value );
187
+ static ::assertEquals ('Confirmed ' , (string )$ value );
188
+ }
189
+
190
+
191
+ /**
192
+ * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute
193
+ */
194
+ public function testGetAccountLockValue ()
195
+ {
196
+ $ this ->document ->setData ('lock_expires ' , null );
197
+
198
+ $ attribute = $ this ->document ->getCustomAttribute ('lock_expires ' );
199
+
200
+ $ value = $ attribute ->getValue ();
201
+ static ::assertInstanceOf (Phrase::class, $ value );
202
+ static ::assertEquals ('Unlocked ' , (string )$ value );
203
+ }
204
+
159
205
/**
160
206
* Create mock for attribute value factory
161
207
* @return void
0 commit comments