Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/code/Magento/Customer/Model/Address/AbstractAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function setData($key, $value = null)
{
if (is_array($key)) {
$key = $this->_implodeArrayField($key);
} elseif (is_array($value) && !empty($value) && $this->isAddressMultilineAttribute($key)) {
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
$value = $this->_implodeArrayValues($value);
}
return parent::setData($key, $value);
Expand Down Expand Up @@ -308,7 +308,11 @@ protected function _implodeArrayField(array $data)
*/
protected function _implodeArrayValues($value)
{
if (is_array($value) && count($value)) {
if (is_array($value)) {
if (!count($value)) {
return '';
}

$isScalar = false;
foreach ($value as $val) {
if (is_scalar($val)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ public function testGetStreetFullAlwaysReturnsString($expectedResult, $street)
$this->assertEquals($expectedResult, $this->model->getStreetFull());
}

/**
* @dataProvider getStreetFullDataProvider
*/
public function testSetDataStreetAlwaysConvertedToString($expectedResult, $street)
{
$this->model->setData('street', $street);
$this->assertEquals($expectedResult, $this->model->getData('street'));
}

/**
* @return array
*/
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Quote/Test/Unit/Model/Quote/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Test class for sales quote address model
*
* @see \Magento\Quote\Model\Quote\Address
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AddressTest extends \PHPUnit\Framework\TestCase
Expand All @@ -47,6 +48,11 @@ class AddressTest extends \PHPUnit\Framework\TestCase
*/
private $quote;

/**
* @var \Magento\Quote\Model\Quote\Address\CustomAttributeListInterface | \PHPUnit_Framework_MockObject_MockObject
*/
private $attributeList;

/**
* @var \Magento\Framework\App\Config | \PHPUnit_Framework_MockObject_MockObject
*/
Expand Down Expand Up @@ -165,9 +171,13 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$this->attributeList = $this->createMock(\Magento\Quote\Model\Quote\Address\CustomAttributeListInterface::class);
$this->attributeList->method('getAttributes')->willReturn([]);

$this->address = $objectManager->getObject(
\Magento\Quote\Model\Quote\Address::class,
[
'attributeList' => $this->attributeList,
'scopeConfig' => $this->scopeConfig,
'serializer' => $this->serializer,
'storeManager' => $this->storeManager,
Expand Down