Skip to content

Commit

Permalink
[5.6] Updated to use new release of cron-expression (#21637)
Browse files Browse the repository at this point in the history
* Updated to use new release of cron-expression

*    fix test
  • Loading branch information
dragonmantank authored and taylorotwell committed Oct 13, 2017
1 parent 9ffb657 commit 07d160a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"erusev/parsedown": "~1.6",
"league/flysystem": "~1.0",
"monolog/monolog": "~1.12",
"mtdowling/cron-expression": "~1.0",
"dragonmantank/cron-expression": "~2.0",

This comment has been minimized.

Copy link
@accolver

accolver Mar 1, 2018

@dragonmantank @taylorotwell This upgrade broke quite a few of our crons, and the breaking change was not documented in the upgrade guide.

Valid cron expressions such as '2,17,35,47 5-7,11-13 * * *' (those with both ranges and fields) failed with an error that they could not be parsed. But worse, expressions such as '* * * * MON-FRI', silently failed to run at all (the now only supported format is '* * * * 1-5'). This left our company with several important crons that we were unaware weren't running for most of the day.

Here's the outstanding issue: dragonmantank/cron-expression#5

This comment has been minimized.

Copy link
@dragonmantank

dragonmantank Mar 2, 2018

Author Contributor

@accolver A fix for the regression on the literals is in the current master, as well as the list/range problem. If you could test those that would be great(and if it's still an issue, feel free to open a second issue on the literals and comment on dragonmantank/cron-expression#5).

"nesbot/carbon": "~1.20",
"psr/container": "~1.0",
"psr/simple-cache": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Event
*
* @var string
*/
public $expression = '* * * * * *';
public $expression = '* * * * *';

/**
* The timezone the date should be evaluated on.
Expand Down
12 changes: 6 additions & 6 deletions tests/Console/ConsoleScheduledEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testBasicCronCompilation()
$app->shouldReceive('environment')->andReturn('production');

$event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$this->assertEquals('* * * * * *', $event->getExpression());
$this->assertEquals('* * * * *', $event->getExpression());
$this->assertTrue($event->isDue($app));
$this->assertTrue($event->skip(function () {
return true;
Expand All @@ -46,17 +46,17 @@ public function testBasicCronCompilation()
})->filtersPass($app));

$event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$this->assertEquals('* * * * * *', $event->getExpression());
$this->assertEquals('* * * * *', $event->getExpression());
$this->assertFalse($event->environments('local')->isDue($app));

$event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$this->assertEquals('* * * * * *', $event->getExpression());
$this->assertEquals('* * * * *', $event->getExpression());
$this->assertFalse($event->when(function () {
return false;
})->filtersPass($app));

$event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$this->assertEquals('* * * * * *', $event->getExpression());
$this->assertEquals('* * * * *', $event->getExpression());
$this->assertFalse($event->when(false)->filtersPass($app));

// chained rules should be commutative
Expand All @@ -81,11 +81,11 @@ public function testEventIsDueCheck()
Carbon::setTestNow(Carbon::create(2015, 1, 1, 0, 0, 0));

$event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$this->assertEquals('* * * * 4 *', $event->thursdays()->getExpression());
$this->assertEquals('* * * * 4', $event->thursdays()->getExpression());
$this->assertTrue($event->isDue($app));

$event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$this->assertEquals('0 19 * * 3 *', $event->wednesdays()->at('19:00')->timezone('EST')->getExpression());
$this->assertEquals('0 19 * * 3', $event->wednesdays()->at('19:00')->timezone('EST')->getExpression());
$this->assertTrue($event->isDue($app));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Scheduling/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testBuildCommand()
$event->runInBackground();

$defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
$this->assertSame("(php -i > {$quote}{$defaultOutput}{$quote} 2>&1 ; '".PHP_BINARY."' artisan schedule:finish \"framework/schedule-c65b1c374c37056e0c57fccb0c08d724ce6f5043\") > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
$this->assertSame("(php -i > {$quote}{$defaultOutput}{$quote} 2>&1 ; '".PHP_BINARY."' artisan schedule:finish \"framework/schedule-eeb46c93d45e928d62aaf684d727e213b7094822\") > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand());
}

public function testBuildCommandSendOutputTo()
Expand Down
44 changes: 22 additions & 22 deletions tests/Console/Scheduling/FrequencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,99 +23,99 @@ public function setUp()

public function testEveryMinute()
{
$this->assertEquals('* * * * * *', $this->event->getExpression());
$this->assertEquals('* * * * * *', $this->event->everyMinute()->getExpression());
$this->assertEquals('* * * * *', $this->event->getExpression());
$this->assertEquals('* * * * *', $this->event->everyMinute()->getExpression());
}

public function testEveryFiveMinutes()
{
$this->assertEquals('*/5 * * * * *', $this->event->everyFiveMinutes()->getExpression());
$this->assertEquals('*/5 * * * *', $this->event->everyFiveMinutes()->getExpression());
}

public function testDaily()
{
$this->assertEquals('0 0 * * * *', $this->event->daily()->getExpression());
$this->assertEquals('0 0 * * *', $this->event->daily()->getExpression());
}

public function testTwiceDaily()
{
$this->assertEquals('0 3,15 * * * *', $this->event->twiceDaily(3, 15)->getExpression());
$this->assertEquals('0 3,15 * * *', $this->event->twiceDaily(3, 15)->getExpression());
}

public function testOverrideWithHourly()
{
$this->assertEquals('0 * * * * *', $this->event->everyFiveMinutes()->hourly()->getExpression());
$this->assertEquals('37 * * * * *', $this->event->hourlyAt(37)->getExpression());
$this->assertEquals('0 * * * *', $this->event->everyFiveMinutes()->hourly()->getExpression());
$this->assertEquals('37 * * * *', $this->event->hourlyAt(37)->getExpression());
}

public function testMonthlyOn()
{
$this->assertEquals('0 15 4 * * *', $this->event->monthlyOn(4, '15:00')->getExpression());
$this->assertEquals('0 15 4 * *', $this->event->monthlyOn(4, '15:00')->getExpression());
}

public function testTwiceMonthly()
{
$this->assertEquals('0 0 1,16 * * *', $this->event->twiceMonthly(1, 16)->getExpression());
$this->assertEquals('0 0 1,16 * *', $this->event->twiceMonthly(1, 16)->getExpression());
}

public function testMonthlyOnWithMinutes()
{
$this->assertEquals('15 15 4 * * *', $this->event->monthlyOn(4, '15:15')->getExpression());
$this->assertEquals('15 15 4 * *', $this->event->monthlyOn(4, '15:15')->getExpression());
}

public function testWeekdaysDaily()
{
$this->assertEquals('0 0 * * 1-5 *', $this->event->weekdays()->daily()->getExpression());
$this->assertEquals('0 0 * * 1-5', $this->event->weekdays()->daily()->getExpression());
}

public function testWeekdaysHourly()
{
$this->assertEquals('0 * * * 1-5 *', $this->event->weekdays()->hourly()->getExpression());
$this->assertEquals('0 * * * 1-5', $this->event->weekdays()->hourly()->getExpression());
}

public function testWeekdays()
{
$this->assertEquals('* * * * 1-5 *', $this->event->weekdays()->getExpression());
$this->assertEquals('* * * * 1-5', $this->event->weekdays()->getExpression());
}

public function testSundays()
{
$this->assertEquals('* * * * 0 *', $this->event->sundays()->getExpression());
$this->assertEquals('* * * * 0', $this->event->sundays()->getExpression());
}

public function testMondays()
{
$this->assertEquals('* * * * 1 *', $this->event->mondays()->getExpression());
$this->assertEquals('* * * * 1', $this->event->mondays()->getExpression());
}

public function testTuesdays()
{
$this->assertEquals('* * * * 2 *', $this->event->tuesdays()->getExpression());
$this->assertEquals('* * * * 2', $this->event->tuesdays()->getExpression());
}

public function testWednesdays()
{
$this->assertEquals('* * * * 3 *', $this->event->wednesdays()->getExpression());
$this->assertEquals('* * * * 3', $this->event->wednesdays()->getExpression());
}

public function testThursdays()
{
$this->assertEquals('* * * * 4 *', $this->event->thursdays()->getExpression());
$this->assertEquals('* * * * 4', $this->event->thursdays()->getExpression());
}

public function testFridays()
{
$this->assertEquals('* * * * 5 *', $this->event->fridays()->getExpression());
$this->assertEquals('* * * * 5', $this->event->fridays()->getExpression());
}

public function testSaturdays()
{
$this->assertEquals('* * * * 6 *', $this->event->saturdays()->getExpression());
$this->assertEquals('* * * * 6', $this->event->saturdays()->getExpression());
}

public function testQuarterly()
{
$this->assertEquals('0 0 1 1-12/3 * *', $this->event->quarterly()->getExpression());
$this->assertEquals('0 0 1 1-12/3 *', $this->event->quarterly()->getExpression());
}

public function testFrequencyMacro()
Expand All @@ -124,6 +124,6 @@ public function testFrequencyMacro()
return $this->spliceIntoPosition(1, "*/{$x}");
});

$this->assertEquals('*/6 * * * * *', $this->event->everyXMinutes(6)->getExpression());
$this->assertEquals('*/6 * * * *', $this->event->everyXMinutes(6)->getExpression());
}
}

2 comments on commit 07d160a

@GrahamCampbell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to update the other composer.json file.

@GrahamCampbell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR incomming.

Please sign in to comment.