12
12
use Magento \Catalog \Model \ResourceModel \Product \Collection as ProductCollection ;
13
13
use Magento \Catalog \Model \ResourceModel \Product \CollectionFactory as ProductCollectionFactory ;
14
14
use Magento \Framework \DataObject ;
15
- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
16
15
use PHPUnit \Framework \MockObject \MockObject ;
17
16
use PHPUnit \Framework \TestCase ;
18
17
19
18
class DuplicateUrlKeyTest extends TestCase
20
19
{
21
- /** @var ObjectManagerHelper */
22
- private $ objectManagerHelper ;
23
-
24
- protected function setUp (): void
25
- {
26
- $ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
27
- }
28
-
29
20
/**
30
21
* @dataProvider duplicatedProductUrlKeyValuesDataProvider
31
22
*
@@ -57,8 +48,12 @@ function ($productData) use ($storeId) {
57
48
$ collectionsPerStoreId = array_map (
58
49
function ($ productsData ) {
59
50
/** @var MockObject $productCollectionMock */
60
- $ productCollectionMock = $ this ->objectManagerHelper
61
- ->getCollectionMock (ProductCollection::class, $ productsData );
51
+ $ productCollectionMock = $ this ->getMockBuilder (ProductCollection::class)
52
+ ->disableOriginalConstructor ()
53
+ ->getMock ();
54
+ $ productCollectionMock ->expects ($ this ->any ())
55
+ ->method ('getIterator ' )
56
+ ->will ($ this ->returnValue (new \ArrayIterator ($ productsData )));
62
57
63
58
$ productCollectionMock ->expects ($ this ->once ())
64
59
->method ('setStoreId ' )
@@ -97,7 +92,7 @@ function ($productsData) {
97
92
$ productCollectionFactoryMock = $ this
98
93
->getMockBuilder (ProductCollectionFactory::class)
99
94
->disableOriginalConstructor ()
100
- ->setMethods (['create ' ])
95
+ ->onlyMethods (['create ' ])
101
96
->getMock ();
102
97
103
98
$ productCollectionFactoryMock ->expects ($ this ->exactly (count ($ storeIds )))
@@ -118,7 +113,7 @@ function ($productsData) {
118
113
$ attributeScopeOverriddenValueFactoryMock = $ this
119
114
->getMockBuilder (AttributeScopeOverriddenValueFactory::class)
120
115
->disableOriginalConstructor ()
121
- ->setMethods (['create ' ])
116
+ ->onlyMethods (['create ' ])
122
117
->getMock ();
123
118
$ attributeScopeOverriddenValueFactoryMock ->expects ($ this ->exactly (count ($ dbData )))
124
119
->method ('create ' )
0 commit comments