From 5973f6c54ccd0d99e15f055c5a16b19b8c45db91 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 31 Oct 2016 15:59:08 -0500 Subject: [PATCH] formatting and fixing --- .../Console/Scheduling/CallbackEvent.php | 16 ++++----- src/Illuminate/Console/Scheduling/Event.php | 16 ++++----- .../Console/Scheduling/Schedule.php | 4 +-- src/Illuminate/Foundation/Console/Kernel.php | 3 +- tests/Console/ConsoleScheduledEventTest.php | 36 +++++++++---------- tests/Console/Scheduling/EventTest.php | 10 +++--- 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/CallbackEvent.php b/src/Illuminate/Console/Scheduling/CallbackEvent.php index 52771b71b377..6ccf36d2cfc3 100644 --- a/src/Illuminate/Console/Scheduling/CallbackEvent.php +++ b/src/Illuminate/Console/Scheduling/CallbackEvent.php @@ -10,18 +10,18 @@ class CallbackEvent extends Event { /** - * The callback to call. + * The cache store implementation. * - * @var string + * @var \Illuminate\Contracts\Cache\Repository */ - protected $callback; + protected $cache; /** - * The cache store implementation. + * The callback to call. * - * @var \Illuminate\Contracts\Cache\Repository + * @var string */ - protected $cache; + protected $callback; /** * The parameters to pass to the method. @@ -33,14 +33,14 @@ class CallbackEvent extends Event /** * Create a new event instance. * - * @param string $callback * @param \Illuminate\Contracts\Cache\Repository $cache + * @param string $callback * @param array $parameters * @return void * * @throws \InvalidArgumentException */ - public function __construct($callback, Cache $cache, array $parameters = []) + public function __construct(Cache $cache, $callback, array $parameters = []) { if (! is_string($callback) && ! is_callable($callback)) { throw new InvalidArgumentException( diff --git a/src/Illuminate/Console/Scheduling/Event.php b/src/Illuminate/Console/Scheduling/Event.php index d592009e98d8..f8bbc506217f 100644 --- a/src/Illuminate/Console/Scheduling/Event.php +++ b/src/Illuminate/Console/Scheduling/Event.php @@ -16,18 +16,18 @@ class Event { /** - * The command string. + * The cache store implementation. * - * @var string + * @var \Illuminate\Contracts\Cache\Repository */ - public $command; + protected $cache; /** - * The cache store implementation. + * The command string. * - * @var \Illuminate\Contracts\Cache\Repository + * @var string */ - protected $cache; + public $command; /** * The cron expression representing the event's frequency. @@ -130,11 +130,11 @@ class Event /** * Create a new event instance. * - * @param string $command * @param \Illuminate\Contracts\Cache\Repository $cache + * @param string $command * @return void */ - public function __construct($command, Cache $cache) + public function __construct(Cache $cache, $command) { $this->cache = $cache; $this->command = $command; diff --git a/src/Illuminate/Console/Scheduling/Schedule.php b/src/Illuminate/Console/Scheduling/Schedule.php index f9117cbea5da..bbfa65a0df0c 100644 --- a/src/Illuminate/Console/Scheduling/Schedule.php +++ b/src/Illuminate/Console/Scheduling/Schedule.php @@ -43,7 +43,7 @@ public function __construct(Cache $cache) */ public function call($callback, array $parameters = []) { - $this->events[] = $event = new CallbackEvent($callback, $this->cache, $parameters); + $this->events[] = $event = new CallbackEvent($this->cache, $callback, $parameters); return $event; } @@ -81,7 +81,7 @@ public function exec($command, array $parameters = []) $command .= ' '.$this->compileParameters($parameters); } - $this->events[] = $event = new Event($command, $this->cache); + $this->events[] = $event = new Event($this->cache, $command); return $event; } diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index c97579e75cfd..c5e7393fa07a 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -9,6 +9,7 @@ use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Application as Artisan; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Contracts\Console\Kernel as KernelContract; use Symfony\Component\Debug\Exception\FatalThrowableError; @@ -93,7 +94,7 @@ public function __construct(Application $app, Dispatcher $events) protected function defineConsoleSchedule() { $this->app->instance( - 'Illuminate\Console\Scheduling\Schedule', $schedule = new Schedule($this->app['cache.store']) + 'Illuminate\Console\Scheduling\Schedule', $schedule = new Schedule($this->app[Cache::class]) ); $this->schedule($schedule); diff --git a/tests/Console/ConsoleScheduledEventTest.php b/tests/Console/ConsoleScheduledEventTest.php index 4619ff3427db..4f1fb2d5ac51 100644 --- a/tests/Console/ConsoleScheduledEventTest.php +++ b/tests/Console/ConsoleScheduledEventTest.php @@ -32,7 +32,7 @@ public function testBasicCronCompilation() $app->shouldReceive('isDownForMaintenance')->andReturn(false); $app->shouldReceive('environment')->andReturn('production'); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('* * * * * *', $event->getExpression()); $this->assertTrue($event->isDue($app)); $this->assertTrue($event->skip(function () { @@ -42,49 +42,49 @@ public function testBasicCronCompilation() return true; })->filtersPass($app)); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('* * * * * *', $event->getExpression()); $this->assertFalse($event->environments('local')->isDue($app)); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('* * * * * *', $event->getExpression()); $this->assertFalse($event->when(function () { return false; })->filtersPass($app)); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('*/5 * * * * *', $event->everyFiveMinutes()->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 0 * * * *', $event->daily()->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 3,15 * * * *', $event->twiceDaily(3, 15)->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('*/5 * * * 3 *', $event->everyFiveMinutes()->wednesdays()->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 * * * * *', $event->everyFiveMinutes()->hourly()->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 15 4 * * *', $event->monthlyOn(4, '15:00')->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 0 * * 1-5 *', $event->weekdays()->daily()->getExpression()); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 * * * 1-5 *', $event->weekdays()->hourly()->getExpression()); // chained rules should be commutative - $eventA = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); - $eventB = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $eventA = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); + $eventB = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals( $eventA->daily()->hourly()->getExpression(), $eventB->hourly()->daily()->getExpression()); - $eventA = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); - $eventB = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $eventA = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); + $eventB = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals( $eventA->weekdays()->hourly()->getExpression(), $eventB->hourly()->weekdays()->getExpression()); @@ -97,11 +97,11 @@ public function testEventIsDueCheck() $app->shouldReceive('environment')->andReturn('production'); Carbon::setTestNow(Carbon::create(2015, 1, 1, 0, 0, 0)); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('* * * * 4 *', $event->thursdays()->getExpression()); $this->assertTrue($event->isDue($app)); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertEquals('0 19 * * 3 *', $event->wednesdays()->at('19:00')->timezone('EST')->getExpression()); $this->assertTrue($event->isDue($app)); } @@ -113,7 +113,7 @@ public function testTimeBetweenChecks() $app->shouldReceive('environment')->andReturn('production'); Carbon::setTestNow(Carbon::now()->startOfDay()->addHours(9)); - $event = new Event('php foo', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php foo'); $this->assertTrue($event->between('8:00', '10:00')->filtersPass($app)); $this->assertTrue($event->between('9:00', '9:00')->filtersPass($app)); $this->assertFalse($event->between('10:00', '11:00')->filtersPass($app)); diff --git a/tests/Console/Scheduling/EventTest.php b/tests/Console/Scheduling/EventTest.php index 963ff5b09d6f..69be7fd8c3fe 100644 --- a/tests/Console/Scheduling/EventTest.php +++ b/tests/Console/Scheduling/EventTest.php @@ -14,7 +14,7 @@ public function testBuildCommand() { $quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'"; - $event = new Event('php -i', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i'); $defaultOutput = (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null'; $this->assertSame("php -i > {$quote}{$defaultOutput}{$quote} 2>&1 &", $event->buildCommand()); @@ -24,12 +24,12 @@ public function testBuildCommandSendOutputTo() { $quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'"; - $event = new Event('php -i', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i'); $event->sendOutputTo('/dev/null'); $this->assertSame("php -i > {$quote}/dev/null{$quote} 2>&1 &", $event->buildCommand()); - $event = new Event('php -i', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i'); $event->sendOutputTo('/my folder/foo.log'); $this->assertSame("php -i > {$quote}/my folder/foo.log{$quote} 2>&1 &", $event->buildCommand()); @@ -39,7 +39,7 @@ public function testBuildCommandAppendOutput() { $quote = (DIRECTORY_SEPARATOR == '\\') ? '"' : "'"; - $event = new Event('php -i', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i'); $event->appendOutputTo('/dev/null'); $this->assertSame("php -i >> {$quote}/dev/null{$quote} 2>&1 &", $event->buildCommand()); @@ -50,7 +50,7 @@ public function testBuildCommandAppendOutput() */ public function testEmailOutputToThrowsExceptionIfOutputFileWasNotSpecified() { - $event = new Event('php -i', m::mock('Illuminate\Contracts\Cache\Repository')); + $event = new Event(m::mock('Illuminate\Contracts\Cache\Repository'), 'php -i'); $event->emailOutputTo('foo@example.com'); $event->buildCommand();