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

WebhookExchangeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 42
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testGettersSetters() 0 39 1
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