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

systemsdk / docker-symfony-api / #80

pending completion
#80

push

DKravtsov
Updated composer dependencies.

1475 of 2825 relevant lines covered (52.21%)

22.42 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
        /** @var Controller $controller */
47
        $controller = static::getContainer()->get($this->controllerClass);
×
48
        assert($controller instanceof Controller);
×
49
        $this->controller = $controller;
×
50
    }
51

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

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

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

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

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

85
    protected function getController(): Controller
86
    {
87
        return $this->controller instanceof Controller
×
88
            ? $this->controller
×
89
            : throw new UnexpectedValueException('Controller not set');
×
90
    }
91
}
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