Skip to content

Commit

Permalink
#88 code review
Browse files Browse the repository at this point in the history
  • Loading branch information
guich25 committed Feb 27, 2024
1 parent dfe2283 commit 13c8045
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions tests/convention/Job/LoggerTest.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
<?php

/*
* This file is part of the Tucania project.
*
* Copyright (C) Tucania (https://www.tucania.com/) - All Rights Reserved
*
* For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Yokai\Batch\Sources\Tests\Convention\Job;

use Exception;
use PHPUnit\Framework\TestCase;
use Yokai\Batch\Factory\JobExecutionFactory;
use Yokai\Batch\Factory\UniqidJobExecutionIdGenerator;
use Yokai\Batch\JobExecution;

class LoggerTest extends TestCase
{
private JobExecutionFactory $jobExecutionFactory;

public function setUp(): void
{
$idGenerator = new UniqidJobExecutionIdGenerator();
$this->jobExecutionFactory = new JobExecutionFactory($idGenerator);
}

public function testLogError()
{
$idGenerator = new UniqidJobExecutionIdGenerator();
$errorToLog = 'test assert logErrorMethod';
$jobExecution = $this->jobExecutionFactory->create('job-test');
$jobExecution->logError(new Exception(), $errorToLog);
$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());
}
}

0 comments on commit 13c8045

Please sign in to comment.