Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -12,14 +12,13 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
/**
|
||||
* Test that a schedule can be created for the server.
|
||||
*
|
||||
* @param array $permissions
|
||||
* @dataProvider permissionsDataProvider
|
||||
*/
|
||||
public function testScheduleCanBeCreatedForServer($permissions)
|
||||
public function testScheduleCanBeCreatedForServer(array $permissions)
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", [
|
||||
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/schedules", [
|
||||
'name' => 'Test Schedule',
|
||||
'is_active' => false,
|
||||
'minute' => '0',
|
||||
|
@ -55,17 +54,17 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
$response = $this->actingAs($user)->postJson("/api/client/servers/{$server->uuid}/schedules", []);
|
||||
$response = $this->actingAs($user)->postJson("/api/client/servers/$server->uuid/schedules", []);
|
||||
|
||||
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
foreach (['name', 'minute', 'hour', 'day_of_month', 'day_of_week'] as $i => $field) {
|
||||
$response->assertJsonPath("errors.{$i}.code", 'ValidationException');
|
||||
$response->assertJsonPath("errors.{$i}.meta.rule", 'required');
|
||||
$response->assertJsonPath("errors.{$i}.meta.source_field", $field);
|
||||
$response->assertJsonPath("errors.$i.code", 'ValidationException');
|
||||
$response->assertJsonPath("errors.$i.meta.rule", 'required');
|
||||
$response->assertJsonPath("errors.$i.meta.source_field", $field);
|
||||
}
|
||||
|
||||
$this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules", [
|
||||
->postJson("/api/client/servers/$server->uuid/schedules", [
|
||||
'name' => 'Testing',
|
||||
'is_active' => 'no',
|
||||
'minute' => '*',
|
||||
|
@ -86,7 +85,7 @@ class CreateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_SCHEDULE_UPDATE]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules", [])
|
||||
->postJson("/api/client/servers/$server->uuid/schedules", [])
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,9 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
/**
|
||||
* Test that a schedule can be deleted from the system.
|
||||
*
|
||||
* @param array $permissions
|
||||
* @dataProvider permissionsDataProvider
|
||||
*/
|
||||
public function testScheduleCanBeDeleted($permissions)
|
||||
public function testScheduleCanBeDeleted(array $permissions)
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
|
@ -24,7 +23,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
$task = Task::factory()->create(['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
|
||||
->assertStatus(Response::HTTP_NO_CONTENT);
|
||||
|
||||
$this->assertDatabaseMissing('schedules', ['id' => $schedule->id]);
|
||||
|
@ -39,7 +38,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/123456789")
|
||||
->deleteJson("/api/client/servers/$server->uuid/schedules/123456789")
|
||||
->assertStatus(Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
|
||||
->assertStatus(Response::HTTP_NOT_FOUND);
|
||||
|
||||
$this->assertDatabaseHas('schedules', ['id' => $schedule->id]);
|
||||
|
@ -72,7 +71,7 @@ class DeleteServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->deleteJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
->deleteJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
|
||||
->assertStatus(Response::HTTP_FORBIDDEN);
|
||||
|
||||
$this->assertDatabaseHas('schedules', ['id' => $schedule->id]);
|
||||
|
|
|
@ -23,11 +23,9 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
|||
/**
|
||||
* Test that schedules for a server are returned.
|
||||
*
|
||||
* @param array $permissions
|
||||
* @param bool $individual
|
||||
* @dataProvider permissionsDataProvider
|
||||
*/
|
||||
public function testServerSchedulesAreReturned($permissions, $individual)
|
||||
public function testServerSchedulesAreReturned(array $permissions, bool $individual)
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
|
@ -39,8 +37,8 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
|||
$response = $this->actingAs($user)
|
||||
->getJson(
|
||||
$individual
|
||||
? "/api/client/servers/{$server->uuid}/schedules/{$schedule->id}"
|
||||
: "/api/client/servers/{$server->uuid}/schedules"
|
||||
? "/api/client/servers/$server->uuid/schedules/$schedule->id"
|
||||
: "/api/client/servers/$server->uuid/schedules"
|
||||
)
|
||||
->assertOk();
|
||||
|
||||
|
@ -69,7 +67,7 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
|||
$schedule = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
->getJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
|
@ -81,13 +79,13 @@ class GetServerSchedulesTest extends ClientApiIntegrationTestCase
|
|||
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->getJson("/api/client/servers/{$server->uuid}/schedules")
|
||||
->getJson("/api/client/servers/$server->uuid/schedules")
|
||||
->assertForbidden();
|
||||
|
||||
$schedule = Schedule::factory()->create(['server_id' => $server->id]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->getJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}")
|
||||
->getJson("/api/client/servers/$server->uuid/schedules/$schedule->id")
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,6 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
|
|||
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \string[][]
|
||||
*/
|
||||
public function methodDataProvider(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -11,10 +11,8 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
{
|
||||
/**
|
||||
* The data to use when updating a schedule.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $updateData = [
|
||||
private array $updateData = [
|
||||
'name' => 'Updated Schedule Name',
|
||||
'minute' => '5',
|
||||
'hour' => '*',
|
||||
|
@ -27,10 +25,9 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
/**
|
||||
* Test that a schedule can be updated.
|
||||
*
|
||||
* @param array $permissions
|
||||
* @dataProvider permissionsDataProvider
|
||||
*/
|
||||
public function testScheduleCanBeUpdated($permissions)
|
||||
public function testScheduleCanBeUpdated(array $permissions)
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount($permissions);
|
||||
|
||||
|
@ -48,7 +45,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
$this->assertFalse($schedule->is_active);
|
||||
$this->assertJsonTransformedWith($response->json('attributes'), $schedule);
|
||||
|
||||
$this->assertSame($expected->toIso8601String(), $schedule->next_run_at->toIso8601String());
|
||||
$this->assertSame($expected->toAtomString(), $schedule->next_run_at->toAtomString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue