Skip to content

Commit 6b47930

Browse files
committed
- unit tests improvements
1 parent 2519edf commit 6b47930

6 files changed

Lines changed: 18 additions & 23 deletions

File tree

Tests/LogConstructorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class LogConstructorTest extends TestCase
99
{
10-
1110
public function test_construction_with_config_array()
1211
{
1312
$log = new Log([

Tests/LogDeferredTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function test_log_suppression()
5151
$this->assertSame('', $processor->formatted());
5252
}
5353

54-
protected function setUp()
54+
protected function setUp(): void
5555
{
5656
$this->SUT = new Log([
5757
'deferred' => true,

Tests/LogTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public function test_log_suppression()
4242

4343
$processor->update([
4444
[
45-
'level' => -1, // this is ignored
45+
'level' => -1, // this is ignored
4646
'levelname' => 'DEBUG',
47-
'message' => 'Hello',
47+
'message' => 'Hello',
4848
'timestamp' => 1234567890
4949
]
5050
]);
@@ -57,11 +57,11 @@ public function test_exception()
5757
$processor = new Memory([]);
5858
$this->SUT->exception(new Exception('The message', 1), $processor);
5959

60-
$this->assertAttributeContains('[CRITICAL]', 'formatted', $processor);
61-
$this->assertAttributeContains('The message', 'formatted', $processor);
60+
$this->assertAttributeContains('[CRITICAL]', 'formatted', $processor);
61+
$this->assertAttributeContains('The message', 'formatted', $processor);
6262
}
6363

64-
protected function setUp()
64+
protected function setUp(): void
6565
{
6666
$this->SUT = new Log([]);
6767
}

Tests/Processors/DefaultProcessorPropertiesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class DefaultProcessorPropertiesTest extends TestCase
99
{
10-
1110
public function test_defaults()
1211
{
1312
$processor = new Memory([]);

Tests/Processors/FileTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class FileTest extends TestCase
99
{
10-
1110
/**
1211
* @var vfsStreamDirectory
1312
*/
@@ -21,15 +20,15 @@ public function test_update()
2120
$processor = new File(['dir' => $this->dir->url()]);
2221
$processor->update([
2322
[
24-
'level' => -1,
23+
'level' => -1,
2524
'levelname' => 'DEBUG',
26-
'message' => 'Test 1',
25+
'message' => 'Test 1',
2726
'timestamp' => 1234567890
2827
],
2928
[
30-
'level' => -1,
29+
'level' => -1,
3130
'levelname' => 'DEBUG',
32-
'message' => 'Test 2',
31+
'message' => 'Test 2',
3332
'timestamp' => 1234567891
3433
]
3534
]);
@@ -38,12 +37,12 @@ public function test_update()
3837
$this->assertTrue($this->dir->hasChild($subdirectory));
3938

4039
$content = $this->dir->getChild($subdirectory . DIRECTORY_SEPARATOR . $file)->getContent();
41-
$this->assertContains("1234567891 [DEBUG]: Test 2\n", $content);
40+
$this->assertStringContainsString("1234567891 [DEBUG]: Test 2\n", $content);
4241
}
4342

4443
public function test_when_directory_does_not_exist()
4544
{
46-
$dir = $this->dir->url() . '/nonexistent/';
45+
$dir = $this->dir->url() . '/nonexistent';
4746

4847
$this->expectException(FileProcessorException::class);
4948
$this->expectExceptionMessage('Log directory "' . $dir . '" must exist');
@@ -57,14 +56,14 @@ public function test_when_directory_is_not_writable()
5756
$dir = $this->dir->url();
5857

5958
$this->expectException(FileProcessorException::class);
60-
$this->expectExceptionMessage('Log directory "' . $dir . '/" must be writable');
59+
$this->expectExceptionMessage('Log directory "' . $dir . '" must be writable');
6160

6261
vfsStreamWrapper::getRoot()->chmod(0400);
6362
$processor = new File(['dir' => $dir]);
6463
$processor->update([]);
6564
}
6665

67-
protected function setUp()
66+
protected function setUp(): void
6867
{
6968
$this->dir = vfsStream::setup();
7069
}

Tests/Processors/MemoryTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@
22

33
namespace Koded\Logging\Processors;
44

5-
use function Koded\Stdlib\dump;
65
use PHPUnit\Framework\TestCase;
76

87
class MemoryTest extends TestCase
98
{
10-
119
public function test_formatting()
1210
{
1311
$processor = new Memory([]);
1412

1513
$processor->update([
1614
[
17-
'level' => -1,
15+
'level' => -1,
1816
'levelname' => 'TEST',
19-
'message' => 'Hello',
17+
'message' => 'Hello',
2018
'timestamp' => 1234567890
2119
],
2220
[
23-
'level' => -1,
21+
'level' => -1,
2422
'levelname' => 'TEST',
25-
'message' => 'World',
23+
'message' => 'World',
2624
'timestamp' => 1234567891
2725
]
2826
]);

0 commit comments

Comments
 (0)