-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathInvalidControllerTypeShouldTriggerDispatchErrorTest.php
More file actions
36 lines (29 loc) · 1.13 KB
/
InvalidControllerTypeShouldTriggerDispatchErrorTest.php
File metadata and controls
36 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace LaminasTest\Mvc\Application;
use Laminas\Mvc\Application;
use Laminas\Mvc\MvcEvent;
use PHPUnit\Framework\TestCase;
class InvalidControllerTypeShouldTriggerDispatchErrorTest extends TestCase
{
use InvalidControllerTypeTrait;
/**
* @group error-handling
*/
public function testInvalidControllerTypeShouldTriggerDispatchError()
{
$application = $this->prepareApplication();
$response = $application->getResponse();
$events = $application->getEventManager();
$events->attach(MvcEvent::EVENT_DISPATCH_ERROR, static function ($e) use ($response) {
$error = $e->getError();
$controller = $e->getController();
$class = $e->getControllerClass();
$response->setContent("Code: " . $error . '; Controller: ' . $controller . '; Class: ' . $class);
return $response;
});
$application->run();
self::assertStringContainsString(Application::ERROR_CONTROLLER_INVALID, $response->getContent());
self::assertStringContainsString('bad', $response->getContent());
}
}