/
IntegrationViaErrorPreviewConsoleControllerWithDoctrineORMModuleSpec.php
98 lines (72 loc) · 2.77 KB
/
IntegrationViaErrorPreviewConsoleControllerWithDoctrineORMModuleSpec.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
namespace ErrorHeroModule\Spec;
use Doctrine\ORM\EntityManager;
use ErrorHeroModule;
use ErrorHeroModule\Controller\ErrorPreviewConsoleController;
use Kahlan\Plugin\Quit;
use Kahlan\QuitException;
use Zend\Console\Console;
use Zend\Mvc\Application;
describe('Integration via ErrorPreviewConsoleController with doctrine', function () {
given('application', function () {
Console::overrideIsConsole(true);
$application = Application::init([
'modules' => [
'Zend\Router',
'DoctrineModule',
'DoctrineORMModule',
'ErrorHeroModule',
],
'module_listener_options' => [
'config_glob_paths' => [
realpath(__DIR__).'/../Fixture/config/autoload-with-doctrine/error-hero-module.local.php',
realpath(__DIR__).'/../Fixture/config/module.local.php',
],
],
]);
$events = $application->getEventManager();
$serviceManager = $application->getServiceManager();
$serviceManager->get('SendResponseListener')
->detach($events);
$entityManager = $serviceManager->get(EntityManager::class);
$stmt = $entityManager->getConnection()->prepare('DELETE FROM log');
$stmt->execute();
return $application;
});
describe('error-preview', function() {
it('show error page', function() {
Quit::disable();
$_SERVER['argv'] = [
__FILE__,
'error-preview',
'controller' => ErrorPreviewConsoleController::class,
'action' => 'exception',
];
ob_start();
$closure = function () {
$this->application->run();
};
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));
$content = ob_get_clean();
expect($content)->toContain('|We have encountered a problem and we can not fulfill your request');
});
});
describe('error-preview error', function() {
it('show error page', function() {
Quit::disable();
$_SERVER['argv'] = [
__FILE__,
'error-preview',
'controller' => ErrorPreviewConsoleController::class,
'action' => 'error',
];
ob_start();
$closure = function () {
$this->application->run();
};
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));
$content = ob_get_clean();
expect($content)->toContain('|We have encountered a problem and we can not fulfill your request');
});
});
});