-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergiu
committed
Sep 9, 2024
1 parent
7d7bcac
commit d2ef1ef
Showing
30 changed files
with
1,495 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DotTest\Log\Factory; | ||
|
||
use Dot\Log\Factory\WriterFactory; | ||
use Dot\Log\Writer\AbstractWriter; | ||
use Dot\Log\Writer\Stream; | ||
use PHPUnit\Framework\MockObject\Exception; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class WriterFactoryTest extends TestCase | ||
{ | ||
private ContainerInterface|MockObject $container; | ||
|
||
private WriterFactory $subject; | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->container = $this->createMock(ContainerInterface::class); | ||
$this->subject = new WriterFactory(); | ||
} | ||
|
||
public function testWillInstantiate(): void | ||
{ | ||
$factory = (new WriterFactory())( | ||
$this->container, | ||
Stream::class, | ||
['stream' => __DIR__ . '/../../log/dk.log'] | ||
); | ||
|
||
$this->assertInstanceOf(AbstractWriter::class, $factory); | ||
} | ||
|
||
public function testSetCreationOptions(): void | ||
{ | ||
$input = []; | ||
|
||
$this->assertNull($this->subject->setCreationOptions($input)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DotTest\Log\Filter; | ||
|
||
use Dot\Log\Exception\InvalidArgumentException; | ||
use Dot\Log\Filter\Priority; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PriorityTest extends TestCase | ||
{ | ||
private Priority $subject; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->subject = new Priority(47); | ||
} | ||
|
||
public function testWillInstantiateWithInt(): void | ||
{ | ||
$this->assertInstanceOf(Priority::class, $this->subject); | ||
} | ||
|
||
public function testWillInstantiateWithArray(): void | ||
{ | ||
$input = ['priority' => 47]; | ||
|
||
$result = new Priority($input); | ||
|
||
$this->assertInstanceOf(Priority::class, $result); | ||
} | ||
|
||
public function testWillNotInstantiateWithEmptyArray(): void | ||
{ | ||
$input = []; | ||
|
||
$this->expectExceptionMessage('Priority must be a number, received "NULL"'); | ||
$this->expectException(InvalidArgumentException::class); | ||
new Priority($input); | ||
} | ||
|
||
public function testFilterWillAcceptMessage(): void | ||
{ | ||
$input = ['priority' => 47]; | ||
|
||
$result = $this->subject->filter($input); | ||
|
||
$this->assertTrue($result); | ||
} | ||
|
||
public function testFilterWillNotAcceptMessage(): void | ||
{ | ||
$input = ['priority' => 244]; | ||
|
||
$result = $this->subject->filter($input); | ||
|
||
$this->assertFalse($result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DotTest\Log\Filter; | ||
|
||
use Dot\Log\Filter\Regex; | ||
use ErrorException; | ||
use PHPUnit\Framework\TestCase; | ||
use TypeError; | ||
|
||
class RegexTest extends TestCase | ||
{ | ||
private Regex $subject; | ||
|
||
/** | ||
* @throws ErrorException | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->subject = new Regex(['regex' => '/(a)(b)*(c)/']); | ||
} | ||
|
||
public function testWillInstantiate(): void | ||
{ | ||
$this->assertInstanceOf(Regex::class, $this->subject); | ||
} | ||
|
||
/** | ||
* @throws ErrorException | ||
*/ | ||
public function testWillNotInstantiateWithEmptyArray(): void | ||
{ | ||
$this->expectExceptionMessage( | ||
'preg_match(): Argument #1 ($pattern) must be of type string, null given' | ||
); | ||
$this->expectException(TypeError::class); | ||
new Regex([]); | ||
} | ||
|
||
public function testFilterWillAcceptMessage(): void | ||
{ | ||
$input = ['message' => 'ac']; | ||
|
||
$result = $this->subject->filter($input); | ||
|
||
$this->assertTrue($result); | ||
} | ||
|
||
public function testFilterWillNotAcceptMessage(): void | ||
{ | ||
$input = ['message' => 'What a wonderful day to write tests']; | ||
|
||
$result = $this->subject->filter($input); | ||
|
||
$this->assertFalse($result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DotTest\Log\Filter; | ||
|
||
use Dot\Log\Exception\InvalidArgumentException; | ||
use Dot\Log\Filter\SuppressFilter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SuppressFilterTest extends TestCase | ||
{ | ||
private SuppressFilter $subject; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->subject = new SuppressFilter(); | ||
} | ||
|
||
public function testWillInstantiate(): void | ||
{ | ||
$this->assertInstanceOf(SuppressFilter::class, $this->subject); | ||
} | ||
|
||
public function testWillNotInstantiate(): void | ||
{ | ||
$this->expectExceptionMessage( | ||
'Suppress must be a boolean; received "string"' | ||
); | ||
$this->expectException(InvalidArgumentException::class); | ||
new SuppressFilter(['suppress' => 'oups']); | ||
} | ||
|
||
public function testFilter(): void | ||
{ | ||
$result = $this->subject->filter([]); | ||
|
||
$this->assertIsBool($result); | ||
} | ||
|
||
public function testSuppress(): void | ||
{ | ||
$this->assertNull($this->subject->suppress(true)); | ||
} | ||
} |
Oops, something went wrong.