Skip to content

Commit

Permalink
More tests added.
Browse files Browse the repository at this point in the history
  • Loading branch information
halilcosdu committed Apr 16, 2024
1 parent 5d84f33 commit be63cbe
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/LogWeaverTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Workbench\App;

use Exception;
use HalilCosdu\LogWeaver\LogWeaver;

it('can be instantiated', function () {
Expand Down Expand Up @@ -43,9 +46,32 @@
expect($logWeaver->getDisk())->toBe('local');
});

it('can set directory', function () {
it('can validate parameters', function () {
$logWeaver = new LogWeaver();
$logWeaver->directory('custom_logs');

expect($logWeaver->getDirectory())->toBe('custom_logs');
$logWeaver->directory('custom_logs');
$logWeaver->logResource('event');
$logWeaver->description('Test Description');
$logWeaver->content(['user_id' => 1]);
$logWeaver->level('info');
$logWeaver->disk('local');

try {
$logWeaver->toArray();
} catch (Exception $e) {
expect($e->getMessage())->toBeEmpty();
}
});

it('should throw exception if parameters are invalid', function () {
$logWeaver = new LogWeaver();
$logWeaver->directory('custom_logs');

try {
$logWeaver->toArray();
} catch (Exception $e) {
expect($e->getMessage())->not()->toBeEmpty();
}
});

0 comments on commit be63cbe

Please sign in to comment.