20
20
use Magento \Framework \Api \FilterBuilder ;
21
21
use Magento \Framework \Api \SearchCriteria ;
22
22
use Magento \Framework \Api \SearchCriteriaBuilder ;
23
- use Magento \Framework \Exception \NoSuchEntityException ;
24
23
use Magento \Framework \Indexer \ActionInterface ;
25
24
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
26
25
use PHPUnit \Framework \MockObject \MockObject ;
27
26
use PHPUnit \Framework \TestCase ;
28
27
28
+ /**
29
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30
+ */
29
31
class ProductTest extends TestCase
30
32
{
31
33
/**
@@ -39,7 +41,7 @@ class ProductTest extends TestCase
39
41
private $ objectManagerHelper ;
40
42
41
43
/**
42
- * @var Configurable|\PHPUnit_Framework_MockObject_MockObject
44
+ * @var Configurable|MockObject
43
45
*/
44
46
private $ configurableMock ;
45
47
@@ -65,7 +67,6 @@ class ProductTest extends TestCase
65
67
66
68
protected function setUp (): void
67
69
{
68
- $ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
69
70
$ this ->configurableMock = $ this ->createMock (Configurable::class);
70
71
$ this ->actionMock = $ this ->getMockForAbstractClass (ActionInterface::class);
71
72
$ this ->productAttributeRepositoryMock = $ this ->getMockBuilder (ProductAttributeRepositoryInterface::class)
@@ -80,6 +81,7 @@ protected function setUp(): void
80
81
FilterBuilder::class,
81
82
['setField ' , 'setConditionType ' , 'setValue ' , 'create ' ]
82
83
);
84
+ $ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
83
85
$ this ->model = $ this ->objectManagerHelper ->getObject (
84
86
PluginResourceModelProduct::class,
85
87
[
@@ -110,11 +112,10 @@ public function testBeforeSaveConfigurable(): void
110
112
Configurable::class,
111
113
['getSetAttributes ' ]
112
114
);
113
-
114
- $ extensionAttributes = $ this ->createPartialMock (
115
- ExtensionAttributesInterface::class,
116
- ['getConfigurableProductOptions ' ]
117
- );
115
+ $ extensionAttributes = $ this ->getMockBuilder (ExtensionAttributesInterface::class)
116
+ ->disableOriginalConstructor ()
117
+ ->addMethods (['getConfigurableProductOptions ' ])
118
+ ->getMock ();
118
119
$ option = $ this ->createPartialMock (
119
120
ConfigurableAttribute::class,
120
121
['getAttributeId ' ]
@@ -142,7 +143,6 @@ public function testBeforeSaveConfigurable(): void
142
143
$ this ->searchCriteriaBuilderMock ->expects ($ this ->once ())
143
144
->method ('create ' )
144
145
->willReturn ($ searchCriteria );
145
-
146
146
$ searchResultMockClass = $ this ->createPartialMock (
147
147
ProductAttributeSearchResults::class,
148
148
['getItems ' ]
@@ -161,7 +161,6 @@ public function testBeforeSaveConfigurable(): void
161
161
$ type ->expects ($ this ->once ())
162
162
->method ('getSetAttributes ' )
163
163
->with ($ object );
164
-
165
164
$ object ->expects ($ this ->once ())
166
165
->method ('getTypeId ' )
167
166
->will ($ this ->returnValue (Configurable::TYPE_CODE ));
0 commit comments