|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
namespace AtlassianConnectBundle\Tests\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use AtlassianConnectBundle\Controller\DescriptorController; |
|
6
|
|
|
use AtlassianConnectBundle\Controller\HandshakeController; |
|
7
|
|
|
use AtlassianConnectBundle\Controller\UnlicensedController; |
|
8
|
|
|
use AtlassianConnectBundle\DependencyInjection\AtlassianConnectExtension; |
|
9
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry; |
|
10
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
use Psr\Log\LoggerInterface; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
14
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
|
15
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
16
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* AtlassianConnectExtensionTest |
|
20
|
|
|
*/ |
|
21
|
|
|
class AtlassianConnectExtensionTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var AtlassianConnectExtension |
|
25
|
|
|
*/ |
|
26
|
|
|
private $extension; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var ContainerBuilder Container builder |
|
30
|
|
|
*/ |
|
31
|
|
|
private $container; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function setUp() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->extension = new AtlassianConnectExtension(); |
|
39
|
|
|
$this->container = new ContainerBuilder(); |
|
40
|
|
|
$this->container->registerExtension($this->extension); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Test load extension |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testLoadExtension(): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->container->set(RouterInterface::class, new \stdClass()); |
|
49
|
|
|
$this->container->set(KernelInterface::class, new \stdClass()); |
|
50
|
|
|
$this->container->set(TokenStorageInterface::class, new \stdClass()); |
|
51
|
|
|
$this->container->set(ManagerRegistry::class, new \stdClass()); |
|
52
|
|
|
$this->container->set(ObjectManager::class, new \stdClass()); |
|
53
|
|
|
$this->container->set(LoggerInterface::class, new \stdClass()); |
|
54
|
|
|
$this->container->set('twig', new \stdClass()); |
|
55
|
|
|
$this->container->setParameter('kernel.environment', 'test'); |
|
56
|
|
|
|
|
57
|
|
|
$this->container->prependExtensionConfig($this->extension->getAlias(), [ |
|
58
|
|
|
'dev_tenant' => 1, |
|
59
|
|
|
'prod' => [], |
|
60
|
|
|
'dev' => [], |
|
61
|
|
|
]); |
|
62
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
|
63
|
|
|
$this->container->compile(); |
|
64
|
|
|
|
|
65
|
|
|
// Check that services have been loaded |
|
66
|
|
|
static::assertTrue($this->container->has('jwt_user_provider')); |
|
67
|
|
|
static::assertTrue($this->container->has('jwt_authenticator')); |
|
68
|
|
|
static::assertTrue($this->container->has(DescriptorController::class)); |
|
69
|
|
|
static::assertTrue($this->container->has(UnlicensedController::class)); |
|
70
|
|
|
static::assertTrue($this->container->has(HandshakeController::class)); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|