Skip to content

Commit 4a1fa1a

Browse files
committed
add test cases for middlename
1 parent b6b2ad4 commit 4a1fa1a

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

app/code/Magento/Sales/Model/Order.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,17 +2039,17 @@ public function getCustomerName()
20392039

20402040
$customerName = '';
20412041
$prefix = $this->getCustomerPrefix();
2042-
if (($prefix !== null) && $this->isVisibleCustomerPrefix() && strlen($prefix)) {
2042+
if ($prefix !== null && $this->isVisibleCustomerPrefix() && strlen($prefix)) {
20432043
$customerName .= $prefix . ' ';
20442044
}
20452045
$customerName .= $this->getCustomerFirstname();
20462046
$middlename = $this->getCustomerMiddlename();
2047-
if (($middlename !== null) && $this->isVisibleCustomerMiddlename() && strlen($middlename)) {
2047+
if ($middlename !== null && $this->isVisibleCustomerMiddlename() && strlen($middlename)) {
20482048
$customerName .= ' ' . $middlename;
20492049
}
20502050
$customerName .= ' ' . $this->getCustomerLastname();
20512051
$suffix = $this->getCustomerSuffix();
2052-
if (($suffix !== null) && $this->isVisibleCustomerSuffix() && strlen($suffix)) {
2052+
if ($suffix !== null && $this->isVisibleCustomerSuffix() && strlen($suffix)) {
20532053
$customerName .= ' ' . $suffix;
20542054
}
20552055

app/code/Magento/Sales/Test/Unit/Model/OrderTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,12 @@ public function testCanInvoice()
401401
public function testGetCustomerName(array $expectedData)
402402
{
403403
$this->order->setCustomerFirstname($expectedData['first_name']);
404+
$this->order->setCustomerMiddlename($expectedData['middle_name']);
404405
$this->order->setCustomerSuffix($expectedData['customer_suffix']);
405406
$this->order->setCustomerPrefix($expectedData['customer_prefix']);
407+
$this->scopeConfigMock->expects($this->exactly($expectedData['invocation']))
408+
->method('isSetFlag')
409+
->willReturn(true);
406410
$this->assertEquals($expectedData['expected_name'], $this->order->getCustomerName());
407411
}
408412

@@ -416,6 +420,8 @@ public function customerNameProvider()
416420
[
417421
[
418422
'first_name' => null,
423+
'invocation' => 0,
424+
'middle_name' => null,
419425
'expected_name' => 'Guest',
420426
'customer_suffix' => 'smith',
421427
'customer_prefix' => 'mr.'
@@ -424,10 +430,22 @@ public function customerNameProvider()
424430
[
425431
[
426432
'first_name' => 'Smith',
433+
'invocation' => 0,
434+
'middle_name' => null,
427435
'expected_name' => 'mr. Smith Carl',
428436
'customer_suffix' => 'Carl',
429437
'customer_prefix' => 'mr.'
430438
]
439+
],
440+
[
441+
[
442+
'first_name' => 'John',
443+
'invocation' => 1,
444+
'middle_name' => 'Middle',
445+
'expected_name' => 'mr. John Middle Carl',
446+
'customer_suffix' => 'Carl',
447+
'customer_prefix' => 'mr.'
448+
]
431449
]
432450
];
433451
}

0 commit comments

Comments
 (0)