1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AtlassianConnectBundle\Tests\DependencyInjection; |
6
|
|
|
|
7
|
|
|
use AtlassianConnectBundle\DependencyInjection\AtlassianConnectExtension; |
8
|
|
|
use AtlassianConnectBundle\Service\AtlassianRestClientInterface; |
9
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
use Psr\Log\LoggerInterface; |
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
13
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
14
|
|
|
use Symfony\Component\Routing\RouterInterface; |
15
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
16
|
|
|
use Twig\Environment; |
17
|
|
|
|
18
|
|
|
class AtlassianConnectExtensionTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
private AtlassianConnectExtension $extension; |
21
|
|
|
private ContainerBuilder $container; |
22
|
|
|
|
23
|
|
|
protected function setUp(): void |
24
|
|
|
{ |
25
|
|
|
$this->extension = new AtlassianConnectExtension(); |
26
|
|
|
$this->container = new ContainerBuilder(); |
27
|
|
|
$this->container->registerExtension($this->extension); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testLoadExtension(): void |
31
|
|
|
{ |
32
|
|
|
$this->container->set(RouterInterface::class, new \stdClass()); |
33
|
|
|
$this->container->set(KernelInterface::class, new \stdClass()); |
34
|
|
|
$this->container->set(TokenStorageInterface::class, new \stdClass()); |
35
|
|
|
$this->container->set(EntityManagerInterface::class, new \stdClass()); |
36
|
|
|
$this->container->set(LoggerInterface::class, new \stdClass()); |
37
|
|
|
$this->container->set(Environment::class, new \stdClass()); |
38
|
|
|
$this->container->setParameter('kernel.environment', 'test'); |
39
|
|
|
|
40
|
|
|
$this->container->prependExtensionConfig($this->extension->getAlias(), [ |
41
|
|
|
'dev_tenant' => 1, |
42
|
|
|
'descriptor' => [ |
43
|
|
|
'baseUrl' => 'https://github.com/thecatontheflat/atlassian-connect-bundle', |
44
|
|
|
'key' => 'atlassian-connect-bundle', |
45
|
|
|
], |
46
|
|
|
]); |
47
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
48
|
|
|
$this->container->compile(); |
49
|
|
|
// Check that services have been loaded |
50
|
|
|
$this->assertTrue($this->container->has(AtlassianRestClientInterface::class)); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|