1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
/** |
4
|
|
|
* /src/Utils/Tests/RestIntegrationControllerTestCase.php |
5
|
|
|
* |
6
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
namespace App\Utils\Tests; |
9
|
|
|
|
10
|
|
|
use App\Rest\ControllerInterface; |
11
|
|
|
use App\Rest\ResponseHandlerInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class RestIntegrationControllerTestCase |
15
|
|
|
* |
16
|
|
|
* @package App\Utils\Tests |
17
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class RestIntegrationControllerTestCase extends ContainerTestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var ControllerInterface |
23
|
|
|
*/ |
24
|
|
|
protected $controller; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $controllerClass; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $resourceClass; |
35
|
|
|
|
36
|
|
|
public function setUp(): void |
37
|
|
|
{ |
38
|
|
|
parent::setUp(); |
39
|
|
|
|
40
|
|
|
$this->controller = $this->getContainer()->get($this->controllerClass); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testThatGivenControllerIsCorrect(): void |
44
|
|
|
{ |
45
|
|
|
$expected = \mb_substr((new \ReflectionClass($this))->getShortName(), 0, -4); |
46
|
|
|
|
47
|
|
|
$message = \sprintf( |
48
|
|
|
'Your REST controller integration test \'%s\' uses likely wrong controller class \'%s\'', |
49
|
|
|
\get_class($this), |
50
|
|
|
$this->controllerClass |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
static::assertSame($expected, (new \ReflectionClass($this->controller))->getShortName(), $message); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testThatGetResourceReturnsExpected(): void |
57
|
|
|
{ |
58
|
|
|
static::assertInstanceOf($this->resourceClass, $this->controller->getResource()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testThatGetResponseHandlerReturnsExpected(): void |
62
|
|
|
{ |
63
|
|
|
static::assertInstanceOf(ResponseHandlerInterface::class, $this->controller->getResponseHandler()); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|