Skip to content

Commit

Permalink
Added end2end test for event logging customization lavary#309 lavary#346
Browse files Browse the repository at this point in the history
  • Loading branch information
drjayvee committed Apr 8, 2021
1 parent b7810cb commit f07569e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/EndToEnd/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ public function test_outputs_are_logged(): void
);
}

public function test_event_logging_override(): void
{
$envBuilder = $this->createEnvironmentBuilder()
->addTask('CustomOutputTasks')
->withConfig(
[
'log_output' => true,
'output_log_file' => 'main.log',
]
)
;
$environment = $envBuilder->createEnvironment();
$logPath = $environment->rootDirectory() . DIRECTORY_SEPARATOR;

$process = $environment->runCrunzCommand('schedule:run');

$this->assertEmpty($process->getOutput());

$this->assertFileDoesNotExist("$logPath/main.log");

$this->assertFileExists("$logPath/custom.log");
$this->assertStringContainsString(
'Usage: php',
file_get_contents("$logPath/custom.log")
);
}

private function assertLogRecord(
string $logRecord,
string $level,
Expand Down
16 changes: 16 additions & 0 deletions tests/resources/tasks/CustomOutputTasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use Crunz\Schedule;

$scheduler = new Schedule();

$scheduler
->run('php --help')
->description('Custom logging test')
->everyMinute()
->appendOutputTo('custom.log')
;

return $scheduler;

0 comments on commit f07569e

Please sign in to comment.