|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace ErrorHeroModule\Spec\Integration; |
| 4 | + |
| 5 | +use ErrorHeroModule\Command\Preview\ErrorPreviewConsoleCommand; |
| 6 | +use Laminas\Db\Adapter\AdapterInterface; |
| 7 | +use Laminas\Db\ResultSet\ResultSet; |
| 8 | +use Laminas\Db\TableGateway\TableGateway; |
| 9 | +use Laminas\Mvc\Application; |
| 10 | +use Symfony\Component\Console\Tester\CommandTester; |
| 11 | +use Kahlan\Plugin\Quit; |
| 12 | +use Kahlan\QuitException; |
| 13 | +use Throwable; |
| 14 | + |
| 15 | +describe('Integration via ErrorPreviewConsoleController', function (): void { |
| 16 | + |
| 17 | + given('application', function () { |
| 18 | + |
| 19 | + $application = Application::init([ |
| 20 | + 'modules' => [ |
| 21 | + 'Laminas\Router', |
| 22 | + 'Laminas\Db', |
| 23 | + 'ErrorHeroModule', |
| 24 | + ], |
| 25 | + 'module_listener_options' => [ |
| 26 | + 'config_glob_paths' => [ |
| 27 | + \realpath(__DIR__).'/../Fixture/config/autoload-for-specific-error-and-exception/error-hero-module.local.php', |
| 28 | + \realpath(__DIR__).'/../Fixture/config/module.local.php', |
| 29 | + ], |
| 30 | + ], |
| 31 | + ]); |
| 32 | + |
| 33 | + $serviceManager = $application->getServiceManager(); |
| 34 | + $db = $serviceManager->get(AdapterInterface::class); |
| 35 | + $tableGateway = new TableGateway('log', $db, null, new ResultSet()); |
| 36 | + $tableGateway->delete([]); |
| 37 | + |
| 38 | + return $application; |
| 39 | + |
| 40 | + }); |
| 41 | + |
| 42 | + describe('error-preview error excluded', function(): void { |
| 43 | + |
| 44 | + it('show error', function(): void { |
| 45 | + |
| 46 | + try { |
| 47 | + /** @var ErrorPreviewConsoleCommand $command */ |
| 48 | + $command = $this->application->getServiceManager()->get(ErrorPreviewConsoleCommand::class); |
| 49 | + |
| 50 | + $commandTester = new CommandTester($command); |
| 51 | + $commandTester->execute([ |
| 52 | + 'type' => 'error', |
| 53 | + ]); |
| 54 | + |
| 55 | + } catch (Throwable $throwable) { |
| 56 | + expect($throwable->getMessage())->toBe('a sample error preview'); |
| 57 | + } |
| 58 | + |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | +}); |
0 commit comments