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

View File

@ -10,6 +10,7 @@ use MailPoet\Util\Helpers;
use MailPoet\Util\Security; use MailPoet\Util\Security;
use MailPoet\WP\Functions as WPFunctions; use MailPoet\WP\Functions as WPFunctions;
use Tracy\Debugger; use Tracy\Debugger;
use Tracy\ILogger;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
@ -180,6 +181,9 @@ class API {
$response = $endpoint->{$this->_request_method}($this->_request_data); $response = $endpoint->{$this->_request_method}($this->_request_data);
return $response; return $response;
} catch (\Exception $e) { } catch (\Exception $e) {
if (class_exists(Debugger::class) && Debugger::$logDirectory) {
Debugger::log($e, ILogger::EXCEPTION);
}
$error_message = $e->getMessage(); $error_message = $e->getMessage();
$error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST); $error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST);
return $error_response; 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)) { if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracy_path)) {
require_once $tracy_path; require_once $tracy_path;
if (getenv('MAILPOET_DISABLE_TRACY_BAR')) { if (getenv('MAILPOET_TEST_TRACY_MODE')) {
Debugger::$showBar = false; Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/tests/_output/exceptions');
Debugger::$logSeverity = E_ALL;
} else { } else {
function render_tracy() { function render_tracy() {
ob_start(); ob_start();
@ -32,8 +33,8 @@ if (WP_DEBUG && PHP_VERSION_ID >= 70100 && file_exists($tracy_path)) {
} }
add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0); add_action('admin_enqueue_scripts', 'render_tracy', PHP_INT_MAX, 0);
session_start(); session_start();
Debugger::enable(Debugger::DEVELOPMENT);
} }
Debugger::enable(Debugger::DEVELOPMENT);
} }
define('MAILPOET_VERSION', $mailpoet_plugin['version']); define('MAILPOET_VERSION', $mailpoet_plugin['version']);

View File

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