Skip to content

Commit dfb0c46

Browse files
MAGETWO-99838: Error message '"customer address attribute" is a required value.' is absent on Storefront
- Updated unit test
1 parent 508161b commit dfb0c46

File tree

1 file changed

+18
-18
lines changed
  • app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute

1 file changed

+18
-18
lines changed

app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\Eav\Test\Unit\Model\Validator\Attribute;
810

911
/**
@@ -21,11 +23,17 @@ class DataTest extends \PHPUnit\Framework\TestCase
2123
*/
2224
private $model;
2325

26+
/**
27+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
28+
*/
29+
private $objectManager;
30+
2431
/**
2532
* @inheritdoc
2633
*/
2734
protected function setUp()
2835
{
36+
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
2937
$this->attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class)
3038
->setMethods(['create'])
3139
->setConstructorArgs(
@@ -36,8 +44,11 @@ protected function setUp()
3644
)
3745
->getMock();
3846

39-
$this->model = new \Magento\Eav\Model\Validator\Attribute\Data(
40-
$this->attrDataFactory
47+
$this->model = $this->objectManager->getObject(
48+
\Magento\Eav\Model\Validator\Attribute\Data::class,
49+
[
50+
'_attrDataFactory' => $this->attrDataFactory
51+
]
4152
);
4253
}
4354

@@ -468,7 +479,7 @@ protected function _getDataModelMock($returnValue, $argument = null)
468479
$dataModel = $this->getMockBuilder(
469480
\Magento\Eav\Model\Attribute\Data\AbstractData::class
470481
)->disableOriginalConstructor()->setMethods(
471-
['validateValue']
482+
['setExtractedData', 'validateValue']
472483
)->getMockForAbstractClass();
473484
if ($argument) {
474485
$dataModel->expects(
@@ -509,24 +520,13 @@ public function testIsValidWithoutData() : void
509520
$attributeData = ['attribute_code' => 'attribute', 'frontend_input' => 'text', 'is_visible' => true];
510521
$entity = $this->_getEntityMock();
511522
$attribute = $this->_getAttributeMock($attributeData);
512-
$this->model->setAttributes([$attribute])->setData([]);
513-
$dataModel = $this->getMockBuilder(\Magento\Eav\Model\Attribute\Data\AbstractData::class)
514-
->disableOriginalConstructor()
515-
->setMethods(['validateValue'])
516-
->getMockForAbstractClass();
517-
$dataModel->expects($this->once())
518-
->method('validateValue')
519-
// only empty string
520-
->with(
521-
$this->logicalAnd(
522-
$this->isEmpty(),
523-
$this->isType('string')
524-
)
525-
)->willReturn(true);
523+
$dataModel = $this->_getDataModelMock(true, $this->logicalAnd($this->isEmpty(), $this->isType('string')));
524+
$dataModel->expects($this->once())->method('setExtractedData')->with([])->willReturnSelf();
526525
$this->attrDataFactory->expects($this->once())
527526
->method('create')
528527
->with($attribute, $entity)
529528
->willReturn($dataModel);
530-
$this->assertEquals(true, $this->model->isValid($entity));
529+
$this->model->setAttributes([$attribute])->setData([]);
530+
$this->assertTrue($this->model->isValid($entity));
531531
}
532532
}

0 commit comments

Comments
 (0)