11
11
class PageTest extends \PHPUnit_Framework_TestCase
12
12
{
13
13
/**
14
- * @var \Magento\Cms\Model\PageRepository |\PHPUnit_Framework_MockObject_MockObject
14
+ * @var \Magento\Cms\Model\Resource\Page\CollectionFactory |\PHPUnit_Framework_MockObject_MockObject
15
15
*/
16
- protected $ pageRepositoryMock ;
17
-
18
- /**
19
- * @var \Magento\Cms\Model\Resource\PageCriteria|\PHPUnit_Framework_MockObject_MockObject
20
- */
21
- protected $ pageCriteriaFactoryMock ;
16
+ protected $ collectionFactory ;
22
17
23
18
/**
24
19
* @var \Magento\Cms\Model\Config\Source\Page
@@ -34,15 +29,8 @@ protected function setUp()
34
29
{
35
30
$ objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
36
31
37
- $ this ->pageRepositoryMock = $ this ->getMock (
38
- 'Magento\Cms\Model\PageRepository ' ,
39
- [],
40
- [],
41
- '' ,
42
- false
43
- );
44
- $ this ->pageCriteriaFactoryMock = $ this ->getMock (
45
- '\Magento\Framework\Api\SearchCriteriaInterfaceFactory ' ,
32
+ $ this ->collectionFactory = $ this ->getMock (
33
+ 'Magento\Cms\Model\Resource\Page\CollectionFactory ' ,
46
34
['create ' ],
47
35
[],
48
36
'' ,
@@ -52,8 +40,7 @@ protected function setUp()
52
40
$ this ->page = $ objectManager ->getObject (
53
41
'Magento\Cms\Model\Config\Source\Page ' ,
54
42
[
55
- 'pageRepository ' => $ this ->pageRepositoryMock ,
56
- 'pageCriteriaFactory ' => $ this ->pageCriteriaFactoryMock
43
+ 'collectionFactory ' => $ this ->collectionFactory ,
57
44
]
58
45
);
59
46
}
@@ -72,21 +59,10 @@ public function testToOptionArray()
72
59
'' ,
73
60
false
74
61
);
75
- $ pageCriteriaMock = $ this ->getMockForAbstractClass (
76
- 'Magento\Framework\Api\SearchCriteriaInterface ' ,
77
- [],
78
- '' ,
79
- false
80
- );
81
62
82
- $ this ->pageRepositoryMock ->expects ($ this ->once ())
83
- ->method ('getList ' )
84
- ->with ($ pageCriteriaMock )
85
- ->will ($ this ->returnValue ($ pageCollectionMock ));
86
-
87
- $ this ->pageCriteriaFactoryMock ->expects ($ this ->once ())
63
+ $ this ->collectionFactory ->expects ($ this ->once ())
88
64
->method ('create ' )
89
- ->will ($ this ->returnValue ($ pageCriteriaMock ));
65
+ ->will ($ this ->returnValue ($ pageCollectionMock ));
90
66
91
67
$ pageCollectionMock ->expects ($ this ->once ())
92
68
->method ('toOptionIdArray ' )
0 commit comments