|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Tests\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\WebhookExchange; |
|
7
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\WebhookQueueItem; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class WebhookExchangeTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testGettersSetters() |
|
13
|
|
|
{ |
|
14
|
|
|
$url = 'https://www.example.com'; |
|
15
|
|
|
|
|
16
|
|
|
$entity = new WebhookExchange($url); |
|
17
|
|
|
|
|
18
|
|
|
$this->assertSame(0, $entity->getId()); |
|
19
|
|
|
$this->assertSame($url, $entity->getUrl()); |
|
20
|
|
|
$this->assertSame(0, $entity->getLastEventId()); |
|
21
|
|
|
|
|
22
|
|
|
$webhookQueueItem = new WebhookQueueItem('content', new WebhookExchange('https://www.example.com')); |
|
23
|
|
|
$entity |
|
24
|
|
|
->setId(10) |
|
25
|
|
|
->setLastEventId(1) |
|
26
|
|
|
->setUrl('https://www.example.dk') |
|
27
|
|
|
->addWebhookQueueItem($webhookQueueItem) |
|
28
|
|
|
; |
|
29
|
|
|
|
|
30
|
|
|
$this->assertSame(10, $entity->getId()); |
|
31
|
|
|
$this->assertSame('https://www.example.dk', $entity->getUrl()); |
|
32
|
|
|
$this->assertSame(1, $entity->getLastEventId()); |
|
33
|
|
|
$this->assertCount(1, $entity->getWebhookQueueItems()); |
|
34
|
|
|
$this->assertSame($webhookQueueItem, $entity->getWebhookQueueItems()->first()); |
|
35
|
|
|
|
|
36
|
|
|
$webhookQueueItems = new ArrayCollection([ |
|
37
|
|
|
new WebhookQueueItem('content', new WebhookExchange('https://www.example.com')), |
|
38
|
|
|
new WebhookQueueItem('content', new WebhookExchange('https://www.example.com')), |
|
39
|
|
|
]); |
|
40
|
|
|
|
|
41
|
|
|
$entity |
|
42
|
|
|
->setId(10) |
|
43
|
|
|
->setLastEventId(1) |
|
44
|
|
|
->setUrl('https://www.example.dk') |
|
45
|
|
|
->setWebhookQueueItems($webhookQueueItems) |
|
46
|
|
|
; |
|
47
|
|
|
|
|
48
|
|
|
$this->assertCount(2, $entity->getWebhookQueueItems()); |
|
49
|
|
|
$this->assertSame($webhookQueueItems, $entity->getWebhookQueueItems()); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|