47 $this->config = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Config::class)
48 ->disableOriginalConstructor()
49 ->setMethods([
'isNewRelicEnabled'])
51 $this->systemFactory = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\SystemFactory::class)
52 ->disableOriginalConstructor()
53 ->setMethods([
'create'])
55 $this->systemModel = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\System::class)
56 ->disableOriginalConstructor()
58 $this->jsonEncoder = $this->getMockBuilder(\
Magento\Framework\Json\EncoderInterface::class)
60 $this->systemFactory->expects($this->any())
62 ->willReturn($this->systemModel);
76 public function testReportProductSavedModuleDisabledFromConfig()
79 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
80 ->disableOriginalConstructor()
82 $this->config->expects($this->once())
83 ->method(
'isNewRelicEnabled')
86 $this->model->execute($eventObserver);
94 public function testReportProductSaved()
96 $testType =
'adminProductChange';
97 $testAction =
'JSON string';
100 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
101 ->disableOriginalConstructor()
103 $this->config->expects($this->once())
104 ->method(
'isNewRelicEnabled')
106 $event = $this->getMockBuilder(\
Magento\Framework\Event::class)
107 ->setMethods([
'getProduct'])
108 ->disableOriginalConstructor()
110 $eventObserver->expects($this->once())
112 ->willReturn($event);
114 $product = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
115 ->setMethods([
'getId'])
116 ->disableOriginalConstructor()
119 $event->expects($this->once())
120 ->method(
'getProduct')
122 $this->jsonEncoder->expects($this->once())
124 ->willReturn($testAction);
125 $this->systemModel->expects($this->once())
127 ->with([
'type' => $testType,
'action' => $testAction])
129 $this->systemModel->expects($this->once())
132 $this->model->execute($eventObserver);
140 public function testReportProductUpdated()
142 $testType =
'adminProductChange';
143 $testAction =
'JSON string';
146 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
147 ->disableOriginalConstructor()
149 $this->config->expects($this->once())
150 ->method(
'isNewRelicEnabled')
152 $event = $this->getMockBuilder(\
Magento\Framework\Event::class)
153 ->setMethods([
'getProduct'])
154 ->disableOriginalConstructor()
156 $eventObserver->expects($this->once())
158 ->willReturn($event);
160 $product = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
161 ->setMethods([
'getId'])
162 ->disableOriginalConstructor()
165 $event->expects($this->once())
166 ->method(
'getProduct')
168 $this->jsonEncoder->expects($this->once())
170 ->willReturn($testAction);
171 $this->systemModel->expects($this->once())
173 ->with([
'type' => $testType,
'action' => $testAction])
175 $this->systemModel->expects($this->once())
178 $this->model->execute($eventObserver);