Skip to content

Commit e343a85

Browse files
committed
AC-15074: Show prefix/suffix setting ignored when set to No
1 parent 02eb60c commit e343a85

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory as HistoryCollectionFactory;
4141
use PHPUnit\Framework\MockObject\MockObject;
4242
use PHPUnit\Framework\TestCase;
43+
use Magento\Config\Model\Config\Source\Nooptreq;
4344

4445
/**
4546
* Test class for \Magento\Sales\Model\Order
@@ -439,6 +440,14 @@ public function testGetCustomerName(array $expectedData)
439440
$this->order->setCustomerMiddlename($expectedData['middle_name']);
440441
$this->order->setCustomerSuffix($expectedData['customer_suffix']);
441442
$this->order->setCustomerPrefix($expectedData['customer_prefix']);
443+
// Ensure prefix/suffix are visible to match expected strings.
444+
$this->scopeConfigMock->method('getValue')->willReturnCallback(function ($path) {
445+
if ($path === 'customer/address/prefix_show' || $path === 'customer/address/suffix_show') {
446+
return Nooptreq::VALUE_REQUIRED;
447+
}
448+
return null;
449+
});
450+
442451
$this->scopeConfigMock->expects($this->exactly($expectedData['invocation']))
443452
->method('isSetFlag')
444453
->willReturn(true);

dev/tests/integration/testsuite/Magento/Sales/Model/OrderPrefixSuffixVisibilityTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class OrderPrefixSuffixVisibilityTest extends TestCase
2525
private const XML_PATH_PREFIX_SHOW = 'customer/address/prefix_show';
2626
private const XML_PATH_SUFFIX_SHOW = 'customer/address/suffix_show';
2727

28+
/**
29+
* @var ObjectManagerInterface
30+
*/
2831
private ObjectManagerInterface $om;
2932

3033
protected function setUp(): void
@@ -93,8 +96,12 @@ private function makeOrder(string $prefix, string $first, string $last, string $
9396
return $order;
9497
}
9598

96-
private function setConfig(string $path, ?string $value, string $scope = ScopeInterface::SCOPE_STORE, string $scopeCode = 'default'): void
97-
{
99+
private function setConfig(
100+
string $path,
101+
?string $value,
102+
string $scope = ScopeInterface::SCOPE_STORE,
103+
string $scopeCode = 'default'
104+
): void {
98105
$this->om->get(MutableScopeConfigInterface::class)->setValue($path, $value, $scope, $scopeCode);
99106
}
100107
}

0 commit comments

Comments
 (0)