diff options
| author | Asko Nõmm <asko@nth.ee> | 2024-11-11 19:38:26 +0200 |
|---|---|---|
| committer | Asko Nõmm <asko@nth.ee> | 2024-11-11 19:38:26 +0200 |
| commit | 7b68bf0c456fc44c067e1303f73752059df59aa0 (patch) | |
| tree | e6026354eaf95b8623fee83ae58dd840cf07eae8 /tests/FileSystemDriverTest.php | |
| parent | c269c16ffaf9b8fb675a9eee5400c05e5149b988 (diff) | |
Improve tests.
Diffstat (limited to 'tests/FileSystemDriverTest.php')
| -rw-r--r-- | tests/FileSystemDriverTest.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/FileSystemDriverTest.php b/tests/FileSystemDriverTest.php index 850f7d7..c28c489 100644 --- a/tests/FileSystemDriverTest.php +++ b/tests/FileSystemDriverTest.php @@ -132,7 +132,7 @@ class FileSystemDriverTest extends MockeryTestCase $this->assertStringContainsString("[{$full_date}] FileSystemDriverTest.DEBUG: test", $last_line); } - public function testFileSystemDriverThrows(): void + public function testNoPath(): void { $loggr = new Loggr(new FileSystemDriver('path-does-not-exist')); $loggr->emergency('test'); @@ -141,6 +141,20 @@ class FileSystemDriverTest extends MockeryTestCase $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(); |
