Skip to content

Commit fd42255

Browse files
Arrows-AC-15800-Test_Helpers: PHPUnit 12 Upgrade | Refactor helper class
1 parent 809df8a commit fd42255

File tree

3 files changed

+62
-91
lines changed

3 files changed

+62
-91
lines changed

app/code/Magento/Catalog/Test/Unit/Helper/ProductInterfaceTestHelper.php

Lines changed: 0 additions & 89 deletions
This file was deleted.

app/code/Magento/Catalog/Test/Unit/Helper/ProductTestHelper.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ class ProductTestHelper extends Product
7979
*/
8080
private $dataCallCount = 0;
8181

82+
/**
83+
* @var array
84+
*/
85+
private $customAttributes = [];
86+
87+
/**
88+
* Initialize resources
89+
*
90+
* @return void
91+
*/
92+
protected function _construct()
93+
{
94+
// Mock implementation - no actual resource initialization needed
95+
}
96+
8297
/**
8398
* Constructor
8499
*
@@ -675,4 +690,49 @@ public function getWebsiteIds()
675690
{
676691
return $this->getData('website_ids') ?: [];
677692
}
693+
694+
/**
695+
* Get custom attribute value
696+
*
697+
* @param string $attributeCode
698+
* @return mixed
699+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
700+
*/
701+
public function getCustomAttribute($attributeCode)
702+
{
703+
return $this->customAttributes[$attributeCode] ?? null;
704+
}
705+
706+
/**
707+
* Set custom attribute for testing
708+
*
709+
* @param string $attributeCode
710+
* @param mixed $attribute
711+
* @return $this
712+
*/
713+
public function setCustomAttributeForTest($attributeCode, $attribute)
714+
{
715+
$this->customAttributes[$attributeCode] = $attribute;
716+
return $this;
717+
}
718+
719+
/**
720+
* Get product options
721+
*
722+
* @return array|null
723+
*/
724+
public function getOptions()
725+
{
726+
return $this->getData('options');
727+
}
728+
729+
/**
730+
* Get attribute set ID
731+
*
732+
* @return int|null
733+
*/
734+
public function getAttributeSetId()
735+
{
736+
return $this->getData('attribute_set_id');
737+
}
678738
}

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Model\Locator\LocatorInterface;
12-
use Magento\Catalog\Test\Unit\Helper\ProductInterfaceTestHelper;
12+
use Magento\Catalog\Test\Unit\Helper\ProductTestHelper;
1313
use Magento\Store\Test\Unit\Helper\StoreInterfaceTestHelper;
1414
use Magento\Framework\Stdlib\ArrayManager;
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -58,7 +58,7 @@ protected function setUp(): void
5858
$this->objectManager = new ObjectManager($this);
5959
$this->locatorMock = $this->createMock(LocatorInterface::class);
6060
$this->productMock = $this->createPartialMock(
61-
ProductInterfaceTestHelper::class,
61+
ProductTestHelper::class,
6262
[
6363
'getId',
6464
'getTypeId',

0 commit comments

Comments
 (0)