FunctionalTestCase::getContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Testing;
6
7
use Exception;
8
use PHPUnit\Framework\TestCase;
9
use Psr\Container\ContainerInterface;
10
11
abstract class FunctionalTestCase extends TestCase
12
{
13
    protected ?FunctionalTester $tester;
14
15
    protected function setUp(): void
16
    {
17
        $this->tester = new FunctionalTester();
18
    }
19
20
    public function mockService(string $id, mixed $definition): void
21
    {
22
        $this->tester?->mockService($id, $definition);
23
    }
24
25
    protected function bootstrapApplication(?string $projectRootPath = null): void
26
    {
27
        $this->tester?->bootstrapApplication($projectRootPath);
28
    }
29
30
    protected function doRequest(string $method, string $url): ResponseAccessor
31
    {
32
        return $this->tester?->doRequest($method, $url) ?? throw new Exception('Either $tester or $response is null');
33
    }
34
35
    protected function getContainer(): ContainerInterface
36
    {
37
        return $this->tester?->getContainer() ?? throw new Exception('Either $tester or $container is null');
38
    }
39
}
40