• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemsdk / docker-symfony-api / #83

pending completion
#83

push

DKravtsov
Updated composer dependencies, refactoring.

45 of 45 new or added lines in 12 files covered. (100.0%)

1483 of 2844 relevant lines covered (52.14%)

22.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/General/Transport/Utils/Tests/RestIntegrationControllerTestCase.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\General\Transport\Utils\Tests;
6

7
use App\General\Transport\Rest\Controller;
8
use ReflectionClass;
9
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
10
use UnexpectedValueException;
11

12
use function assert;
13
use function gc_collect_cycles;
14
use function gc_enable;
15
use function mb_substr;
16
use function sprintf;
17

18
/**
19
 * Class RestIntegrationControllerTestCase
20
 *
21
 * @package App\General
22
 */
23
abstract class RestIntegrationControllerTestCase extends KernelTestCase
24
{
25
    protected ?Controller $controller = null;
26

27
    /**
28
     * @var class-string
29
     */
30
    protected string $controllerClass;
31

32
    /**
33
     * @var class-string
34
     */
35
    protected string $resourceClass;
36

37
    /**
38
     * {@inheritdoc}
39
     */
40
    protected function setUp(): void
41
    {
42
        gc_enable();
×
43

44
        parent::setUp();
×
45

46
        $controller = static::getContainer()->get($this->controllerClass);
×
47
        assert($controller instanceof Controller);
×
48
        $this->controller = $controller;
×
49
    }
50

51
    /**
52
     * {@inheritdoc}
53
     */
54
    protected function tearDown(): void
55
    {
56
        parent::tearDown();
×
57

58
        unset($this->controller);
×
59
        gc_collect_cycles();
×
60
    }
61

62
    public function testThatGivenControllerIsCorrect(): void
63
    {
64
        $expected = mb_substr((new ReflectionClass($this))->getShortName(), 0, -4);
×
65
        $message = sprintf(
×
66
            'Your REST controller integration test \'%s\' uses likely wrong controller class \'%s\'',
×
67
            static::class,
×
68
            $this->controllerClass
×
69
        );
×
70

71
        static::assertSame($expected, (new ReflectionClass($this->getController()))->getShortName(), $message);
×
72
    }
73

74
    /**
75
     * This test is to make sure that controller has set the expected resource. There is multiple resources and each
76
     * controller needs to use specified one.
77
     */
78
    public function testThatGetResourceReturnsExpected(): void
79
    {
80
        /** @noinspection UnnecessaryAssertionInspection */
81
        static::assertInstanceOf($this->resourceClass, $this->getController()->getResource());
×
82
    }
83

84
    protected function getController(): Controller
85
    {
86
        return $this->controller instanceof Controller
×
87
            ? $this->controller
×
88
            : throw new UnexpectedValueException('Controller not set');
×
89
    }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc