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 testReportProductDeletedModuleDisabledFromConfig()
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 testReportProductDeleted()
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);
113 $product = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
114 ->setMethods([
'getId'])
115 ->disableOriginalConstructor()
117 $event->expects($this->once())
118 ->method(
'getProduct')
120 $this->jsonEncoder->expects($this->once())
122 ->willReturn($testAction);
123 $this->systemModel->expects($this->once())
125 ->with([
'type' => $testType,
'action' => $testAction])
127 $this->systemModel->expects($this->once())
130 $this->model->execute($eventObserver);