Skip to content

Commit 6af222b

Browse files
committed
MAGETWO-56206: API - inconsistency in the Magento response data types
- Remove magic toArray method for comparison of customer objects - Move test objects to more appropriate location - Fix multi-line array style
1 parent ab803e2 commit 6af222b

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ public function tearDown()
9999
*/
100100
public function testGetCustomer()
101101
{
102-
$expectedCustomerData = $this->_loadCustomer()->__toArray();
102+
$expectedCustomer = $this->_loadCustomer();
103+
$expectedCustomerData = $this->_dataObjectProcessor->buildOutputDataArray(
104+
$expectedCustomer,
105+
\Magento\Customer\Api\Data\CustomerInterface::class
106+
);
103107
$actualCustomerData = $this->_block->getCustomer()->__toArray();
104108
foreach ($expectedCustomerData as $property => $value) {
105109
$expectedValue = is_numeric($value) ? intval($value) : $value;

lib/internal/Magento/Framework/Reflection/Test/Unit/DataObjectProcessorTest.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,22 @@ protected function setUp()
6767
public function testBuildOutputDataArray($extensionAttributes, $expectedOutputDataArray)
6868
{
6969
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
70-
/** @var \Magento\Framework\Reflection\Test\Unit\_files\TestDataObject $testDataObject */
71-
$testDataObject = $objectManager->getObject(_files\TestDataObject::class, [
72-
'extensionAttributes' => $this->getMockForAbstractClass(
73-
\Magento\Framework\Api\ExtensionAttributesInterface::class
74-
)
75-
]);
70+
/** @var \Magento\Framework\Reflection\Test\Unit\TestDataObject $testDataObject */
71+
$testDataObject = $objectManager->getObject(
72+
\Magento\Framework\Reflection\Test\Unit\TestDataObject::class,
73+
[
74+
'extensionAttributes' => $this->getMockForAbstractClass(
75+
\Magento\Framework\Api\ExtensionAttributesInterface::class
76+
)
77+
]
78+
);
7679

7780
$this->extensionAttributesProcessorMock->expects($this->once())
7881
->method('buildOutputDataArray')
7982
->willReturn($extensionAttributes);
8083

8184
$outputData = $this->dataObjectProcessor
82-
->buildOutputDataArray($testDataObject, _files\TestDataInterface::class);
85+
->buildOutputDataArray($testDataObject, \Magento\Framework\Reflection\Test\Unit\TestDataInterface::class);
8386
$this->assertEquals($expectedOutputDataArray, $outputData);
8487
}
8588

@@ -100,9 +103,10 @@ public function buildOutputDataArrayDataProvider()
100103
'No Attributes' => [[], $expectedOutputDataArray],
101104
'With Attributes' => [
102105
$extensionAttributeArray,
103-
array_merge($expectedOutputDataArray, [
104-
'extension_attributes' => $extensionAttributeArray
105-
])
106+
array_merge(
107+
$expectedOutputDataArray,
108+
['extension_attributes' => $extensionAttributeArray]
109+
)
106110
]
107111
];
108112
}

lib/internal/Magento/Framework/Reflection/Test/Unit/_files/TestDataInterface.php renamed to lib/internal/Magento/Framework/Reflection/Test/Unit/TestDataInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Framework\Reflection\Test\Unit\_files;
6+
namespace Magento\Framework\Reflection\Test\Unit;
77

88
interface TestDataInterface
99
{

lib/internal/Magento/Framework/Reflection/Test/Unit/_files/TestDataObject.php renamed to lib/internal/Magento/Framework/Reflection/Test/Unit/TestDataObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Framework\Reflection\Test\Unit\_files;
6+
namespace Magento\Framework\Reflection\Test\Unit;
77

88
class TestDataObject implements TestDataInterface
99
{

0 commit comments

Comments
 (0)