Save exception when running acceptance tests

[MAILPOET-2267]
This commit is contained in:
Pavel Dohnal
2019-08-15 14:05:42 +02:00
committed by M. Shull
parent 857c3fab84
commit 9fbff395b0
5 changed files with 12 additions and 5 deletions

View File

@ -159,6 +159,7 @@ jobs:
- run:
name: Run acceptance tests
command: |
mkdir -m 777 -p tests/_output/exceptions
cd tests/docker
docker-compose run -e SKIP_DEPS=1 codeception -g acceptance_group_<< parameters.index >> --steps --debug -vvv --html --xml
- store_artifacts:
@ -180,6 +181,7 @@ jobs:
- run:
name: Run acceptance tests
command: |
mkdir -m 777 -p tests/_output/exceptions
cd tests/docker
docker-compose run -e SKIP_DEPS=1 -e MULTISITE=1 codeception -g acceptance_group_<< parameters.index >> --steps --debug -vvv --html --xml
- store_artifacts:

View File

@ -10,6 +10,7 @@ use MailPoet\Util\Helpers;
use MailPoet\Util\Security;
use MailPoet\WP\Functions as WPFunctions;
use Tracy\Debugger;
use Tracy\ILogger;
if (!defined('ABSPATH')) exit;
@ -180,6 +181,9 @@ class API {
$response = $endpoint->{$this->_request_method}($this->_request_data);
return $response;
} catch (\Exception $e) {
if (class_exists(Debugger::class) && Debugger::$logDirectory) {
Debugger::log($e, ILogger::EXCEPTION);
}
$error_message = $e->getMessage();
$error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST);
return $error_response;

View File

@ -12,8 +12,9 @@ $tracy_path = __DIR__ . '/tools/tracy.phar';
if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracy_path)) {
require_once $tracy_path;
if (getenv('MAILPOET_DISABLE_TRACY_BAR')) {
Debugger::$showBar = false;
if (getenv('MAILPOET_TEST_TRACY_MODE')) {
Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/tests/_output/exceptions');
Debugger::$logSeverity = E_ALL;
} else {
function render_tracy() {
ob_start();
@ -32,9 +33,9 @@ if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracy_path)) {
}
add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0);
session_start();
}
Debugger::enable(Debugger::DEVELOPMENT);
}
}
define('MAILPOET_VERSION', $mailpoet_plugin['version']);

View File

@ -42,7 +42,7 @@ services:
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_TABLE_PREFIX: mp_
MAILPOET_DISABLE_TRACY_BAR: 1
MAILPOET_TEST_TRACY_MODE: 1
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]