Skip to content

Commit

Permalink
Feature/seed schedules with default (#4)
Browse files Browse the repository at this point in the history
* fix phpstan config

* fix test workflow

* schedule default commands through migration
  • Loading branch information
herpaderpaldent committed Jun 8, 2023
1 parent 6e28fab commit 22d4550
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
],
"require": {
"php": "^8.1",
"seatplus/core": "^3.0",
"illuminate/contracts": "^10.0",
"seatplus/web": "^3.0",
"seatplus/connector": "^1.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Seatplus\Eveapi\Models\Schedules;

return new class extends Migration
{
public function up(): void
{

$jobs = [
// Run ApplyNicknamePolicy Command every 15 minutes
\Seatplus\Tribe\Commands\ApplyNicknamePolicyCommand::class => '*/15 * * * *',
// Run RunSquadSyncCommand every 15 minutes
\Seatplus\Tribe\Commands\RunSquadSyncCommand::class => '*/15 * * * *',
];
// if the schedule is not in the database, create it
foreach ($jobs as $job => $schedule) {
Schedules::query()->firstOrCreate([
'job' => $job,
], [
'expression' => $schedule,
]);
}
}
};
11 changes: 11 additions & 0 deletions tests/Integration/TribeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
->assertRedirect(route('tribe.index'));
});

it('seeds schedules tables with commands', function () {

$schedules = \Seatplus\Eveapi\Models\Schedules::all();

// assert that ApplyNicknamePolicyCommand is scheduled
expect($schedules->contains('job', \Seatplus\Tribe\Commands\ApplyNicknamePolicyCommand::class))->toBeTrue()
// assert that RunSquadSyncCommand is scheduled
->and($schedules->contains('job', \Seatplus\Tribe\Commands\RunSquadSyncCommand::class))->toBeTrue();

});

function getControllerTribeMock(): Mockery\MockInterface
{
$tribe = getTribeMock();
Expand Down

0 comments on commit 22d4550

Please sign in to comment.