71 $this->configMock = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Config::class)
72 ->disableOriginalConstructor()
73 ->setMethods([
'isNewRelicEnabled'])
75 $this->productManagementMock = $this->getMockBuilder(\
Magento\Catalog\Api\ProductManagementInterface::class)
76 ->setMethods([
'getCount'])
77 ->disableOriginalConstructor()
79 $this->configurableManagementMock = $this
81 ->setMethods([
'getCount'])
82 ->disableOriginalConstructor()
83 ->getMockForAbstractClass();
84 $this->categoryManagementMock = $this->getMockBuilder(\
Magento\Catalog\Api\CategoryManagementInterface::class)
85 ->setMethods([
'getCount'])
86 ->disableOriginalConstructor()
87 ->getMockForAbstractClass();
88 $this->countsFactoryMock = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\CountsFactory::class)
89 ->disableOriginalConstructor()
90 ->setMethods([
'create'])
92 $this->countsModelMock = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Counts::class)
93 ->setMethods([
'getCount',
'load',
'setEntityId',
'setType',
'setCount',
'setUpdatedAt',
'save'])
94 ->disableOriginalConstructor()
96 $this->countsCollectionFactoryMock = $this
98 ->disableOriginalConstructor()
99 ->setMethods([
'create'])
101 $collectionClassName = \Magento\NewRelicReporting\Model\ResourceModel\Counts\Collection::class;
102 $this->countsCollectionMock = $this->getMockBuilder($collectionClassName)
103 ->disableOriginalConstructor()
104 ->setMethods([
'addFieldToFilter',
'addOrder',
'setPageSize',
'getFirstItem'])
107 $this->countsFactoryMock->expects($this->any())
109 ->willReturn($this->countsModelMock);
110 $this->countsModelMock->expects($this->any())
113 $this->countsCollectionFactoryMock->expects($this->any())
115 ->willReturn($this->countsCollectionMock);
116 $this->countsCollectionMock->expects($this->any())
117 ->method(
'addFieldToFilter')
119 $this->countsCollectionMock->expects($this->any())
122 $this->countsCollectionMock->expects($this->any())
123 ->method(
'setPageSize')
125 $this->countsCollectionMock->expects($this->any())
126 ->method(
'getFirstItem')
127 ->willReturn($this->countsModelMock);
131 $this->productManagementMock,
132 $this->configurableManagementMock,
133 $this->categoryManagementMock,
134 $this->countsFactoryMock,
135 $this->countsCollectionFactoryMock
146 $this->configMock->expects($this->once())
147 ->method(
'isNewRelicEnabled')
152 $this->model->report()
163 $this->configMock->expects($this->once())
164 ->method(
'isNewRelicEnabled')
166 $this->productManagementMock->expects($this->exactly(2))
169 $this->configurableManagementMock->expects($this->once())
172 $this->categoryManagementMock->expects($this->once())
176 $this->countsModelMock->expects($this->any())
179 $this->countsModelMock->expects($this->any())
180 ->method(
'setEntityId')
182 $this->countsModelMock->expects($this->any())
185 $this->countsModelMock->expects($this->any())
188 $this->countsModelMock->expects($this->any())
189 ->method(
'setUpdatedAt')
191 $this->countsModelMock->expects($this->any())
197 $this->model->report()
testReportCountsTestsModuleDisabledFromConfig()
$configurableManagementMock
$countsCollectionFactoryMock