|
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\App\Kernel; |
|
10
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
11
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; |
|
12
|
|
|
|
|
13
|
|
|
final class TenantRepositoryTest extends KernelTestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function testFindTenant(): void |
|
16
|
|
|
{ |
|
17
|
|
|
self::bootKernel(); |
|
18
|
|
|
$repository = self::getContainer()->get(TenantRepositoryInterface::class); |
|
19
|
|
|
|
|
20
|
|
|
$this->assertNotNull($repository->findById(1)); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function testFindTenantByClientKey(): void |
|
24
|
|
|
{ |
|
25
|
|
|
self::bootKernel(); |
|
26
|
|
|
$repository = self::getContainer()->get(TenantRepositoryInterface::class); |
|
27
|
|
|
|
|
28
|
|
|
$tenant = $repository->findByClientKey('client_key'); |
|
29
|
|
|
|
|
30
|
|
|
$this->assertNotNull($tenant); |
|
31
|
|
|
$this->assertSame('client_key', $tenant->getClientKey()); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testSaveTenant(): void |
|
35
|
|
|
{ |
|
36
|
|
|
self::bootKernel(); |
|
37
|
|
|
$repository = self::getContainer()->get(TenantRepositoryInterface::class); |
|
38
|
|
|
|
|
39
|
|
|
$tenant = $repository->initializeTenant(); |
|
40
|
|
|
$tenant->setClientKey('new_client_key'); |
|
41
|
|
|
$tenant->setAddonKey('key'); |
|
42
|
|
|
$tenant->setPublicKey('key'); |
|
43
|
|
|
$tenant->setSharedSecret('shared'); |
|
44
|
|
|
$tenant->setServerVersion('1'); |
|
45
|
|
|
$tenant->setPluginsVersion('1'); |
|
46
|
|
|
$tenant->setBaseUrl('https://google.com'); |
|
47
|
|
|
$tenant->setProductType('jira'); |
|
48
|
|
|
$tenant->setDescription('description'); |
|
49
|
|
|
$tenant->setEventType('event'); |
|
50
|
|
|
$repository->save($tenant); |
|
51
|
|
|
|
|
52
|
|
|
self::getContainer()->get(EntityManagerInterface::class)->clear(Tenant::class); |
|
53
|
|
|
|
|
54
|
|
|
$this->assertNotNull($repository->findByClientKey('new_client_key')); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
protected static function getKernelClass(): string |
|
58
|
|
|
{ |
|
59
|
|
|
return Kernel::class; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|