Skip to content

Commit bbe233b

Browse files
Fix test issues
1 parent d77e8c6 commit bbe233b

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

src/Exceptions/BackupFailed.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ final class BackupFailed extends Exception
1212
{
1313
public function __construct(Throwable $previous)
1414
{
15-
parent::__construct(
16-
__('statamic-backup::backup.failed', ['date' => Carbon::now()->format('Ymd')]),
17-
previous: $previous,
18-
);
15+
parent::__construct(__('statamic-backup::backup.failed', ['date' => Carbon::now()->format(
16+
'Ymd',
17+
)]), previous: $previous);
1918
}
2019
}

src/Http/Controllers/UploadController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ public function __invoke(
2121
BackupRepository $repo,
2222
Backuper $backuper,
2323
): JsonResponse {
24-
return $chunky->put(
25-
ChunkyUploadDto::fromRequest($request),
26-
onCompleted: function (string $completeFile) use ($repo, $backuper): void {
27-
$backup = $repo->add($completeFile);
24+
return $chunky->put(ChunkyUploadDto::fromRequest($request), onCompleted: function (string $completeFile) use (
25+
$repo,
26+
$backuper,
27+
): void {
28+
$backup = $repo->add($completeFile);
2829

29-
$backuper->addMetaFromZipToBackupMeta($completeFile, $backup);
30+
$backuper->addMetaFromZipToBackupMeta($completeFile, $backup);
3031

31-
$backuper->enforceMaxBackups();
32-
},
33-
);
32+
$backuper->enforceMaxBackups();
33+
});
3434
}
3535

3636
public function test(Request $request, Chunky $chunky): JsonResponse

src/ServiceProvider.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,15 @@ private function configureNavigation(): void
9494
private function configurePermissions(): void
9595
{
9696
Permission::extend(static function (PermissionContract $permission): void {
97-
$permission->group(
98-
'itiden-backup',
99-
'Backup',
100-
static fn() => $permission
101-
->register('manage backups')
102-
->label('Manage Backups')
103-
->children([
104-
$permission->make('create backups')->label('Create Backups'),
105-
$permission->make('restore backups')->label('Restore From Backups'),
106-
$permission->make('download backups')->label('Download Backups'),
107-
$permission->make('delete backups')->label('Delete Backups'),
108-
]),
109-
);
97+
$permission->group('itiden-backup', 'Backup', static fn() => $permission
98+
->register('manage backups')
99+
->label('Manage Backups')
100+
->children([
101+
$permission->make('create backups')->label('Create Backups'),
102+
$permission->make('restore backups')->label('Restore From Backups'),
103+
$permission->make('download backups')->label('Download Backups'),
104+
$permission->make('delete backups')->label('Delete Backups'),
105+
]));
110106
});
111107
}
112108
}

src/Support/Chunky.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ public function put(ChunkyUploadDto $dto, ?Closure $onCompleted = null): JsonRes
5151
->reduce(fn(int $carry, string $item): int => $carry + $this->disk->size($item), 0);
5252

5353
if ($chunksOnDiskSize < $dto->totalSize) {
54-
return response()->json(
55-
['message' => 'uploaded ' . $dto->currentChunk . ' of ' . $dto->totalChunks],
56-
Response::HTTP_CREATED,
57-
);
54+
return response()->json([
55+
'message' => 'uploaded ' . $dto->currentChunk . ' of ' . $dto->totalChunks,
56+
], Response::HTTP_CREATED);
5857
}
5958

6059
$completeFile = $this->mergeChunksIntoFile($dto->identifier, $dto->filename, $dto->totalChunks);
@@ -63,10 +62,10 @@ public function put(ChunkyUploadDto $dto, ?Closure $onCompleted = null): JsonRes
6362
$onCompleted($completeFile);
6463
}
6564

66-
return response()->json(
67-
['message' => 'File successfully uploaded', 'file' => $completeFile],
68-
Response::HTTP_CREATED,
69-
);
65+
return response()->json([
66+
'message' => 'File successfully uploaded',
67+
'file' => $completeFile,
68+
], Response::HTTP_CREATED);
7069
}
7170

7271
/**

tests/Feature/ViewBackupsTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use Inertia\Testing\AssertableInertia;
56
use Itiden\Backup\Facades\Backuper;
67
use Itiden\Backup\Pipes\Users;
78

@@ -32,7 +33,11 @@
3233

3334
actingAs($user);
3435

35-
get(cp_route('itiden.backup.index'))->assertOk()->assertViewIs('itiden-backup::backups');
36+
$response = get(cp_route('itiden.backup.index'));
37+
38+
$response->assertInertia(function (AssertableInertia $page) {
39+
$page->component('statamic-backup::page');
40+
});
3641
});
3742

3843
test('user without permission cant get backups from api', function (): void {

0 commit comments

Comments
 (0)