Completed
Push — master ( 2604a0...14e09a )
by Joachim
02:14
created

WebhookExchangeTest::testGettersSetters()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 39
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 27
nc 1
nop 0
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