SymfonyInteropContainerTestCase   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getContainerFromBootedKernelWith() 0 8 1
A bootKernelWith() 0 11 1
A thenIsInstanceOfExpectedClass() 0 4 1
A thenPass() 0 4 1
1
<?php declare(strict_types = 1);
2
3
namespace TomCizek\SymfonyInteropContainer\Tests\Configurators;
4
5
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\ContainerInterface;
8
use TomCizek\SymfonyInteropContainer\Tests\TestKernel;
9
10
abstract class SymfonyInteropContainerTestCase extends KernelTestCase
11
{
12
13
	/** @var ContainerBuilder */
14
	protected $container;
15
16
	/**
17
	 * @param string[]     $bundles
18
	 * @param ConfigFile[] $configFiles
19
	 *
20
	 * @return ContainerInterface
21
	 */
22
	protected function getContainerFromBootedKernelWith(
23
		array $bundles = [],
24
		array $configFiles = []
25
	): ContainerInterface {
26
		$kernel = $this->bootKernelWith($bundles, $configFiles);
27
28
		return $kernel->getContainer();
29
	}
30
31
	/**
32
	 * @param string[]     $bundles
33
	 * @param ConfigFile[] $configFiles
34
	 *
35
	 * @return TestKernel
36
	 */
37
	public function bootKernelWith(array $bundles = [], array $configFiles = []): TestKernel
38
	{
39
		$randomEnvironment = bin2hex(random_bytes(10));
40
		$kernel = new TestKernel($randomEnvironment, true);
41
42
		$kernel->addBundleClasses($bundles);
43
		$kernel->addConfigFiles($configFiles);
44
		$kernel->boot();
45
46
		return $kernel;
47
	}
48
49
	protected function thenIsInstanceOfExpectedClass($expected, $actual): void
50
	{
51
		self::assertInstanceOf($expected, $actual);
52
	}
53
54
	protected function thenPass(): void
55
	{
56
		self::assertTrue(true);
57
	}
58
}
59