Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* console-argv: zend-mvc-console require command class_alias fix command "php" console preview class alias fix and its spec console controller zf3 preview name fix console preview exclude zf2 console controller from test syntax error fix adding error preview console controllers readme preview update better Console information with include scriptname and args
- Loading branch information
Showing
11 changed files
with
240 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace ErrorHeroModule\Spec; | ||
|
||
use ErrorHeroModule\Controller\ErrorPreviewConsoleController; | ||
|
||
describe('ErrorPreviewConsoleController', function () { | ||
|
||
given('controller', function () { | ||
|
||
return new ErrorPreviewConsoleController(); | ||
|
||
}); | ||
|
||
describe('->exceptionAction()', function() { | ||
|
||
it('throw Exception', function() { | ||
|
||
$controller = $this->controller; | ||
$closure = function() use ($controller) { | ||
$controller->exceptionAction(); | ||
}; | ||
expect($closure)->toThrow(new \Exception('a sample error preview')); | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('->errorAction()', function() { | ||
|
||
it('Error', function() { | ||
|
||
skipIf(PHP_MAJOR_VERSION < 7); | ||
|
||
try { | ||
$controller = $this->controller; | ||
$controller->errorAction(); | ||
} catch (\Throwable $error) { | ||
expect($error)->toBeAnInstanceOf(\Throwable::class); | ||
} | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
102 changes: 102 additions & 0 deletions
102
spec/IntegrationViaErrorPreviewConsoleControllerSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace ErrorHeroModule\Spec; | ||
|
||
use ErrorHeroModule; | ||
use ErrorHeroModule\Controller\ErrorPreviewConsoleController; | ||
use Kahlan\Plugin\Quit; | ||
use Kahlan\QuitException; | ||
use Zend\Console\Console; | ||
use Zend\Db\ResultSet\ResultSet; | ||
use Zend\Db\TableGateway\TableGateway; | ||
use Zend\Log; | ||
use Zend\Mvc\Application; | ||
|
||
describe('Integration via ErrorPreviewConsoleController', function () { | ||
|
||
given('application', function () { | ||
|
||
Console::overrideIsConsole(true); | ||
|
||
$application = Application::init([ | ||
'modules' => [ | ||
'Zend\Router', | ||
'Zend\Db', | ||
'ErrorHeroModule', | ||
], | ||
'module_listener_options' => [ | ||
'config_glob_paths' => [ | ||
realpath(__DIR__).'/Fixture/autoload/{{,*.}global,{,*.}local}.php', | ||
], | ||
], | ||
]); | ||
|
||
$events = $application->getEventManager(); | ||
$serviceManager = $application->getServiceManager(); | ||
$serviceManager->get('SendResponseListener') | ||
->detach($events); | ||
|
||
$db = $serviceManager->get('Zend\Db\Adapter\Adapter'); | ||
$tableGateway = new TableGateway('log', $db, null, new ResultSet()); | ||
$tableGateway->delete([]); | ||
|
||
return $application; | ||
|
||
}); | ||
|
||
describe('/error-preview', function() { | ||
|
||
it('show error page', function() { | ||
|
||
skipIf(PHP_MAJOR_VERSION < 7); | ||
|
||
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() { | ||
|
||
skipIf(PHP_MAJOR_VERSION < 7); | ||
|
||
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'); | ||
|
||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.