2020use Magento \Framework \Api \FilterBuilder ;
2121use Magento \Framework \Api \SearchCriteria ;
2222use Magento \Framework \Api \SearchCriteriaBuilder ;
23- use Magento \Framework \Exception \NoSuchEntityException ;
2423use Magento \Framework \Indexer \ActionInterface ;
2524use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
2625use PHPUnit \Framework \MockObject \MockObject ;
2726use PHPUnit \Framework \TestCase ;
2827
28+ /**
29+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30+ */
2931class ProductTest extends TestCase
3032{
3133 /**
@@ -39,7 +41,7 @@ class ProductTest extends TestCase
3941 private $ objectManagerHelper ;
4042
4143 /**
42- * @var Configurable|\PHPUnit_Framework_MockObject_MockObject
44+ * @var Configurable|MockObject
4345 */
4446 private $ configurableMock ;
4547
@@ -65,7 +67,6 @@ class ProductTest extends TestCase
6567
6668 protected function setUp (): void
6769 {
68- $ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
6970 $ this ->configurableMock = $ this ->createMock (Configurable::class);
7071 $ this ->actionMock = $ this ->getMockForAbstractClass (ActionInterface::class);
7172 $ this ->productAttributeRepositoryMock = $ this ->getMockBuilder (ProductAttributeRepositoryInterface::class)
@@ -80,6 +81,7 @@ protected function setUp(): void
8081 FilterBuilder::class,
8182 ['setField ' , 'setConditionType ' , 'setValue ' , 'create ' ]
8283 );
84+ $ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
8385 $ this ->model = $ this ->objectManagerHelper ->getObject (
8486 PluginResourceModelProduct::class,
8587 [
@@ -110,11 +112,10 @@ public function testBeforeSaveConfigurable(): void
110112 Configurable::class,
111113 ['getSetAttributes ' ]
112114 );
113-
114- $ extensionAttributes = $ this ->createPartialMock (
115- ExtensionAttributesInterface::class,
116- ['getConfigurableProductOptions ' ]
117- );
115+ $ extensionAttributes = $ this ->getMockBuilder (ExtensionAttributesInterface::class)
116+ ->disableOriginalConstructor ()
117+ ->addMethods (['getConfigurableProductOptions ' ])
118+ ->getMock ();
118119 $ option = $ this ->createPartialMock (
119120 ConfigurableAttribute::class,
120121 ['getAttributeId ' ]
@@ -142,7 +143,6 @@ public function testBeforeSaveConfigurable(): void
142143 $ this ->searchCriteriaBuilderMock ->expects ($ this ->once ())
143144 ->method ('create ' )
144145 ->willReturn ($ searchCriteria );
145-
146146 $ searchResultMockClass = $ this ->createPartialMock (
147147 ProductAttributeSearchResults::class,
148148 ['getItems ' ]
@@ -161,7 +161,6 @@ public function testBeforeSaveConfigurable(): void
161161 $ type ->expects ($ this ->once ())
162162 ->method ('getSetAttributes ' )
163163 ->with ($ object );
164-
165164 $ object ->expects ($ this ->once ())
166165 ->method ('getTypeId ' )
167166 ->will ($ this ->returnValue (Configurable::TYPE_CODE ));
0 commit comments