FunctionalTestCase   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 10
cp 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getContainer() 0 3 1
A setUp() 0 3 1
A mockService() 0 3 1
A doRequest() 0 3 1
A bootstrapApplication() 0 3 1
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