Skip to content

Commit 731a4fc

Browse files
author
al.kravchuk
committed
#23386: Copy Service does not works properly for Entities which extends Data Object and implements ExtensibleDataInterface.
Reformat code.
1 parent 661874a commit 731a4fc

File tree

1 file changed

+54
-28
lines changed
  • lib/internal/Magento/Framework/DataObject/Test/Unit

1 file changed

+54
-28
lines changed

lib/internal/Magento/Framework/DataObject/Test/Unit/CopyTest.php

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
use Magento\Quote\Model\Quote\Address;
1010

11+
/**
12+
* Unit tests coverage for @see \Magento\Framework\DataObject\Copy
13+
*/
1114
class CopyTest extends \PHPUnit\Framework\TestCase
1215
{
1316
/**
@@ -91,7 +94,7 @@ public function testCopyFieldsetToTargetWhenFieldExists()
9194
$data = [
9295
'target' => new \Magento\Framework\DataObject([$this->targetMock]),
9396
'source' => $this->sourceMock,
94-
'root' => 'global',
97+
'root' => 'global',
9598
];
9699
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($eventName, $data);
97100
$this->assertEquals(
@@ -124,7 +127,7 @@ public function testCopyFieldsetToTargetWhenTargetNotArray()
124127
$data = [
125128
'target' => $this->targetMock,
126129
'source' => $this->sourceMock,
127-
'root' => 'global',
130+
'root' => 'global',
128131
];
129132
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($eventName, $data);
130133
$this->assertEquals(
@@ -160,7 +163,7 @@ public function testGetCopyFieldsetToTargetWhenTargetIsArray()
160163
$data = [
161164
'target' => new \Magento\Framework\DataObject($newTarget),
162165
'source' => $this->sourceMock,
163-
'root' => 'global',
166+
'root' => 'global',
164167
];
165168
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($eventName, $data);
166169
$this->assertEquals(
@@ -178,14 +181,21 @@ public function testGetCopyFieldsetToTargetWhenTargetIsExtensibleDataInterface()
178181
->with('fieldset', 'global')
179182
->will($this->returnValue($fields));
180183

181-
$sourceMock = $this->createPartialMock(\Magento\Framework\Api\ExtensibleDataInterface::class, [
182-
'getExtensionAttributes', 'getCode'
183-
]);
184-
$targetMock = $this->createPartialMock(\Magento\Framework\Api\ExtensibleDataInterface::class, [
184+
$sourceMock = $this->createPartialMock(
185+
\Magento\Framework\Api\ExtensibleDataInterface::class,
186+
[
187+
'getExtensionAttributes',
188+
'getCode'
189+
]
190+
);
191+
$targetMock = $this->createPartialMock(
192+
\Magento\Framework\Api\ExtensibleDataInterface::class,
193+
[
185194
'getExtensionAttributes',
186195
'setCode',
187196
'setExtensionAttributes'
188-
]);
197+
]
198+
);
189199

190200
$sourceMock
191201
->expects($this->any())
@@ -224,12 +234,18 @@ public function testGetCopyFieldsetToTargetWhenTargetIsAbstractSimpleObject()
224234
->with('fieldset', 'global')
225235
->will($this->returnValue($fields));
226236

227-
$sourceMock = $this->createPartialMock(\Magento\Framework\Api\AbstractSimpleObject::class, [
237+
$sourceMock = $this->createPartialMock(
238+
\Magento\Framework\Api\AbstractSimpleObject::class,
239+
[
228240
'__toArray'
229-
]);
230-
$targetMock = $this->createPartialMock(\Magento\Framework\Api\AbstractSimpleObject::class, [
241+
]
242+
);
243+
$targetMock = $this->createPartialMock(
244+
\Magento\Framework\Api\AbstractSimpleObject::class,
245+
[
231246
'setData'
232-
]);
247+
]
248+
);
233249

234250
$sourceMock
235251
->expects($this->once())
@@ -312,15 +328,21 @@ public function testGetExtensionAttributeForDataObjectChild()
312328
->with('fieldset', 'global')
313329
->will($this->returnValue($fields));
314330

315-
$sourceMock = $this->createPartialMock(Address::class, [
316-
'getExtensionAttributes', 'getCode'
317-
]);
331+
$sourceMock = $this->createPartialMock(
332+
Address::class,
333+
[
334+
'getExtensionAttributes',
335+
'getCode'
336+
]
337+
);
318338
$targetMock = $this->createPartialMock(
319-
Address::class, [
320-
'getExtensionAttributes',
321-
'setCode',
322-
'setExtensionAttributes'
323-
]);
339+
Address::class,
340+
[
341+
'getExtensionAttributes',
342+
'setCode',
343+
'setExtensionAttributes'
344+
]
345+
);
324346

325347
$sourceMock
326348
->expects($this->any())
@@ -349,7 +371,7 @@ public function testGetExtensionAttributeForDataObjectChild()
349371
$this->assertEquals($result, $targetMock);
350372
}
351373

352-
public function testGetDataObjectFieldFromExtensbielEntity()
374+
public function testGetDataObjectFieldFromExtensibleEntity()
353375
{
354376
$fields['code']['aspect'] = '*';
355377
$this->fieldsetConfigMock
@@ -358,13 +380,18 @@ public function testGetDataObjectFieldFromExtensbielEntity()
358380
->with('fieldset', 'global')
359381
->will($this->returnValue($fields));
360382

361-
$sourceMock = $this->createPartialMock(Address::class, [
362-
'getExtensionAttributes'
363-
]);
383+
$sourceMock = $this->createPartialMock(
384+
Address::class,
385+
[
386+
'getExtensionAttributes'
387+
]
388+
);
364389
$targetMock = $this->createPartialMock(
365-
Address::class, [
366-
'getExtensionAttributes'
367-
]);
390+
Address::class,
391+
[
392+
'getExtensionAttributes'
393+
]
394+
);
368395

369396
$sourceMock
370397
->expects($this->any())
@@ -378,7 +405,6 @@ public function testGetDataObjectFieldFromExtensbielEntity()
378405
->method('getExtensionAttributes')
379406
->willReturn(null);
380407

381-
382408
$this->eventManagerMock->expects($this->once())->method('dispatch');
383409
$result = $this->copy->copyFieldsetToTarget('fieldset', 'aspect', $sourceMock, $targetMock);
384410
$this->assertEquals($result, $targetMock);

0 commit comments

Comments
 (0)