9 use \Magento\Setup\Fixtures\CatalogPriceRulesFixture;
19 private $fixtureModelMock;
28 $this->fixtureModelMock = $this->createMock(\
Magento\Setup\Fixtures\FixtureModel::class);
35 $storeMock = $this->createMock(\
Magento\
Store\Model\Store::class);
36 $storeMock->expects($this->once())
37 ->method(
'getRootCategoryId')
38 ->will($this->returnValue(2));
40 $websiteMock = $this->createMock(\
Magento\
Store\Model\Website::class);
41 $websiteMock->expects($this->once())
43 ->will($this->returnValue([$storeMock]));
44 $websiteMock->expects($this->once())
46 ->will($this->returnValue(
'website_id'));
48 $storeManagerMock = $this->createMock(\
Magento\
Store\Model\StoreManager::class);
49 $storeManagerMock->expects($this->once())
50 ->method(
'getWebsites')
51 ->will($this->returnValue([$websiteMock]));
54 $abstractDbMock = $this->getMockForAbstractClass(
63 $abstractDbMock->expects($this->once())
64 ->method(
'getAllChildren')
65 ->will($this->returnValue([1]));
67 $categoryMock = $this->createMock(\
Magento\Catalog\Model\Category::class);
68 $categoryMock->expects($this->once())
69 ->method(
'getResource')
70 ->will($this->returnValue($abstractDbMock));
71 $categoryMock->expects($this->once())
73 ->will($this->returnValue(
'path/to/file'));
74 $categoryMock->expects($this->once())
76 ->will($this->returnValue(
'category_id'));
78 $modelMock = $this->createMock(\
Magento\CatalogRule\Model\Rule::class);
79 $metadataMock = $this->createMock(\
Magento\Framework\EntityManager\EntityMetadata::class);
80 $metadataPoolMock = $this->createMock(\
Magento\Framework\EntityManager\MetadataPool::class);
81 $metadataMock->expects($this->once())
82 ->method(
'getLinkField')
83 ->will($this->returnValue(
'Field Id Name'));
86 [\Magento\CatalogRule\Model\Rule::class, $modelMock],
87 [\Magento\Catalog\Model\Category::class, $categoryMock],
88 [\Magento\Framework\EntityManager\MetadataPool::class, $metadataPoolMock]
91 ->expects($this->once())
92 ->method(
'getMetadata')
93 ->with(\
Magento\CatalogRule\Api\Data\RuleInterface::class)
94 ->willReturn($metadataMock);
96 $objectManagerMock->expects($this->once())
98 ->will($this->returnValue($storeManagerMock));
99 $objectManagerMock->expects($this->exactly(3))
101 ->will($this->returnValueMap($valueMap));
103 $this->fixtureModelMock
104 ->expects($this->once())
106 ->will($this->returnValue(1));
107 $this->fixtureModelMock
108 ->expects($this->exactly(4))
109 ->method(
'getObjectManager')
110 ->will($this->returnValue($objectManagerMock));
112 $this->model->execute();
117 $ruleMock = $this->createMock(\
Magento\SalesRule\Model\Rule::class);
118 $ruleMock->expects($this->never())->method(
'save');
121 $objectManagerMock->expects($this->never())
123 ->with($this->equalTo(\
Magento\SalesRule\Model\Rule::class))
124 ->willReturn($ruleMock);
126 $this->fixtureModelMock
127 ->expects($this->never())
128 ->method(
'getObjectManager')
129 ->willReturn($objectManagerMock);
130 $this->fixtureModelMock
131 ->expects($this->once())
135 $this->model->execute();
140 $this->assertSame(
'Generating catalog price rules', $this->model->getActionTitle());
146 'catalog_price_rules' =>
'Catalog Price Rules' 147 ], $this->model->introduceParamLabels());
testNoFixtureConfigValue()
testIntroduceParamLabels()