51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Http\Requests\Bo\Pages\UpdatePageRequest;
|
||
|
|
use Infrastructure\Adapters\Services\AppAdminAuthService;
|
||
|
|
|
||
|
|
use function Pest\Laravel\mock;
|
||
|
|
|
||
|
|
describe('UpdatePageRequest', function () {
|
||
|
|
it('authorizes via auth service', function () {
|
||
|
|
// GIVEN
|
||
|
|
$authService = mock(AppAdminAuthService::class);
|
||
|
|
$authService->shouldReceive('check')->once()->andReturn(true);
|
||
|
|
|
||
|
|
$request = new UpdatePageRequest($authService);
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$request->initialize();
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($request->authorize())->toBeTrue();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('validates rules', function () {
|
||
|
|
// GIVEN
|
||
|
|
$authService = mock(AppAdminAuthService::class);
|
||
|
|
$request = new UpdatePageRequest($authService);
|
||
|
|
$request->initialize();
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$rules = $request->rules();
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($rules)->toHaveKeys(['seo_title', 'seo_description', 'title', 'content']);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('returns attributes', function () {
|
||
|
|
// GIVEN
|
||
|
|
$authService = mock(AppAdminAuthService::class);
|
||
|
|
$request = new UpdatePageRequest($authService);
|
||
|
|
$request->initialize();
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$attributes = $request->attributes();
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($attributes)->toHaveKeys(['seo_title', 'seo_description', 'title', 'content']);
|
||
|
|
});
|
||
|
|
});
|