summaryrefslogtreecommitdiff
path: root/tests/FileSystemDriverTest.php
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nth.ee>2024-11-15 16:48:41 +0200
committerAsko Nõmm <asko@nth.ee>2024-11-15 16:48:41 +0200
commit88ee33c51b9696eb9c4b31afeae9487b21c0565f (patch)
treeca776922d74e8203cb6a5a97747b005581e74f25 /tests/FileSystemDriverTest.php
parentc69944457919ddf133da7573fe9aa41246f98957 (diff)
Create file and path if it does not exist.
Diffstat (limited to 'tests/FileSystemDriverTest.php')
-rw-r--r--tests/FileSystemDriverTest.php28
1 files changed, 2 insertions, 26 deletions
diff --git a/tests/FileSystemDriverTest.php b/tests/FileSystemDriverTest.php
index a05b5a9..a50adcc 100644
--- a/tests/FileSystemDriverTest.php
+++ b/tests/FileSystemDriverTest.php
@@ -132,35 +132,11 @@ class FileSystemDriverTest extends MockeryTestCase
$this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.DEBUG: test", $last_line);
}
- public function testNoPath(): void
- {
- $loggr = new Loggr(new FileSystemDriver('path-does-not-exist'));
- $loggr->emergency('test');
- $sep = DIRECTORY_SEPARATOR;
- $date = (new DateTime())->format('Y-m-d');
- $this->assertEquals("Log file could not be created at path: path-does-not-exist{$sep}{$date}.log", $loggr->error);
- }
-
- public function testCantWrite(): void
- {
- $driver = Mockery::mock(FileSystemDriver::class, [''])->makePartial();
- $driver->shouldReceive('log')->passthru();
- $driver->shouldReceive('exists')->andReturn(true);
- $driver->shouldReceive('isWriteable')->andReturns(false);
- $driver->shouldReceive('write')->never();
- $loggr = new Loggr($driver);
- $loggr->emergency('test');
- $sep = DIRECTORY_SEPARATOR;
- $date = (new DateTime())->format('Y-m-d');
- $this->assertEquals("Log file is not writeable at path: {$sep}{$date}.log", $loggr->error);
- }
-
private function mockLogger(string &$result): Loggr
{
- $driver = Mockery::mock(FileSystemDriver::class, [''])->makePartial();
+ $driver = Mockery::mock(FileSystemDriver::class, ['/tmp'])->makePartial();
$driver->shouldReceive('log')->passthru();
- $driver->shouldReceive('exists')->andReturn(true);
- $driver->shouldReceive('isWriteable')->andReturns(true);
+ $driver->shouldReceive('createLogFileIfNotExist')->andReturn(true);
$driver->shouldReceive('write')->withArgs(function (string $path, string $data) use (&$result) {
$result .= $data;