Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksagona committed Oct 31, 2023
1 parent 1806092 commit 243bc46
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ $devLog->setLogLimit(6); // Log only INFO (6) and above
$log = new Logger([$prodLog, $devLog]);

$log->alert('Look Out! Something serious happened!'); // Will write to both writers
$log->info('Just a info message'); // Will write to only app_dev.log
$log->info('Just a info message'); // Will write to only app_dev.log
```

The `app_prod.log` file will contain:
Expand Down
2 changes: 2 additions & 0 deletions tests/WriterDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public function testConstructor()
$writer = new Writer\Database($db, 'logs');
$this->assertInstanceOf('Pop\Log\Writer\Database', $writer);
$this->assertContains('logs', $db->getTables());
$this->assertInstanceOf('Pop\Db\Adapter\Sqlite', $writer->getDb());
$this->assertEquals('logs', $writer->getTable());
}

public function testLog()
Expand Down
2 changes: 2 additions & 0 deletions tests/WriterFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public function testConstructor()
$writer = new File(__DIR__ . '/tmp/test.log');
$this->assertInstanceOf('Pop\Log\Writer\File', $writer);
$this->assertFileExists(__DIR__ . '/tmp/test.log');
$this->assertEquals(__DIR__ . '/tmp/test.log', $writer->getFile());
$this->assertEquals('log', $writer->getType());
unlink(__DIR__ . '/tmp/test.log');
}

Expand Down
1 change: 1 addition & 0 deletions tests/WriterHttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function testConstructor()
{
$writer = new Http(new Client('http://localhost/', ['method' => 'POST']));
$this->assertInstanceOf('Pop\Log\Writer\Http', $writer);
$this->assertInstanceOf('Pop\Http\Client', $writer->getClient());
}

public function testSend()
Expand Down
13 changes: 13 additions & 0 deletions tests/WriterMailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public function testConstructor1()
{
$writer = new Writer\Mail(new Mail\Mailer(new Mail\Transport\Sendmail()), 'nobody@localhost');
$this->assertInstanceOf('Pop\Log\Writer\Mail', $writer);
$this->assertInstanceOf('Pop\Mail\Mailer', $writer->getMailer());
$this->assertIsArray($writer->getEmails());
$this->assertIsArray($writer->getOptions());
}

public function testConstructor2()
Expand All @@ -21,6 +24,16 @@ public function testConstructor2()
$this->assertInstanceOf('Pop\Log\Writer\Mail', $writer);
}

public function testAddOptions()
{
$writer = new Writer\Mail(new Mail\Mailer(new Mail\Transport\Sendmail()), 'nobody@localhost');
$writer->addOptions([
'subject' => 'Subject',
'cc' => 'nobody2@localhost'
]);
$this->assertCount(2, $writer->getOptions());
}

public function testLog()
{
$writer = new Writer\Mail(new Mail\Mailer(new Mail\Transport\Mailgun(['api_url' => 'http://localhost/', 'api_key' => 'API_KEY'])), 'nobody@localhost', [
Expand Down

0 comments on commit 243bc46

Please sign in to comment.