Passed
Push — master ( 1b26fd...643675 )
by Matthieu
04:35
created

TenantRepositoryTest::testFindTenant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AtlassianConnectBundle\Tests\Functional\Repository;
6
7
use AtlassianConnectBundle\Entity\Tenant;
8
use AtlassianConnectBundle\Repository\TenantRepositoryInterface;
9
use AtlassianConnectBundle\Tests\Functional\KernelTestCase;
10
use Doctrine\ORM\EntityManagerInterface;
11
12
final class TenantRepositoryTest extends KernelTestCase
13
{
14
    public function testFindTenant(): void
15
    {
16
        self::bootKernel();
17
        $repository = self::getContainer()->get(TenantRepositoryInterface::class);
18
19
        $this->assertNotNull($repository->findById(1));
20
    }
21
22
    public function testFindTenantByClientKey(): void
23
    {
24
        self::bootKernel();
25
        $repository = self::getContainer()->get(TenantRepositoryInterface::class);
26
27
        $tenant = $repository->findByClientKey('client_key');
28
29
        $this->assertNotNull($tenant);
30
        $this->assertSame('client_key', $tenant->getClientKey());
31
    }
32
33
    public function testSaveTenant(): void
34
    {
35
        self::bootKernel();
36
        $repository = self::getContainer()->get(TenantRepositoryInterface::class);
37
38
        $tenant = $repository->initializeTenant();
39
        $tenant->setClientKey('new_client_key');
40
        $tenant->setAddonKey('key');
41
        $tenant->setPublicKey('key');
42
        $tenant->setSharedSecret('shared');
43
        $tenant->setServerVersion('1');
44
        $tenant->setPluginsVersion('1');
45
        $tenant->setBaseUrl('https://google.com');
46
        $tenant->setProductType('jira');
47
        $tenant->setDescription('description');
48
        $tenant->setEventType('event');
49
        $repository->save($tenant);
50
51
        self::getContainer()->get(EntityManagerInterface::class)->clear(Tenant::class);
52
53
        $this->assertNotNull($repository->findByClientKey('new_client_key'));
54
    }
55
}
56