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
|
|
|
|