Add logging errors to the log table

[MAILPOET-4104]
This commit is contained in:
Jan Lysý
2023-01-02 19:05:06 +01:00
committed by Aschepikov
parent 4195428643
commit b0ab2f404f
2 changed files with 29 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ use MailPoet\Config\AccessControl;
use MailPoet\DI\ContainerConfigurator;
use MailPoet\DI\ContainerFactory;
use MailPoet\Entities\SubscriberSegmentEntity;
use MailPoet\Logging\LoggerFactory;
use MailPoet\Settings\SettingsController;
use MailPoet\WP\Functions as WPFunctions;
use MailPoetVendor\Symfony\Component\DependencyInjection\Container;
@@ -38,6 +39,9 @@ class APITest extends \MailPoetTest {
/** @var SettingsController */
private $settings;
/** @var LoggerFactory */
private $loggerFactory;
public function _before() {
parent::_before();
// create WP user
@@ -56,11 +60,13 @@ class APITest extends \MailPoetTest {
$this->container->compile();
$this->errorHandler = $this->container->get(ErrorHandler::class);
$this->settings = $this->container->get(SettingsController::class);
$this->loggerFactory = $this->container->get(LoggerFactory::class);
$this->api = new JSONAPI(
$this->container,
$this->container->get(AccessControl::class),
$this->errorHandler,
$this->settings,
$this->loggerFactory,
new WPFunctions
);
}
@@ -242,7 +248,7 @@ class APITest extends \MailPoetTest {
['validatePermission' => false]
);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, new WPFunctions);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, $this->loggerFactory, new WPFunctions);
$api->addEndpointNamespace($namespace['name'], $namespace['version']);
$api->setRequestData($data, Endpoint::TYPE_POST);
$response = $api->processRoute();
@@ -264,7 +270,7 @@ class APITest extends \MailPoetTest {
]
);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, new WPFunctions);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, $this->loggerFactory, new WPFunctions);
expect($api->validatePermissions(null, $permissions))->false();
$accessControl = Stub::make(
@@ -276,7 +282,7 @@ class APITest extends \MailPoetTest {
}),
]
);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, new WPFunctions);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, $this->loggerFactory, new WPFunctions);
expect($api->validatePermissions(null, $permissions))->true();
}
@@ -298,7 +304,7 @@ class APITest extends \MailPoetTest {
]
);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, new WPFunctions);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, $this->loggerFactory, new WPFunctions);
expect($api->validatePermissions('test', $permissions))->false();
$accessControl = Stub::make(
@@ -311,7 +317,7 @@ class APITest extends \MailPoetTest {
]
);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, new WPFunctions);
$api = new JSONAPI($this->container, $accessControl, $this->errorHandler, $this->settings, $this->loggerFactory, new WPFunctions);
expect($api->validatePermissions('test', $permissions))->true();
}