1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace Bukashk0zzz\FilterBundle\Tests\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use AtlassianConnectBundle\Controller\HandshakeController; |
6
|
|
|
use AtlassianConnectBundle\Entity\Tenant; |
7
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
8
|
|
|
use Doctrine\Common\Persistence\ObjectRepository; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
11
|
|
|
use Symfony\Component\HttpKernel\Log\Logger; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* HandshakeControllerTest |
15
|
|
|
*/ |
16
|
|
|
class HandshakeControllerTest extends TestCase |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Test |
20
|
|
|
*/ |
21
|
|
|
public function testIndexAction(): void |
22
|
|
|
{ |
23
|
|
|
$tenantRepository = $this->getMockBuilder(ObjectRepository::class)->setMethods(['findOneByClientKey'])->getMockForAbstractClass(); |
24
|
|
|
$tenantRepository->expects($this->any()) |
25
|
|
|
->method('findOneByClientKey') |
26
|
|
|
->willReturn(null); |
27
|
|
|
|
28
|
|
|
$objectManager = $this->createMock(ObjectManager::class); |
29
|
|
|
$objectManager->expects($this->any()) |
30
|
|
|
->method('getRepository') |
31
|
|
|
->willReturn($tenantRepository); |
32
|
|
|
|
33
|
|
|
$controller = new HandshakeController($objectManager, new Logger(), Tenant::class); |
34
|
|
|
$request = new Request([], [], [], [], [], [], \json_encode([ |
35
|
|
|
'key' => 'test', |
36
|
|
|
'clientKey' => 'test', |
37
|
|
|
'publicKey' => 'test', |
38
|
|
|
'sharedSecret' => 'test', |
39
|
|
|
'serverVersion' => 'test', |
40
|
|
|
'pluginsVersion' => 'test', |
41
|
|
|
'baseUrl' => 'test', |
42
|
|
|
'productType' => 'test', |
43
|
|
|
'description' => 'test', |
44
|
|
|
'eventType' => 'test', |
45
|
|
|
])); |
46
|
|
|
|
47
|
|
|
$response = $controller->registerAction($request); |
48
|
|
|
self::assertEquals(200, $response->getStatusCode()); |
49
|
|
|
self::assertEquals('OK', $response->getContent()); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|