-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
127 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Adyen\Payment\Test\Unit\Model\Queue\Notification; | ||
|
||
use Adyen\Payment\Helper\Webhook; | ||
use Adyen\Payment\Logger\AdyenLogger; | ||
use Adyen\Payment\Model\Notification; | ||
use Adyen\Payment\Model\Queue\Notification\Consumer; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Exception; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class ConsumerTest extends AbstractAdyenTestCase | ||
{ | ||
/** @var Webhook|MockObject $webhookMock */ | ||
private $webhookMock; | ||
|
||
/** @var AdyenLogger|MockObject $adyenLoggerMock */ | ||
private $adyenLoggerMock; | ||
|
||
/** @var Notification|MockObject $notificationMock */ | ||
private $notificationMock; | ||
|
||
/** @var Consumer $consumer */ | ||
private $consumer; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->webhookMock = $this->createMock(Webhook::class); | ||
$this->adyenLoggerMock = $this->createMock(AdyenLogger::class); | ||
$this->notificationMock = $this->createMock(Notification::class); | ||
$this->consumer = new Consumer($this->webhookMock, $this->adyenLoggerMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws Exception | ||
*/ | ||
public function testExecute(): void | ||
{ | ||
$this->webhookMock->expects($this->once()) | ||
->method('processNotification') | ||
->with($this->notificationMock) | ||
->willReturn(true); | ||
|
||
$this->assertTrue($this->consumer->execute($this->notificationMock)); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws Exception | ||
*/ | ||
public function testExecuteThrowsException(): void | ||
{ | ||
$this->webhookMock->expects($this->once()) | ||
->method('processNotification') | ||
->with($this->notificationMock) | ||
->willThrowException(new Exception()); | ||
$this->adyenLoggerMock->expects($this->once())->method('addAdyenWarning'); | ||
|
||
$this->expectException(Exception::class); | ||
$this->consumer->execute($this->notificationMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Adyen\Payment\Test\Unit\Model\Queue\Notification; | ||
|
||
use Adyen\Payment\Model\Notification; | ||
use Adyen\Payment\Model\Queue\Notification\Publisher; | ||
use Adyen\Payment\Model\ResourceModel\Notification as NotificationResourceModel; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Exception; | ||
use Magento\Framework\MessageQueue\PublisherInterface; | ||
|
||
class PublisherTest extends AbstractAdyenTestCase | ||
{ | ||
/** | ||
* @return void | ||
* @throws Exception | ||
*/ | ||
public function testExecute(): void | ||
{ | ||
$publisherMock = $this->createMock(PublisherInterface::class); | ||
$notificationResourceMock = $this->createMock(NotificationResourceModel::class); | ||
$notificationMock = $this->createMock(Notification::class); | ||
|
||
$notificationMock->expects($this->once())->method('setProcessing')->with(true); | ||
$notificationResourceMock->expects($this->once())->method('save')->with($notificationMock); | ||
$publisherMock->expects($this->once())->method('publish')->with(Publisher::TOPIC_NAME, $notificationMock); | ||
|
||
$publisher = new Publisher($publisherMock, $notificationResourceMock); | ||
$publisher->execute($notificationMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd"> | ||
<publisher topic="adyen.notification"> | ||
<connection name="amqp" exchange="magento"/> | ||
</publisher> | ||
<publisher topic="adyen.notification"/> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters