Skip to content

Commit 51e41ac

Browse files
#10765 Add tests for added methods
1 parent 1c2e841 commit 51e41ac

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Magento\Customer\Ui\Component\DataProvider\Document;
1414
use Magento\Framework\Api\AttributeValue;
1515
use Magento\Framework\Api\AttributeValueFactory;
16+
use Magento\Framework\App\Config\ScopeConfigInterface;
17+
use Magento\Framework\Phrase;
1618
use Magento\Store\Api\Data\WebsiteInterface;
1719
use Magento\Store\Model\StoreManagerInterface;
1820
use PHPUnit_Framework_MockObject_MockObject as MockObject;
@@ -44,6 +46,11 @@ class DocumentTest extends \PHPUnit\Framework\TestCase
4446
*/
4547
private $storeManager;
4648

49+
/**
50+
* @var ScopeConfigInterface|MockObject
51+
*/
52+
private $scopeConfig;
53+
4754
/**
4855
* @var Document
4956
*/
@@ -59,11 +66,14 @@ protected function setUp()
5966

6067
$this->storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class);
6168

69+
$this->scopeConfig = $this->getMockForAbstractClass(ScopeConfigInterface::class);
70+
6271
$this->document = new Document(
6372
$this->attributeValueFactory,
6473
$this->groupRepository,
6574
$this->customerMetadata,
66-
$this->storeManager
75+
$this->storeManager,
76+
$this->scopeConfig
6777
);
6878
}
6979

@@ -156,6 +166,42 @@ public function testGetWebsiteAttribute()
156166
static::assertEquals('Main Website', $attribute->getValue());
157167
}
158168

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+
159205
/**
160206
* Create mock for attribute value factory
161207
* @return void

0 commit comments

Comments
 (0)