summaryrefslogtreecommitdiff
path: root/tests/Drivers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Drivers')
-rw-r--r--tests/Drivers/FileSystemDriverTest.php155
-rw-r--r--tests/Drivers/OutputDriverTest.php99
2 files changed, 0 insertions, 254 deletions
diff --git a/tests/Drivers/FileSystemDriverTest.php b/tests/Drivers/FileSystemDriverTest.php
deleted file mode 100644
index bb49042..0000000
--- a/tests/Drivers/FileSystemDriverTest.php
+++ /dev/null
@@ -1,155 +0,0 @@
-<?php
-
-namespace Asko\Loggr\Tests\Drivers;
-
-use Asko\Loggr\Drivers\FileSystemDriver;
-use Asko\Loggr\Loggr;
-use DateTime;
-use PHPUnit\Framework\TestCase;
-
-class FileSystemDriverTest extends TestCase
-{
- /**
- * @throws \Exception
- */
- public function testEmergency(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->emergency('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.EMERGENCY: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testAlert(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->alert('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.ALERT: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testCritical(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->critical('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.CRITICAL: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testError(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->error('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.ERROR: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testWarning(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->warning('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.WARNING: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testNotice(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->notice('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.NOTICE: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testInfo(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->info('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.INFO: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testDebug(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->debug('test');
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.DEBUG: test", $last_line);
- }
-
- /**
- * @throws \Exception
- */
- public function testMultipleEntries(): void
- {
- $date = new DateTime();
- $loggr = new Loggr(new FileSystemDriver(__DIR__ . '/logs'));
- $loggr->emergency('test');
- $loggr->alert('test');
- $loggr->critical('test');
- $loggr->error('test');
- $loggr->warning('test');
- $loggr->notice('test');
- $loggr->info('test');
- $loggr->debug('test');
-
- $lines = file(__DIR__ . '/logs/' . $date->format('Y-m-d') . '.log');
- $this->assertCount(8, $lines);
-
- $first_line = $lines[0];
- $last_line = end($lines);
- $full_date = $date->format('Y-m-d H:i:s');
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.EMERGENCY: test", $first_line);
- $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.DEBUG: test", $last_line);
- }
-
- public function tearDown(): void
- {
- array_map('unlink', glob(__DIR__ . '/logs/*'));
- rmdir(__DIR__ . '/logs');
- }
-} \ No newline at end of file
diff --git a/tests/Drivers/OutputDriverTest.php b/tests/Drivers/OutputDriverTest.php
deleted file mode 100644
index 9f023ae..0000000
--- a/tests/Drivers/OutputDriverTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-namespace Asko\Loggr\Tests\Drivers;
-
-use Asko\Loggr\Drivers\OutputDriver;
-use Asko\Loggr\Loggr;
-use DateTime;
-use PHPUnit\Framework\TestCase;
-
-class OutputDriverTest extends TestCase
-{
- /**
- * @throws \Exception
- */
- public function testEmergency(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.EMERGENCY: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->emergency('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testAlert(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.ALERT: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->alert('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testCritical(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.CRITICAL: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->critical('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testError(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.ERROR: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->error('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testWarning(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.WARNING: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->warning('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testNotice(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.NOTICE: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->notice('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testInfo(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.INFO: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->info('test');
- }
-
- /**
- * @throws \Exception
- */
- public function testDebug(): void
- {
- $date = (new DateTime)->format('Y-m-d H:i:s');
- $this->expectOutputString("[{$date}] OutputDriverTest.DEBUG: test");
- $loggr = new Loggr(new OutputDriver());
- $loggr->debug('test');
- }
-} \ No newline at end of file