Skip to content

Commit

Permalink
Add more code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Sep 17, 2024
1 parent 23354df commit 62324ba
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public function it_counts(): void
{
$context = new Context(['env' => 'prod', 'foo' => 'bar']);
self::assertCount(2, $context);
self::assertFalse($context->isEmpty());
}

/**
* @test
*/
public function it_is_empty_by_default(): void
{
$context = new Context();
self::assertTrue($context->isEmpty());
}

/**
Expand Down
37 changes: 37 additions & 0 deletions tests/CronJobTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Setono\CronBuilder;

use Cron\CronExpression;
use PHPUnit\Framework\TestCase;

final class CronJobTest extends TestCase
{
/**
* @test
*/
public function it_constructs(): void
{
$cronJob = new CronJob('0 0 * * *', '/usr/bin/php /home/johndoe/public_html/send-report.php', 'Run every day at midnight');

self::assertSame('0 0 * * *', (string) $cronJob->schedule);
self::assertSame('/usr/bin/php /home/johndoe/public_html/send-report.php', $cronJob->command);
self::assertSame('Run every day at midnight', $cronJob->description);

self::assertSame('0 0 * * * /usr/bin/php /home/johndoe/public_html/send-report.php # Run every day at midnight', (string) $cronJob);
}

/**
* @test
*/
public function it_constructs_with_expression(): void
{
$cronJob = new CronJob(new CronExpression('0 0 * * *'), '/usr/bin/php /home/johndoe/public_html/send-report.php', 'Run every day at midnight');

self::assertSame('0 0 * * *', (string) $cronJob->schedule);
self::assertSame('/usr/bin/php /home/johndoe/public_html/send-report.php', $cronJob->command);
self::assertSame('Run every day at midnight', $cronJob->description);
}
}

0 comments on commit 62324ba

Please sign in to comment.