Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doctrine config converter fixes and its integration tests
- Loading branch information
1 parent
e335492
commit 08e7ea1
Showing
3 changed files
with
202 additions
and
8 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
spec/Fixture/config/autoload-with-doctrine/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,98 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'doctrine' => [ | ||
'connection' => [ | ||
'orm_default' => [ | ||
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver', | ||
'params' => [ | ||
'user' => 'root', | ||
'password' => '', | ||
'dbname' => 'errorheromodule', | ||
'host' => '127.0.0.1', | ||
'port' => '3306', | ||
'driverOptions' => [ | ||
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.', | ||
], | ||
|
||
], | ||
'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', | ||
], | ||
], | ||
], | ||
]; |
100 changes: 100 additions & 0 deletions
100
spec/Integration/IntegrationViaErrorPreviewConsoleControllerWithDoctrineORMModuleSpec.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,100 @@ | ||
<?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 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); | ||
|
||
$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() { | ||
|
||
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'); | ||
|
||
}); | ||
}); | ||
|
||
}); |
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