-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper method to log error without adding failure (#114)
* #88 add helper method to log error without adding failure * #88 code review * #88 move LoggerTest in the right directory
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yokai\Batch\Tests\Job; | ||
|
||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
use Yokai\Batch\Factory\UniqidJobExecutionIdGenerator; | ||
use Yokai\Batch\JobExecution; | ||
|
||
class LoggerTest extends TestCase | ||
{ | ||
public function testLogError() | ||
{ | ||
$idGenerator = new UniqidJobExecutionIdGenerator(); | ||
$errorToLog = 'test assert logErrorMethod'; | ||
$errorException = 'test assert errorException'; | ||
$jobExecution = JobExecution::createRoot($idGenerator->generate(), 'export'); | ||
$jobExecution->logError(new Exception($errorException), $errorToLog); | ||
|
||
self::assertStringContainsString($errorToLog, $jobExecution->getLogs()->__toString()); | ||
self::assertStringContainsString($errorException, $jobExecution->getLogs()->__toString()); | ||
} | ||
} |