Skip to content

Commit 5905097

Browse files
committed
Merge remote-tracking branch '38073/fix-for-issue-37953' into bt_comm_pr_247beta3
2 parents 928d622 + a0852aa commit 5905097

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

app/code/Magento/Eav/Model/Entity/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ public function getStoreLabels()
489489
*/
490490
public function getStoreLabel($storeId = null)
491491
{
492-
if ($this->hasData('store_label')) {
492+
if ($this->hasData('store_label') && $storeId === null) {
493493
return $this->getData('store_label');
494494
}
495495
$store = $this->_storeManager->getStore($storeId);

app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\Eav\Model\Entity\Attribute\FrontendLabel;
1212
use Magento\Eav\Model\Entity\Attribute\FrontendLabelFactory;
1313
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
use Magento\Store\Api\Data\StoreInterface;
15+
use Magento\Store\Model\StoreManagerInterface;
1416
use PHPUnit\Framework\MockObject\MockObject;
1517
use PHPUnit\Framework\TestCase;
1618

@@ -41,6 +43,28 @@ protected function tearDown(): void
4143
$this->_model = null;
4244
}
4345

46+
/**
47+
* @return void
48+
*/
49+
public function testGetStoreLabel(): void
50+
{
51+
$objectManager = new ObjectManager($this);
52+
$storeMock = $this->createMock(StoreInterface::class);
53+
$storeManagerMock = $this->createMock(StoreManagerInterface::class);
54+
$storeManagerMock->method('getStore')->willReturn($storeMock);
55+
$resource = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute::class)
56+
->setMethods(['getStoreLabelsByAttributeId'])
57+
->disableOriginalConstructor()
58+
->getMock();
59+
$arguments = [
60+
'_resource' => $resource,
61+
'storeManager' => $storeManagerMock,
62+
];
63+
$this->_model = $objectManager->getObject(Attribute::class, $arguments);
64+
65+
$this->assertEmpty($this->_model->getStoreLabel());
66+
}
67+
4468
/**
4569
* @param string $givenFrontendInput
4670
* @param string $expectedBackendType

0 commit comments

Comments
 (0)