Skip to content
Snippets Groups Projects
Commit 43602d6c authored by dyszczo's avatar dyszczo
Browse files

test for capture

parent d39e12fa
No related branches found
No related tags found
2 merge requests!3Devel,!2Feature/tests
<?php
use Monolog\Logger;
use WPDesk\Logger\WC\Exception\WCLoggerAlreadyCaptured;
use WPDesk\Logger\WC\WooCommerceCapture;
use WPDesk\Logger\WC\WooCommerceMonologPlugin;
class TestWooCommerceCapture extends WP_UnitTestCase {
public function testIfCanCaptureWcLogger() {
$wcCapture = new WooCommerceCapture($this->createMock(Logger::class));
$wcCapture->captureWcLogger();
$this->assertInstanceOf(WooCommerceMonologPlugin::class, wc_get_logger(), "Logger should be captured.");
}
public function testIfCanFreeWcLogger() {
$wcCapture = new WooCommerceCapture($this->createMock(Logger::class));
$wcCapture->captureWcLogger();
$wcCapture->freeWcLogger();
$this->assertNotInstanceOf(WooCommerceMonologPlugin::class, wc_get_logger(), "Logger should be restored to original");
$wcCapture->captureWcLogger();
$this->assertInstanceOf(WooCommerceMonologPlugin::class, wc_get_logger(), "Logger should be captured.");
$wcCapture->freeWcLogger();
$this->assertNotInstanceOf(WooCommerceMonologPlugin::class, wc_get_logger(), "Logger should be restored to original - twice");
}
public function testIfCantCaptureTwice() {
$this->expectException(WCLoggerAlreadyCaptured::class);
$wcCapture = new WooCommerceCapture($this->createMock(Logger::class));
$wcCapture->captureWcLogger();
$wcCapture->captureWcLogger();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment