Skip to content

Commit

Permalink
Upgrade types for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Sep 26, 2024
1 parent 228c46c commit 2c5329b
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 64 deletions.
10 changes: 1 addition & 9 deletions tests/App/Components/SimpleShowValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@

class SimpleShowValue extends Component
{
/**
* @var User
*/
public $value;

/**
* Create a new component instance.
*
* @param mixed $value
*/
public function __construct($value)
public function __construct(public mixed $value)
{
$this->value = $value;
}

/**
Expand Down
23 changes: 2 additions & 21 deletions tests/App/Components/SimpleShowValueWithArguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,12 @@

class SimpleShowValueWithArguments extends Component
{
/**
* @var mixed
*/
public $value;

/**
* @var Application
*/
public $application;

/**
* @var string
*/
public $from;

/**
* Create a new component instance.
*
* @param mixed $value
*/
public function __construct(Application $application, $value, string $from = 'Alexandr')
public function __construct(public Application $application, public mixed $value, public string $from = 'Alexandr')
{
$this->value = $value;
$this->application = $application;
$this->from = $from;

}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/App/Layouts/DependentSumListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function layouts(): array
*/
public function getSlug(): string
{
return sha1($this->slug);
return sha1((string) $this->slug);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions tests/App/Notifications/TaskCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ class TaskCompleted extends Notification

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*/
public function via($notifiable): array
public function via(mixed $notifiable): array
{
return [DashboardChannel::class];
}
Expand All @@ -35,10 +33,8 @@ public function toDashboard($notifiable): DashboardMessage

/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*/
public function toArray($notifiable): array
public function toArray(mixed $notifiable): array
{
return [
//
Expand Down
2 changes: 1 addition & 1 deletion tests/App/RouteSolving.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function resolveChildRouteBinding($childType, $value, $field)
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return 'Hello Word';
}
Expand Down
4 changes: 1 addition & 3 deletions tests/App/Screens/SerializeRetrievableScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public function __construct(
private readonly string $private = 'Private',
public $user = null
) {
$this->middleware(function ($request, $next) {
return $next($request);
});
$this->middleware(fn($request, $next) => $next($request));
}

/**
Expand Down
4 changes: 1 addition & 3 deletions tests/App/Screens/SerializeScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public function __construct(
private readonly string $private = 'Private',
public $user = null
) {
$this->middleware(function ($request, $next) {
return $next($request);
});
$this->middleware(fn($request, $next) => $next($request));
}

/**
Expand Down
4 changes: 1 addition & 3 deletions tests/Feature/App/RouteResolveScreenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ public function testExplicitBinding(): void

public function testResolutionLogic(): void
{
Route::bind('user', function ($value) {
return User::where('email', $value)->firstOrFail();
});
Route::bind('user', fn($value) => User::where('email', $value)->firstOrFail());

Route::screen('bind/users/{user}', ModelRouteBindScreen::class)
->middleware(config('platform.middleware.private'))
Expand Down
20 changes: 8 additions & 12 deletions tests/Feature/Platform/RelationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ public function testScopeModel(array $scope): void
{
$response = $this->getScope($scope);

$json = $this->users->map(function ($user) {
return [
'value' => $user->id,
'label' => $user->email,
];
})->toArray();
$json = $this->users->map(fn($user) => [
'value' => $user->id,
'label' => $user->email,
])->toArray();

$response->assertJson($json);
}
Expand All @@ -63,12 +61,10 @@ public function testAppendModel(array $scope): void
{
$response = $this->getScope($scope, 'full');

$json = $this->users->map(function ($user) {
return [
'value' => $user->id,
'label' => $user->name.' ('.$user->email.')',
];
})->toArray();
$json = $this->users->map(fn($user) => [
'value' => $user->id,
'label' => $user->name.' ('.$user->email.')',
])->toArray();

$response->assertJson($json);
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Unit/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,11 @@ public static function exampleFields(): ?\Generator
}

/**
* @param mixed $options
*
* @dataProvider exampleFields
*
* @throws \Throwable
*/
public function testHasCorrectInstance(string $field, $options): void
public function testHasCorrectInstance(string $field, mixed $options): void
{
/** @var \Orchid\Screen\Field $field */
$field = $field::make();
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Screen/Fields/RelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testInstanceArrayWithStringPrimary(): void

$select = Relation::make('role')
->title('Select roles')
->fromModel(get_class(new $stringPrimaryClass), 'name')
->fromModel($stringPrimaryClass::class, 'name')
->value($current->getRoleSlug());

$view = self::renderField($select);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Screen/Fields/RelationWithEnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testInstanceArrayWithStringPrimary(): void

$select = Relation::make('role')
->title('Select roles')
->fromModel(get_class(new $stringPrimaryClass), 'name')
->fromModel($stringPrimaryClass::class, 'name')
->value($current->getRoleSlug());

$view = self::renderField($select);
Expand Down

0 comments on commit 2c5329b

Please sign in to comment.