Skip to content

Commit

Permalink
Merge pull request #7 from stackkit/development
Browse files Browse the repository at this point in the history
Fix undefined offset error for closure commands and improve README
  • Loading branch information
marickvantuil authored Dec 27, 2020
2 parents 17f7940 + a50dc7a commit 9b3fc98
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.0.2 - 2020-12-27

**Fixed**

- Undefined offset error for closure commands

## 1.0.1 - 2020-12-07

**Fixed**
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ STACKKIT_CLOUD_SCHEDULER_APP_URL=https://yourdomainname.com/cloud-scheduler-job

# Cloud Scheduler Example

Here is an example job that will run `php artisan inspire` every minute.
Here is an example job that will run `php artisan schedule:run` every minute.

These are the most important settings:
- Target must be `HTTP`
- URL must be `https://yourdomainname.com/cloud-scheduler-job`
- URL and AUD (audience) must be `https://yourdomainname.com/cloud-scheduler-job`
- Auth header must be OIDC token!

<img src="/example.png">
Expand Down
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/TaskHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ private function getScheduledCommand($command)
$events = $this->schedule->events();

foreach ($events as $event) {
if (!is_string($event->command)) {
continue;
}

$eventCommand = $this->commandWithoutArtisan($event->command);

if ($command === $eventCommand) {
Expand Down
3 changes: 3 additions & 0 deletions tests/Support/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ protected function schedule(Schedule $schedule)
})->after(function () {
Log::warning('log before');
});
$schedule->call(function () {
Log::info('log call');
});
}
}
20 changes: 20 additions & 0 deletions tests/TaskHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,24 @@ public function in_case_of_signature_verification_failure_it_will_retry()
Event::assertDispatched(CacheHit::class);
Event::assertDispatched(KeyWritten::class);
}

/** @test */
public function it_can_run_the_schedule_run_command()
{
$this->fakeCommand->shouldReceive('capture')->andReturn('schedule:run');
$this->openId->shouldReceive('guardAgainstInvalidOpenIdToken')->andReturnNull();
$this->openId->shouldReceive('getKidFromOpenIdToken')->andReturnNull();
$this->openId->shouldReceive('decodeOpenIdToken')->andReturnNull();

Log::swap(new LogFake());

$this->taskHandler->handle();

Log::assertLoggedMessage('info', 'log after');
Log::assertLoggedMessage('warning', 'log before');
Log::assertLoggedMessage('info', 'log call');

// @todo - can't test commands run from schedule:run because testbench has no artisan binary.
// Log::assertLoggedMessage('debug', 'did something testy');
}
}

0 comments on commit 9b3fc98

Please sign in to comment.