12 use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageFactory;
32 private $webhookMessageFactory;
37 private $webhookRequest;
44 $this->decoder = $this->getMockBuilder(DecoderInterface::class)
45 ->getMockForAbstractClass();
47 $this->webhookMessageFactory = $this->getMockBuilder(WebhookMessageFactory::class)
48 ->setMethods([
'create'])
49 ->disableOriginalConstructor()
52 $this->webhookRequest = $this->getMockBuilder(WebhookRequest::class)
53 ->disableOriginalConstructor()
58 $this->webhookMessageFactory
70 $decodedData = [
'status' =>
"DISMISSED",
'orderId' =>
'19418'];
72 $this->webhookRequest->expects($this->once())
74 ->willReturn($rawBody);
75 $this->webhookRequest->expects($this->once())
76 ->method(
'getEventTopic')
77 ->willReturn(
'topic');
78 $this->decoder->expects($this->once())
81 ->willReturn($decodedData);
82 $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
83 ->disableOriginalConstructor()
85 $this->webhookMessageFactory->expects($this->once())
89 'data' => $decodedData,
90 'eventTopic' => $topic
93 ->willReturn($webhookMessage);
97 $this->model->read($this->webhookRequest)
108 $this->decoder->expects($this->once())
110 ->willThrowException(
new \Exception(
'Error'));
112 $this->model->read($this->webhookRequest);