Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Aug 16, 2024
1 parent 0d79e2e commit bb25fa1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/CronBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ public function it_builds_with_prod_env_set(): void
self::assertSame($expected, $crontab);
}

/**
* @test
*/
public function it_merges(): void
{
$existingCrontab = <<<CRON
0 0 * * * /usr/bin/php /home/johndoe/public_html/other-job.php
###> Automatically generated by Setono Cron Builder - DO NOT EDIT ###
0 0 * * * /usr/bin/php /home/johndoe/public_html/delete-files.php
###< Automatically generated by Setono Cron Builder - DO NOT EDIT ###
CRON;

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

self::assertSame($expected, CronBuilder::merge($existingCrontab, self::getCronBuilder()));
}

private static function getCronBuilder(): CronBuilder
{
return (new CronBuilder())
Expand Down

0 comments on commit bb25fa1

Please sign in to comment.