diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 62f6106ac..502dbe708 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -15,7 +15,7 @@ jobs: - name: Run PHP CS Fixer uses: docker://oskarstark/php-cs-fixer-ga with: - args: --config=.php_cs.dist.php --allow-risky=yes + args: --config=.php-cs-fixer.dist.php --allow-risky=yes - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/.php_cs.dist.php b/.php-cs-fixer.dist.php similarity index 73% rename from .php_cs.dist.php rename to .php-cs-fixer.dist.php index d612a548b..d1466aac8 100644 --- a/.php_cs.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,34 +2,40 @@ $finder = Symfony\Component\Finder\Finder::create() ->in([ - __DIR__ . '/src', - __DIR__ . '/tests', + __DIR__.'/src', + __DIR__.'/tests', ]) ->name('*.php') ->notName('*.blade.php') ->ignoreDotFiles(true) - ->ignoreVCS(true); + ->ignoreVCS(true) +; return (new PhpCsFixer\Config()) ->setRules([ - '@PSR2' => true, + '@PSR12' => true, 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sort_algorithm' => 'alpha'], - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => true, - 'trailing_comma_in_multiline' => true, - 'phpdoc_scalar' => true, - 'unary_operator_spaces' => true, 'binary_operator_spaces' => true, 'blank_line_before_statement' => [ 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], ], - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => ['elements' => ['method' => 'one']], + 'combine_consecutive_unsets' => true, 'method_argument_space' => [ 'on_multiline' => 'ensure_fully_multiline', 'keep_multiple_spaces_after_comma' => true, ], + 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'phpdoc_scalar' => true, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, 'single_trait_insert_per_statement' => true, + 'single_quote' => true, + 'trailing_comma_in_multiline' => true, + 'unary_operator_spaces' => true, ]) - ->setFinder($finder); + ->setFinder($finder) +; diff --git a/composer.json b/composer.json index ac33e5a56..4b39a5786 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ }, "require-dev": { "brianium/paratest": "^6.2", + "friendsofphp/php-cs-fixer": "^3.8", "nunomaduro/collision": "^5.3", "orchestra/testbench": "^6.0|^7.0", "phpunit/phpunit": "^9.3", diff --git a/src/Bootstrap/BootRepository.php b/src/Bootstrap/BootRepository.php index 5dcdcf2be..e91a59d7c 100644 --- a/src/Bootstrap/BootRepository.php +++ b/src/Bootstrap/BootRepository.php @@ -7,7 +7,6 @@ class BootRepository { /** * @var Repository */ - public function __construct( private string $repository ) { diff --git a/src/Commands/PublishAuthCommand.php b/src/Commands/PublishAuthCommand.php index d4c57c700..7d417a726 100644 --- a/src/Commands/PublishAuthCommand.php +++ b/src/Commands/PublishAuthCommand.php @@ -95,7 +95,7 @@ public function checkDirectory(string $path): self */ protected function copyDirectory(string $path, string $stubDirectory, string $format): self { - $filesystem = new Filesystem; + $filesystem = new Filesystem(); collect($filesystem->allFiles(__DIR__ . $stubDirectory)) ->each(function (SplFileInfo $file) use ($filesystem, $path, $format, $stubDirectory) { diff --git a/src/Fields/BelongsTo.php b/src/Fields/BelongsTo.php index ec40baa27..3febcc356 100644 --- a/src/Fields/BelongsTo.php +++ b/src/Fields/BelongsTo.php @@ -29,7 +29,6 @@ public function __construct($relation, $parentRepository) $this->repositoryClass = $parentRepository; } - public function fillAttribute(RestifyRequest $request, $model, int $bulkRow = null) { /** * @var Model $relatedModel */ diff --git a/src/Fields/Concerns/Attachable.php b/src/Fields/Concerns/Attachable.php index 0cc5b7de9..b1c6dc443 100644 --- a/src/Fields/Concerns/Attachable.php +++ b/src/Fields/Concerns/Attachable.php @@ -120,8 +120,8 @@ public function initializePivot(RestifyRequest $request, $relationship, $related if ($relationship->withTimestamps) { $pivot->forceFill([ - $relationship->createdAt() => new DateTime, - $relationship->updatedAt() => new DateTime, + $relationship->createdAt() => new DateTime(), + $relationship->updatedAt() => new DateTime(), ]); } diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index f7ec47085..1fe5dee64 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -62,12 +62,7 @@ public function __construct() $this->booted(); } - protected function booted() - { - // - } - - abstract public function filter(RestifyRequest $request, Builder | Relation $query, $value); + abstract public function filter(RestifyRequest $request, Builder|Relation $query, $value); public function canSee(Closure $callback) { @@ -86,31 +81,7 @@ public function key(): string return static::class; } - protected function getType(): string - { - return $this->type; - } - - protected function title(): string - { - if ($this->title) { - return $this->title; - } - - if ($column = $this->column()) { - return Str::title(Str::snake(Str::studly($column), ' ')); - } - - return $this->title ?? Str::title(Str::snake(class_basename(static::class), ' ')); - } - - protected function description(): string - { - return $this->description; - } - /** - * @return string|null * @deprecated use `column()` instead */ public function getColumn(): ?string @@ -155,7 +126,9 @@ public function invalidPayloadValue(Request $request, $value) { if (is_array($value)) { return count($value) < 1; - } elseif (is_string($value)) { + } + + if (is_string($value)) { return trim($value) === ''; } @@ -188,6 +161,13 @@ public function setRepository(Repository $repository): self return $this; } + public function setTitle(string $title): self + { + $this->title = $title; + + return $this; + } + public function repository(): ?Repository { if (! isset($this->repository)) { @@ -222,8 +202,6 @@ public function getRelatedRepository(): ?array /** * Get the URI key for the filter. - * - * @return string */ public static function uriKey(): string { @@ -257,7 +235,6 @@ public function jsonSerialize() ]) : $initial; }); - if ($this->isAdvanced()) { $serialized = array_merge($serialized, [ 'rules' => $this->rules(app(Request::class)), @@ -278,4 +255,31 @@ public function dd(): self return $this; } + + protected function booted() + { + } + + protected function getType(): string + { + return $this->type; + } + + protected function title(): string + { + if ($this->title) { + return $this->title; + } + + if ($column = $this->column()) { + return Str::title(Str::snake(Str::studly($column), ' ')); + } + + return $this->title ?? Str::title(Str::snake(class_basename(static::class), ' ')); + } + + protected function description(): string + { + return $this->description; + } } diff --git a/src/Filters/SearchableFilter.php b/src/Filters/SearchableFilter.php index 371158cc4..0ef4c9e92 100644 --- a/src/Filters/SearchableFilter.php +++ b/src/Filters/SearchableFilter.php @@ -7,7 +7,7 @@ class SearchableFilter extends Filter { - const TYPE = 'searchable'; + public const TYPE = 'searchable'; public array $computedColumns = []; diff --git a/src/Http/Controllers/Auth/ResetPasswordController.php b/src/Http/Controllers/Auth/ResetPasswordController.php index 7c1431a4a..f48427ef6 100644 --- a/src/Http/Controllers/Auth/ResetPasswordController.php +++ b/src/Http/Controllers/Auth/ResetPasswordController.php @@ -32,6 +32,6 @@ public function __invoke(Request $request): JsonResponse Password::deleteToken($user); - return data("Password has been successfully changed"); + return data('Password has been successfully changed'); } } diff --git a/src/Http/Controllers/RestResponse.php b/src/Http/Controllers/RestResponse.php index 24b4f2d6f..2e7df52ee 100644 --- a/src/Http/Controllers/RestResponse.php +++ b/src/Http/Controllers/RestResponse.php @@ -50,23 +50,23 @@ class RestResponse extends JsonResponse implements Responsable /** * Response Codes. */ - const REST_RESPONSE_AUTH_CODE = 401; - const REST_RESPONSE_REFRESH_CODE = 103; - const REST_RESPONSE_CREATED_CODE = 201; - const REST_RESPONSE_UPDATED_CODE = 200; - const REST_RESPONSE_DELETED_CODE = 204; // update or delete with success - const REST_RESPONSE_BLANK_CODE = 204; - const REST_RESPONSE_ERROR_CODE = 500; - const REST_RESPONSE_INVALID_CODE = 400; - const REST_RESPONSE_UNAUTHORIZED_CODE = 401; - const REST_RESPONSE_FORBIDDEN_CODE = 403; - const REST_RESPONSE_MISSING_CODE = 404; - const REST_RESPONSE_NOTFOUND_CODE = 404; - const REST_RESPONSE_THROTTLE_CODE = 429; - const REST_RESPONSE_SUCCESS_CODE = 200; - const REST_RESPONSE_UNAVAILABLE_CODE = 503; - - const CODES = [ + public const REST_RESPONSE_AUTH_CODE = 401; + public const REST_RESPONSE_REFRESH_CODE = 103; + public const REST_RESPONSE_CREATED_CODE = 201; + public const REST_RESPONSE_UPDATED_CODE = 200; + public const REST_RESPONSE_DELETED_CODE = 204; // update or delete with success + public const REST_RESPONSE_BLANK_CODE = 204; + public const REST_RESPONSE_ERROR_CODE = 500; + public const REST_RESPONSE_INVALID_CODE = 400; + public const REST_RESPONSE_UNAUTHORIZED_CODE = 401; + public const REST_RESPONSE_FORBIDDEN_CODE = 403; + public const REST_RESPONSE_MISSING_CODE = 404; + public const REST_RESPONSE_NOTFOUND_CODE = 404; + public const REST_RESPONSE_THROTTLE_CODE = 429; + public const REST_RESPONSE_SUCCESS_CODE = 200; + public const REST_RESPONSE_UNAVAILABLE_CODE = 503; + + public const CODES = [ self::REST_RESPONSE_AUTH_CODE, self::REST_RESPONSE_REFRESH_CODE, self::REST_RESPONSE_CREATED_CODE, diff --git a/src/Http/Requests/Concerns/DetermineRequestType.php b/src/Http/Requests/Concerns/DetermineRequestType.php index afce8d9e6..717a021ce 100644 --- a/src/Http/Requests/Concerns/DetermineRequestType.php +++ b/src/Http/Requests/Concerns/DetermineRequestType.php @@ -1,6 +1,5 @@ app->singleton('laravel-restify', function () { - return new Restify; + return new Restify(); }); $this->commands([ diff --git a/src/Models/ActionLog.php b/src/Models/ActionLog.php index 43413c9ad..c98120390 100644 --- a/src/Models/ActionLog.php +++ b/src/Models/ActionLog.php @@ -35,11 +35,11 @@ class ActionLog extends Model 'changes' => 'array', ]; - const STATUS_FINISHED = 'finished'; + public const STATUS_FINISHED = 'finished'; - const ACTION_CREATED = 'Stored'; - const ACTION_UPDATED = 'Updated'; - const ACTION_DELETED = 'Deleted'; + public const ACTION_CREATED = 'Stored'; + public const ACTION_UPDATED = 'Updated'; + public const ACTION_DELETED = 'Deleted'; public static function forRepositoryStored(Model $model, Authenticatable $user = null, array $dirty = null): self { diff --git a/src/Restify.php b/src/Restify.php index f4d744388..de25b48e0 100644 --- a/src/Restify.php +++ b/src/Restify.php @@ -101,7 +101,7 @@ public static function repositories(array $repositories) (new BootRepository($repository))->boot(); }); - return new static; + return new static(); } /** @@ -117,7 +117,7 @@ public static function repositoriesFrom(string $directory): void $repositories = []; - foreach ((new Finder)->in($directory)->files() as $repository) { + foreach ((new Finder())->in($directory)->files() as $repository) { $repository = $namespace.str_replace( ['/', '.php'], ['\\', ''], diff --git a/src/Services/Search/RepositorySearchService.php b/src/Services/Search/RepositorySearchService.php index 0334030d7..701d75792 100644 --- a/src/Services/Search/RepositorySearchService.php +++ b/src/Services/Search/RepositorySearchService.php @@ -195,6 +195,6 @@ protected function applyFilters(RestifyRequest $request, Repository $repository, public static function make(): static { - return new static; + return new static(); } } diff --git a/src/Traits/AuthorizableModels.php b/src/Traits/AuthorizableModels.php index 9fb99a28c..170bd435d 100644 --- a/src/Traits/AuthorizableModels.php +++ b/src/Traits/AuthorizableModels.php @@ -256,6 +256,6 @@ public function authorizedTo(Request $request, $ability) */ public static function isRepositoryContext() { - return new static instanceof Repository; + return new static() instanceof Repository; } } diff --git a/src/Traits/AuthorizesRequests.php b/src/Traits/AuthorizesRequests.php index c0bb26ceb..1e81ef1b5 100644 --- a/src/Traits/AuthorizesRequests.php +++ b/src/Traits/AuthorizesRequests.php @@ -21,7 +21,7 @@ public static function auth($callback) { static::$authUsing = $callback; - return new static; + return new static(); } /** diff --git a/src/Traits/InteractWithSQLight.php b/src/Traits/InteractWithSQLight.php index 4031024b6..618a6e6a5 100644 --- a/src/Traits/InteractWithSQLight.php +++ b/src/Traits/InteractWithSQLight.php @@ -19,7 +19,7 @@ public static function resolveConnection($connection = null) public static function bootSushi() { - $instance = (new static); + $instance = (new static()); $cacheFileName = 'sushi-'.Str::kebab(str_replace('\\', '', static::class)).'.sqlite'; $cacheDirectory = realpath(config('sushi.cache-path', storage_path('framework/cache'))); $cachePath = $cacheDirectory.'/'.$cacheFileName; diff --git a/src/Traits/InteractWithSearch.php b/src/Traits/InteractWithSearch.php index 4aa5e6eac..b376799e4 100644 --- a/src/Traits/InteractWithSearch.php +++ b/src/Traits/InteractWithSearch.php @@ -108,7 +108,7 @@ public static function collectFilters($type): Collection return $type instanceof Filter ? tap($type, fn ($filter) => $filter->column = $filter->column ?? $column) - : tap(new $base, function (Filter $filter) use ($column, $type) { + : tap(new $base(), function (Filter $filter) use ($column, $type) { $filter->type = $type ? $type : 'value'; $filter->column = $column; }); diff --git a/tests/Actions/FieldActionTest.php b/tests/Actions/FieldActionTest.php index 99d7d1499..b49f792be 100644 --- a/tests/Actions/FieldActionTest.php +++ b/tests/Actions/FieldActionTest.php @@ -15,7 +15,7 @@ class FieldActionTest extends IntegrationTest /** * @test */ public function can_use_actionable_field(): void { - $action = new class extends Action { + $action = new class () extends Action { public bool $showOnShow = true; public function handle(RestifyRequest $request, Post $post) @@ -53,7 +53,7 @@ public function handle(RestifyRequest $request, Post $post) /** @test */ public function can_use_actionable_field_on_bulk_store(): void { - $action = new class extends Action { + $action = new class () extends Action { public bool $showOnShow = true; public function handle(RestifyRequest $request, Post $post, int $row) @@ -99,7 +99,7 @@ public function handle(RestifyRequest $request, Post $post, int $row) /** @test */ public function can_use_actionable_field_on_bulk_update(): void { - $action = new class extends Action { + $action = new class () extends Action { public bool $showOnShow = true; public function handle(RestifyRequest $request, Post $post, int $row) diff --git a/tests/Actions/PerformActionControllerTest.php b/tests/Actions/PerformActionControllerTest.php index bfdb1720b..f7186df84 100644 --- a/tests/Actions/PerformActionControllerTest.php +++ b/tests/Actions/PerformActionControllerTest.php @@ -46,7 +46,7 @@ public function test_could_perform_action_using_all() PostRepository::partialMock() ->shouldReceive('actions') ->andReturn([ - new class extends Action { + new class () extends Action { public static $uriKey = 'publish'; public function handle(Request $request, Collection $collection) @@ -77,7 +77,7 @@ public function test_show_action_not_need_repositories() { $users = $this->mockUsers(); - $this->postJson('users/'.$users->first()->id.'/action?action='.(new ActivateAction)->uriKey()) + $this->postJson('users/'.$users->first()->id.'/action?action='.(new ActivateAction())->uriKey()) ->assertSuccessful() ->assertJsonStructure([ 'data', diff --git a/tests/Controllers/RepositoryAttachControllerTest.php b/tests/Controllers/RepositoryAttachControllerTest.php index 6800cae0e..0a4168992 100644 --- a/tests/Controllers/RepositoryAttachControllerTest.php +++ b/tests/Controllers/RepositoryAttachControllerTest.php @@ -191,7 +191,7 @@ public function test_many_to_many_field_can_intercept_attach_method(): void return true; }) - ->attachCallback(new AttachInvokable), + ->attachCallback(new AttachInvokable()), ]); $this->postJson('companies/'.$company->id.'/attach/users', [ diff --git a/tests/Feature/ActionLogTest.php b/tests/Feature/ActionLogTest.php index 206884b6c..aada3d0a7 100644 --- a/tests/Feature/ActionLogTest.php +++ b/tests/Feature/ActionLogTest.php @@ -97,7 +97,7 @@ public function test_can_create_log_for_repository_custom_action() $user = User::factory()->create(); - $action = new class extends Action { + $action = new class () extends Action { public static $uriKey = 'test action'; }; diff --git a/tests/Fields/BelongsToFieldTest.php b/tests/Fields/BelongsToFieldTest.php index dda664634..6f16384b4 100644 --- a/tests/Fields/BelongsToFieldTest.php +++ b/tests/Fields/BelongsToFieldTest.php @@ -28,9 +28,9 @@ protected function setUp(): void PostWithUserRepository::class, ]); - unset($_SERVER['restify.post.store']); - unset($_SERVER['restify.post.allowRestify']); - unset($_SERVER['restify.users.show']); + unset($_SERVER['restify.post.store'], $_SERVER['restify.post.allowRestify'], $_SERVER['restify.users.show']); + + } protected function tearDown(): void diff --git a/tests/Fields/FieldTest.php b/tests/Fields/FieldTest.php index d0f01b2a7..a0137510f 100644 --- a/tests/Fields/FieldTest.php +++ b/tests/Fields/FieldTest.php @@ -95,7 +95,7 @@ public function test_field_can_have_custom_store_callback(): void 'title' => 'Request value.', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -113,7 +113,7 @@ public function test_field_keep_its_value_if_request_empty(): void { $request = new RepositoryStoreRequest([], []); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -134,7 +134,7 @@ public function test_field_can_have_custom_update_callback(): void 'title' => 'Request title.', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -151,7 +151,7 @@ public function test_field_fill_callback_has_high_priority(): void { $request = new RepositoryStoreRequest([], []); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -160,7 +160,7 @@ public function test_field_fill_callback_has_high_priority(): void ->value(function () { return 'from append callback'; }) - ->fillCallback(new InvokableFill) + ->fillCallback(new InvokableFill()) ->storeCallback(function () { return 'from store callback'; }) @@ -189,7 +189,7 @@ public function test_field_fill_from_request() 'title' => 'title from request', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -217,7 +217,7 @@ public function test_append_overwrite_the_request_value() 'title' => 'title from request', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -245,13 +245,13 @@ public function test_field_after_store_called(): void 'title' => 'After store title', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $table = 'posts'; protected $fillable = ['title']; }; /** * @var Field $field */ - $field = Field::new('title')->afterStore(new InvokableAfterStore); + $field = Field::new('title')->afterStore(new InvokableAfterStore()); $field->fillAttribute($request, $model); @@ -262,7 +262,7 @@ public function test_field_after_store_called(): void public function test_field_after_update_called() { - $model = new class extends Model { + $model = new class () extends Model { protected $table = 'posts'; protected $fillable = ['title']; }; @@ -324,7 +324,7 @@ public function test_fill_field_using_label_key() 'custom_title' => 'title from request', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $fillable = ['title']; }; @@ -344,7 +344,7 @@ public function test_field_can_be_filled_from_the_append_value() 'title' => 'Title from the request.', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $table = 'posts'; protected $fillable = ['title']; }; @@ -374,7 +374,7 @@ public function test_field_can_be_filled_from_the_append_callback() 'title' => 'Title from the request.', ]); - $model = new class extends Model { + $model = new class () extends Model { protected $table = 'posts'; protected $fillable = ['title']; }; diff --git a/tests/Fields/HasManyTest.php b/tests/Fields/HasManyTest.php index 7f4a225a0..2da905f4a 100644 --- a/tests/Fields/HasManyTest.php +++ b/tests/Fields/HasManyTest.php @@ -26,9 +26,9 @@ protected function setUp(): void UserWithPosts::class, ]); - unset($_SERVER['restify.post.show']); - unset($_SERVER['restify.post.delete']); - unset($_SERVER['restify.post.allowRestify']); + unset($_SERVER['restify.post.show'], $_SERVER['restify.post.delete'], $_SERVER['restify.post.allowRestify']); + + } protected function tearDown(): void diff --git a/tests/Fixtures/Post/PublishPostAction.php b/tests/Fixtures/Post/PublishPostAction.php index 160b20d76..6b335a48e 100644 --- a/tests/Fixtures/Post/PublishPostAction.php +++ b/tests/Fixtures/Post/PublishPostAction.php @@ -17,7 +17,6 @@ public static function indexQuery(RestifyRequest $request, $query) $query->whereNotNull('published_at'); } - public function handle(ActionRequest $request, Collection $models): JsonResponse { static::$applied[] = $models; diff --git a/tests/Fixtures/User/SampleUser.php b/tests/Fixtures/User/SampleUser.php index e9d6c3894..b7c243cec 100644 --- a/tests/Fixtures/User/SampleUser.php +++ b/tests/Fixtures/User/SampleUser.php @@ -17,7 +17,7 @@ public function getEmail() public function createToken($name, array $scopes = []) { - return new class { + return new class () { public $accessToken = 'token'; }; } diff --git a/tests/Fixtures/User/User.php b/tests/Fixtures/User/User.php index 089d74bb1..93db10ada 100644 --- a/tests/Fixtures/User/User.php +++ b/tests/Fixtures/User/User.php @@ -72,7 +72,7 @@ public function getEmail() public function createToken($name, array $scopes = []) { - return new class { + return new class () { public $accessToken = 'token'; }; } diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 5bda429e4..b87b5d438 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -134,18 +134,21 @@ public function getTempDirectory($suffix = ''): string return __DIR__ . '/TestSupport/temp' . ($suffix === '' ? '' : '/' . $suffix); } - #[Pure] public function getMediaDirectory($suffix = ''): string - { - return $this->getTempDirectory() . '/media' . ($suffix === '' ? '' : '/' . $suffix); - } - - #[Pure] public function getTestFilesDirectory($suffix = ''): string - { - return $this->getTempDirectory() . '/testfiles' . ($suffix === '' ? '' : '/' . $suffix); - } - - #[Pure] public function getTestJpg(): string - { - return $this->getTestFilesDirectory('test.jpg'); - } + #[Pure] + public function getMediaDirectory($suffix = ''): string + { + return $this->getTempDirectory() . '/media' . ($suffix === '' ? '' : '/' . $suffix); + } + + #[Pure] + public function getTestFilesDirectory($suffix = ''): string + { + return $this->getTempDirectory() . '/testfiles' . ($suffix === '' ? '' : '/' . $suffix); + } + + #[Pure] + public function getTestJpg(): string + { + return $this->getTestFilesDirectory('test.jpg'); + } } diff --git a/tests/Unit/AdvancedFilterTest.php b/tests/Unit/AdvancedFilterTest.php index 4e4520968..094db54eb 100644 --- a/tests/Unit/AdvancedFilterTest.php +++ b/tests/Unit/AdvancedFilterTest.php @@ -14,7 +14,7 @@ class AdvancedFilterTest extends IntegrationTest { public function test_advanced_filters_can_serialize(): void { - $filter = new class extends AdvancedFilter { + $filter = new class () extends AdvancedFilter { public static $uriKey = 'status-filter'; public string $type = 'multiselect'; @@ -62,8 +62,7 @@ function (AssertableJson $json) { ->where('options', [[ 'label' => 'Draft', 'property' => 'draft', - ]]) - ; + ]]); } ); } diff --git a/tests/Unit/MatchableFilterTest.php b/tests/Unit/MatchableFilterTest.php index c40a10c6b..7c027600c 100644 --- a/tests/Unit/MatchableFilterTest.php +++ b/tests/Unit/MatchableFilterTest.php @@ -10,7 +10,7 @@ class MatchableFilterTest extends IntegrationTest { public function test_matchable_filter_has_key(): void { - $filter = new class extends MatchFilter { + $filter = new class () extends MatchFilter { public ?string $column = 'approved_at'; }; @@ -22,8 +22,7 @@ function (AssertableJson $json) { ->where('key', 'matches') ->where('title', 'Approved At') ->where('column', 'approved_at') - ->etc() - ; + ->etc(); } ); }