Skip to content

Commit

Permalink
fix(Testing): Upgrade Laravel assert (construct, nullable, remove arr…
Browse files Browse the repository at this point in the history
…ay_values)
  • Loading branch information
pionl committed Jun 27, 2023
1 parent 2b05ae1 commit c30fc9c
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 150 deletions.
65 changes: 33 additions & 32 deletions src/Testing/Laravel/Contracts/Auth/Access/GateAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
class GateAssert extends AbstractExpectationCallsMap implements Gate
{
/**
* @param array<GateHasExpectation> $has
* @param array<GateDefineExpectation> $define
* @param array<GateResourceExpectation> $resource
* @param array<GatePolicyExpectation> $policy
* @param array<GateBeforeExpectation> $before
* @param array<GateAfterExpectation> $after
* @param array<GateAllowsExpectation> $allows
* @param array<GateDeniesExpectation> $denies
* @param array<GateCheckExpectation> $check
* @param array<GateAnyExpectation> $any
* @param array<GateAuthorizeExpectation> $authorize
* @param array<GateInspectExpectation> $inspect
* @param array<GateRawExpectation> $raw
* @param array<GateGetPolicyForExpectation> $getPolicyFor
* @param array<GateForUserExpectation> $forUser
* @param array<GateAbilitiesExpectation> $abilities
* @param array<GateHasExpectation|null> $has
* @param array<GateDefineExpectation|null> $define
* @param array<GateResourceExpectation|null> $resource
* @param array<GatePolicyExpectation|null> $policy
* @param array<GateBeforeExpectation|null> $before
* @param array<GateAfterExpectation|null> $after
* @param array<GateAllowsExpectation|null> $allows
* @param array<GateDeniesExpectation|null> $denies
* @param array<GateCheckExpectation|null> $check
* @param array<GateAnyExpectation|null> $any
* @param array<GateAuthorizeExpectation|null> $authorize
* @param array<GateInspectExpectation|null> $inspect
* @param array<GateRawExpectation|null> $raw
* @param array<GateGetPolicyForExpectation|null> $getPolicyFor
* @param array<GateForUserExpectation|null> $forUser
* @param array<GateAbilitiesExpectation|null> $abilities
*/
public function __construct(
array $has = [],
Expand All @@ -48,22 +48,23 @@ public function __construct(
array $forUser = [],
array $abilities = [],
) {
$this->setExpectations(GateHasExpectation::class, array_values(array_filter($has)));
$this->setExpectations(GateDefineExpectation::class, array_values(array_filter($define)));
$this->setExpectations(GateResourceExpectation::class, array_values(array_filter($resource)));
$this->setExpectations(GatePolicyExpectation::class, array_values(array_filter($policy)));
$this->setExpectations(GateBeforeExpectation::class, array_values(array_filter($before)));
$this->setExpectations(GateAfterExpectation::class, array_values(array_filter($after)));
$this->setExpectations(GateAllowsExpectation::class, array_values(array_filter($allows)));
$this->setExpectations(GateDeniesExpectation::class, array_values(array_filter($denies)));
$this->setExpectations(GateCheckExpectation::class, array_values(array_filter($check)));
$this->setExpectations(GateAnyExpectation::class, array_values(array_filter($any)));
$this->setExpectations(GateAuthorizeExpectation::class, array_values(array_filter($authorize)));
$this->setExpectations(GateInspectExpectation::class, array_values(array_filter($inspect)));
$this->setExpectations(GateRawExpectation::class, array_values(array_filter($raw)));
$this->setExpectations(GateGetPolicyForExpectation::class, array_values(array_filter($getPolicyFor)));
$this->setExpectations(GateForUserExpectation::class, array_values(array_filter($forUser)));
$this->setExpectations(GateAbilitiesExpectation::class, array_values(array_filter($abilities)));
parent::__construct();
$this->setExpectations(GateHasExpectation::class, $has);
$this->setExpectations(GateDefineExpectation::class, $define);
$this->setExpectations(GateResourceExpectation::class, $resource);
$this->setExpectations(GatePolicyExpectation::class, $policy);
$this->setExpectations(GateBeforeExpectation::class, $before);
$this->setExpectations(GateAfterExpectation::class, $after);
$this->setExpectations(GateAllowsExpectation::class, $allows);
$this->setExpectations(GateDeniesExpectation::class, $denies);
$this->setExpectations(GateCheckExpectation::class, $check);
$this->setExpectations(GateAnyExpectation::class, $any);
$this->setExpectations(GateAuthorizeExpectation::class, $authorize);
$this->setExpectations(GateInspectExpectation::class, $inspect);
$this->setExpectations(GateRawExpectation::class, $raw);
$this->setExpectations(GateGetPolicyForExpectation::class, $getPolicyFor);
$this->setExpectations(GateForUserExpectation::class, $forUser);
$this->setExpectations(GateAbilitiesExpectation::class, $abilities);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions src/Testing/Laravel/Contracts/Auth/GuardAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ public function __construct(
array $hasUser = [],
array $setUser = [],
) {
$this->setExpectations(GuardCheckExpectation::class, array_values(array_filter($check)));
$this->setExpectations(GuardGuestExpectation::class, array_values(array_filter($guest)));
$this->setExpectations(GuardUserExpectation::class, array_values(array_filter($user)));
$this->setExpectations(GuardIdExpectation::class, array_values(array_filter($id)));
$this->setExpectations(GuardValidateExpectation::class, array_values(array_filter($validate)));
$this->setExpectations(GuardHasUserExpectation::class, array_values(array_filter($hasUser)));
$this->setExpectations(GuardSetUserExpectation::class, array_values(array_filter($setUser)));
parent::__construct();
$this->setExpectations(GuardCheckExpectation::class, $check);
$this->setExpectations(GuardGuestExpectation::class, $guest);
$this->setExpectations(GuardUserExpectation::class, $user);
$this->setExpectations(GuardIdExpectation::class, $id);
$this->setExpectations(GuardValidateExpectation::class, $validate);
$this->setExpectations(GuardHasUserExpectation::class, $hasUser);
$this->setExpectations(GuardSetUserExpectation::class, $setUser);
}

/**
Expand Down
35 changes: 15 additions & 20 deletions src/Testing/Laravel/Contracts/Bus/DispatcherAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
class DispatcherAssert extends AbstractExpectationCallsMap implements Dispatcher
{
/**
* @param array<DispatcherDispatchExpectation> $dispatch
* @param array<DispatcherDispatchSyncExpectation> $dispatchSync
* @param array<DispatcherDispatchNowExpectation> $dispatchNow
* @param array<DispatcherHasCommandHandlerExpectation> $hasCommandHandler
* @param array<DispatcherGetCommandHandlerExpectation> $getCommandHandler
* @param array<DispatcherPipeThroughExpectation> $pipeThrough
* @param array<DispatcherMapExpectation> $map
* @param array<DispatcherDispatchExpectation|null> $dispatch
* @param array<DispatcherDispatchSyncExpectation|null> $dispatchSync
* @param array<DispatcherDispatchNowExpectation|null> $dispatchNow
* @param array<DispatcherHasCommandHandlerExpectation|null> $hasCommandHandler
* @param array<DispatcherGetCommandHandlerExpectation|null> $getCommandHandler
* @param array<DispatcherPipeThroughExpectation|null> $pipeThrough
* @param array<DispatcherMapExpectation|null> $map
*/
public function __construct(
array $dispatch = [],
Expand All @@ -28,19 +28,14 @@ public function __construct(
array $pipeThrough = [],
array $map = [],
) {
$this->setExpectations(DispatcherDispatchExpectation::class, array_values(array_filter($dispatch)));
$this->setExpectations(DispatcherDispatchSyncExpectation::class, array_values(array_filter($dispatchSync)));
$this->setExpectations(DispatcherDispatchNowExpectation::class, array_values(array_filter($dispatchNow)));
$this->setExpectations(
DispatcherHasCommandHandlerExpectation::class,
array_values(array_filter($hasCommandHandler))
);
$this->setExpectations(
DispatcherGetCommandHandlerExpectation::class,
array_values(array_filter($getCommandHandler))
);
$this->setExpectations(DispatcherPipeThroughExpectation::class, array_values(array_filter($pipeThrough)));
$this->setExpectations(DispatcherMapExpectation::class, array_values(array_filter($map)));
parent::__construct();
$this->setExpectations(DispatcherDispatchExpectation::class, $dispatch);
$this->setExpectations(DispatcherDispatchSyncExpectation::class, $dispatchSync);
$this->setExpectations(DispatcherDispatchNowExpectation::class, $dispatchNow);
$this->setExpectations(DispatcherHasCommandHandlerExpectation::class, $hasCommandHandler);
$this->setExpectations(DispatcherGetCommandHandlerExpectation::class, $getCommandHandler);
$this->setExpectations(DispatcherPipeThroughExpectation::class, $pipeThrough);
$this->setExpectations(DispatcherMapExpectation::class, $map);
}

/**
Expand Down
42 changes: 20 additions & 22 deletions src/Testing/Laravel/Contracts/Cache/RepositoryAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,26 @@ public function __construct(
array $deleteMultiple = [],
array $has = [],
) {
$this->setExpectations(RepositoryPullExpectation::class, array_values(array_filter($pull)));
$this->setExpectations(RepositoryPutExpectation::class, array_values(array_filter($put)));
$this->setExpectations(RepositoryAddExpectation::class, array_values(array_filter($add)));
$this->setExpectations(RepositoryIncrementExpectation::class, array_values(array_filter($increment)));
$this->setExpectations(RepositoryDecrementExpectation::class, array_values(array_filter($decrement)));
$this->setExpectations(RepositoryForeverExpectation::class, array_values(array_filter($forever)));
$this->setExpectations(RepositoryRememberExpectation::class, array_values(array_filter($remember)));
$this->setExpectations(RepositorySearExpectation::class, array_values(array_filter($sear)));
$this->setExpectations(
RepositoryRememberForeverExpectation::class,
array_values(array_filter($rememberForever))
);
$this->setExpectations(RepositoryForgetExpectation::class, array_values(array_filter($forget)));
$this->setExpectations(RepositoryGetStoreExpectation::class, array_values(array_filter($getStore)));
$this->setExpectations(RepositoryGetExpectation::class, array_values(array_filter($get)));
$this->setExpectations(RepositorySetExpectation::class, array_values(array_filter($set)));
$this->setExpectations(RepositoryDeleteExpectation::class, array_values(array_filter($delete)));
$this->setExpectations(RepositoryClearExpectation::class, array_values(array_filter($clear)));
$this->setExpectations(RepositoryGetMultipleExpectation::class, array_values(array_filter($getMultiple)));
$this->setExpectations(RepositorySetMultipleExpectation::class, array_values(array_filter($setMultiple)));
$this->setExpectations(RepositoryDeleteMultipleExpectation::class, array_values(array_filter($deleteMultiple)));
$this->setExpectations(RepositoryHasExpectation::class, array_values(array_filter($has)));
parent::__construct();
$this->setExpectations(RepositoryPullExpectation::class, $pull);
$this->setExpectations(RepositoryPutExpectation::class, $put);
$this->setExpectations(RepositoryAddExpectation::class, $add);
$this->setExpectations(RepositoryIncrementExpectation::class, $increment);
$this->setExpectations(RepositoryDecrementExpectation::class, $decrement);
$this->setExpectations(RepositoryForeverExpectation::class, $forever);
$this->setExpectations(RepositoryRememberExpectation::class, $remember);
$this->setExpectations(RepositorySearExpectation::class, $sear);
$this->setExpectations(RepositoryRememberForeverExpectation::class, $rememberForever);
$this->setExpectations(RepositoryForgetExpectation::class, $forget);
$this->setExpectations(RepositoryGetStoreExpectation::class, $getStore);
$this->setExpectations(RepositoryGetExpectation::class, $get);
$this->setExpectations(RepositorySetExpectation::class, $set);
$this->setExpectations(RepositoryDeleteExpectation::class, $delete);
$this->setExpectations(RepositoryClearExpectation::class, $clear);
$this->setExpectations(RepositoryGetMultipleExpectation::class, $getMultiple);
$this->setExpectations(RepositorySetMultipleExpectation::class, $setMultiple);
$this->setExpectations(RepositoryDeleteMultipleExpectation::class, $deleteMultiple);
$this->setExpectations(RepositoryHasExpectation::class, $has);
}

/**
Expand Down
23 changes: 9 additions & 14 deletions src/Testing/Laravel/Contracts/Debug/ExceptionHandlerAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,22 @@
class ExceptionHandlerAssert extends AbstractExpectationCallsMap implements ExceptionHandler
{
/**
* @param array<ExceptionHandlerReportExpectation> $report
* @param array<ExceptionHandlerShouldReportExpectation> $shouldReport
* @param array<ExceptionHandlerRenderExpectation> $render
* @param array<ExceptionHandlerRenderForConsoleExpectation> $renderForConsole
* @param array<ExceptionHandlerReportExpectation|null> $report
* @param array<ExceptionHandlerShouldReportExpectation|null> $shouldReport
* @param array<ExceptionHandlerRenderExpectation|null> $render
* @param array<ExceptionHandlerRenderForConsoleExpectation|null> $renderForConsole
*/
public function __construct(
array $report = [],
array $shouldReport = [],
array $render = [],
array $renderForConsole = []
) {
$this->setExpectations(ExceptionHandlerReportExpectation::class, array_values(array_filter($report)));
$this->setExpectations(
ExceptionHandlerShouldReportExpectation::class,
array_values(array_filter($shouldReport))
);
$this->setExpectations(ExceptionHandlerRenderExpectation::class, array_values(array_filter($render)));
$this->setExpectations(
ExceptionHandlerRenderForConsoleExpectation::class,
array_values(array_filter($renderForConsole))
);
parent::__construct();
$this->setExpectations(ExceptionHandlerReportExpectation::class, $report);
$this->setExpectations(ExceptionHandlerShouldReportExpectation::class, $shouldReport);
$this->setExpectations(ExceptionHandlerRenderExpectation::class, $render);
$this->setExpectations(ExceptionHandlerRenderForConsoleExpectation::class, $renderForConsole);
}

/**
Expand Down
37 changes: 19 additions & 18 deletions src/Testing/Laravel/Contracts/Events/DispatcherAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
class DispatcherAssert extends AbstractExpectationCallsMap implements Dispatcher
{
/**
* @param array<DispatcherListenExpectation> $listen
* @param array<DispatcherHasListenersExpectation> $hasListeners
* @param array<DispatcherSubscribeExpectation> $subscribe
* @param array<DispatcherUntilExpectation> $until
* @param array<DispatcherDispatchExpectation> $dispatch
* @param array<DispatcherPushExpectation> $push
* @param array<DispatcherFlushExpectation> $flush
* @param array<DispatcherForgetExpectation> $forget
* @param array<DispatcherForgetPushedExpectation> $forgetPushed
* @param array<DispatcherListenExpectation|null> $listen
* @param array<DispatcherHasListenersExpectation|null> $hasListeners
* @param array<DispatcherSubscribeExpectation|null> $subscribe
* @param array<DispatcherUntilExpectation|null> $until
* @param array<DispatcherDispatchExpectation|null> $dispatch
* @param array<DispatcherPushExpectation|null> $push
* @param array<DispatcherFlushExpectation|null> $flush
* @param array<DispatcherForgetExpectation|null> $forget
* @param array<DispatcherForgetPushedExpectation|null> $forgetPushed
*/
public function __construct(
array $listen = [],
Expand All @@ -33,15 +33,16 @@ public function __construct(
array $forget = [],
array $forgetPushed = [],
) {
$this->setExpectations(DispatcherListenExpectation::class, array_values(array_filter($listen)));
$this->setExpectations(DispatcherHasListenersExpectation::class, array_values(array_filter($hasListeners)));
$this->setExpectations(DispatcherSubscribeExpectation::class, array_values(array_filter($subscribe)));
$this->setExpectations(DispatcherUntilExpectation::class, array_values(array_filter($until)));
$this->setExpectations(DispatcherDispatchExpectation::class, array_values(array_filter($dispatch)));
$this->setExpectations(DispatcherPushExpectation::class, array_values(array_filter($push)));
$this->setExpectations(DispatcherFlushExpectation::class, array_values(array_filter($flush)));
$this->setExpectations(DispatcherForgetExpectation::class, array_values(array_filter($forget)));
$this->setExpectations(DispatcherForgetPushedExpectation::class, array_values(array_filter($forgetPushed)));
parent::__construct();
$this->setExpectations(DispatcherListenExpectation::class, $listen);
$this->setExpectations(DispatcherHasListenersExpectation::class, $hasListeners);
$this->setExpectations(DispatcherSubscribeExpectation::class, $subscribe);
$this->setExpectations(DispatcherUntilExpectation::class, $until);
$this->setExpectations(DispatcherDispatchExpectation::class, $dispatch);
$this->setExpectations(DispatcherPushExpectation::class, $push);
$this->setExpectations(DispatcherFlushExpectation::class, $flush);
$this->setExpectations(DispatcherForgetExpectation::class, $forget);
$this->setExpectations(DispatcherForgetPushedExpectation::class, $forgetPushed);
}

/**
Expand Down
Loading

0 comments on commit c30fc9c

Please sign in to comment.