-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beee247
commit a056976
Showing
10 changed files
with
244 additions
and
18 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
94 changes: 94 additions & 0 deletions
94
spec/Fixture/autoload-for-xmlhttprequest-with-non-json-message/error-hero-module.local.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,94 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'db' => [ | ||
'username' => 'root', | ||
'password' => '', | ||
'driver' => 'Pdo', | ||
'dsn' => 'mysql:dbname=errorheromodule;host=127.0.0.1', | ||
'driver_options' => [ | ||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'', | ||
], | ||
], | ||
|
||
'log' => [ | ||
'ErrorHeroModuleLogger' => [ | ||
'writers' => [ | ||
|
||
[ | ||
'name' => 'db', | ||
'options' => [ | ||
'db' => 'Zend\Db\Adapter\Adapter', | ||
'table' => 'log', | ||
'column' => [ | ||
'timestamp' => 'date', | ||
'priority' => 'type', | ||
'message' => 'event', | ||
'extra' => [ | ||
'url' => 'url', | ||
'file' => 'file', | ||
'line' => 'line', | ||
'error_type' => 'error_type', | ||
'trace' => 'trace', | ||
'request_data' => 'request_data', | ||
], | ||
], | ||
], | ||
], | ||
|
||
], | ||
], | ||
], | ||
|
||
'error-hero-module' => [ | ||
'enable' => true, | ||
'display-settings' => [ | ||
|
||
// excluded php errors | ||
'exclude-php-errors' => [ | ||
E_USER_DEPRECATED | ||
], | ||
|
||
// show or not error | ||
'display_errors' => 0, | ||
|
||
// if enable and display_errors = 0, the page will bring layout and view | ||
'template' => [ | ||
'layout' => 'layout/layout', | ||
'view' => 'error-hero-module/error-default' | ||
], | ||
|
||
// if enable and display_errors = 0, the console will bring message | ||
'console' => [ | ||
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.', | ||
], | ||
|
||
'ajax' => [ | ||
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.', | ||
], | ||
|
||
], | ||
'logging-settings' => [ | ||
'same-error-log-time-range' => 86400, | ||
], | ||
'email-notification-settings' => [ | ||
// set to true to activate email notification on log error | ||
'enable' => false, | ||
|
||
// Zend\Mail\Message instance registered at service manager | ||
'mail-message' => 'YourMailMessageService', | ||
|
||
// Zend\Mail\Transport\TransportInterface instance registered at service manager | ||
'mail-transport' => 'YourMailTransportService', | ||
|
||
// email sender | ||
'email-from' => 'Sender Name <sender@host.com>', | ||
|
||
'email-to-send' => [ | ||
'developer1@foo.com', | ||
'developer2@foo.com', | ||
], | ||
], | ||
], | ||
]; |
47 changes: 47 additions & 0 deletions
47
spec/Fixture/autoload-for-xmlhttprequest-with-non-json-message/module.local.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,47 @@ | ||
<?php | ||
|
||
namespace ErrorHeroModule; | ||
|
||
use Zend\Log; | ||
use Zend\ServiceManager\Factory\InvokableFactory; | ||
|
||
return [ | ||
|
||
'controllers' => [ | ||
'factories' => [ | ||
Controller\ErrorPreviewController::class => InvokableFactory::class, | ||
], | ||
], | ||
|
||
'router' => [ | ||
'routes' => [ | ||
'error-preview' => [ | ||
'type' => 'Segment', | ||
'options' => [ | ||
'route' => '/error-preview[/][:action]', | ||
'defaults' => [ | ||
'controller' => Controller\ErrorPreviewController::class, | ||
'action' => 'exception', | ||
], | ||
], | ||
], | ||
], | ||
], | ||
|
||
'service_manager' => [ | ||
'abstract_factories' => [ | ||
Log\LoggerAbstractServiceFactory::class, | ||
], | ||
'factories' => [ | ||
Listener\Mvc::class => Listener\MvcFactory::class, | ||
Handler\Logging::class => Handler\LoggingFactory::class, | ||
], | ||
], | ||
|
||
'view_manager' => [ | ||
'template_path_stack' => [ | ||
__DIR__.'/../view', | ||
], | ||
], | ||
|
||
]; |
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
67 changes: 67 additions & 0 deletions
67
spec/IntegrationViaErrorPreviewControllerForXmlHttpRequestWithNonJsonMessageSpec.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,67 @@ | ||
<?php | ||
|
||
namespace ErrorHeroModule\Spec\Integration; | ||
|
||
use ErrorHeroModule; | ||
use ErrorHeroModule\Controller\ErrorPreviewController; | ||
use Kahlan\Plugin\Quit; | ||
use Kahlan\QuitException; | ||
use Zend\Console\Console; | ||
use Zend\Http\PhpEnvironment\Request; | ||
use Zend\Mvc\Application; | ||
|
||
describe('Integration via ErrorPreviewController for XmlHttpRequest', function () { | ||
|
||
given('application', function () { | ||
|
||
Console::overrideIsConsole(false); | ||
|
||
$application = Application::init([ | ||
'modules' => [ | ||
'Zend\Router', | ||
'Zend\Db', | ||
'ErrorHeroModule', | ||
], | ||
'module_listener_options' => [ | ||
'config_glob_paths' => [ | ||
realpath(__DIR__).'/Fixture/autoload-for-xmlhttprequest-with-non-json-message/{{,*.}global,{,*.}local}.php', | ||
], | ||
], | ||
]); | ||
|
||
$events = $application->getEventManager(); | ||
$serviceManager = $application->getServiceManager(); | ||
$serviceManager->get('SendResponseListener') | ||
->detach($events); | ||
|
||
return $application; | ||
|
||
}); | ||
|
||
describe('/error-preview', function() { | ||
|
||
it('show error page', function() { | ||
|
||
skipIf(PHP_MAJOR_VERSION < 7); | ||
Quit::disable(); | ||
|
||
$request = $this->application->getRequest(); | ||
$request->setMethod('GET'); | ||
$request->setUri('/error-preview'); | ||
|
||
allow(Request::class)->toReceive('isXmlHttpRequest')->andReturn(true); | ||
|
||
ob_start(); | ||
$closure = function () { | ||
$this->application->run(); | ||
}; | ||
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1)); | ||
$content = ob_get_clean(); | ||
|
||
expect($content)->toBe('We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.'); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
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.