Skip to content

Commit

Permalink
Update the method that creates the cron builder to include some more …
Browse files Browse the repository at this point in the history
…method calls
  • Loading branch information
loevgaard committed Sep 17, 2024
1 parent edd1a56 commit 9a11729
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions tests/CronBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function it_builds(): void
$crontab = self::getCronBuilder()->build();

$expected = <<<CRON
###> Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###> Generated by PHPUnit ###
0 0 * * * /usr/bin/php /home/johndoe/public_html/send-report.php --verbose # Run every day at midnight
###< Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###< Generated by PHPUnit ###
CRON;

Expand All @@ -37,10 +37,10 @@ public function it_builds_with_prod_env_set(): void
;

$expected = <<<CRON
###> Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###> Generated by PHPUnit ###
0 0 * * * /usr/bin/php /home/johndoe/public_html/send-report.php --verbose # Run every day at midnight
0 0 * * * /usr/bin/php /home/johndoe/public_html/process.php --verbose
###< Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###< Generated by PHPUnit ###
CRON;

Expand All @@ -57,9 +57,9 @@ public function it_merges(): void
0 0 * * * /usr/bin/php /home/johndoe/public_html/other-job.php
###> Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###> Generated by PHPUnit ###
0 0 * * * /usr/bin/php /home/johndoe/public_html/delete-files.php
###< Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###< Generated by PHPUnit ###
Expand All @@ -69,9 +69,9 @@ public function it_merges(): void
$expected = <<<CRON
0 0 * * * /usr/bin/php /home/johndoe/public_html/other-job.php
###> Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###> Generated by PHPUnit ###
0 0 * * * /usr/bin/php /home/johndoe/public_html/send-report.php --verbose # Run every day at midnight
###< Automatically generated by Setono Cron Builder - DO NOT EDIT ###
###< Generated by PHPUnit ###
CRON;

Expand All @@ -80,10 +80,15 @@ public function it_merges(): void

private static function getCronBuilder(): CronBuilder
{
return (new CronBuilder())
$cronBuilder = new CronBuilder();
$cronBuilder->setDelimiter('Generated by PHPUnit')
->addFiles((new Finder())->files()->in(__DIR__ . '/cronjobs'))
->addContext('release_path', '/home/johndoe/public_html')
->addContext('args', ['--verbose'])
->setContext(['args' => ['--verbose']])
;

$cronBuilder->context()->set('release_number', 12);

return $cronBuilder;
}
}

0 comments on commit 9a11729

Please sign in to comment.