Skip to content

Commit

Permalink
Remove assertPushedWithParamsOn
Browse files Browse the repository at this point in the history
* the queue can be asserted using the second argument of assertPushedWith
  • Loading branch information
patrickomeara committed Aug 20, 2024
1 parent 51fe347 commit e1a20c4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 49 deletions.
5 changes: 0 additions & 5 deletions src/Concerns/AsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ public static function assertPushedWith(Closure|array $callback, ?string $queue
);
}

public static function assertPushedWithParamsOn(string $queue, Closure|array $callback): void
{
static::assertPushedWith($callback, $queue);
}

public static function assertNotPushedWith(Closure|array $callback): void
{
if (is_array($callback)) {
Expand Down
44 changes: 0 additions & 44 deletions tests/AsJobWithAssertionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,50 +164,6 @@ public function handle(User $user): void
AsJobWithAssertionsTest::assertPushedWith([$userB]);
})->with('custom job decorators');

it('asserts an action has been pushed with params on a given queue - success', function () {
loadMigrations();
$user = createUser();

// When we dispatch the action with some parameters on "some-queue".
AsJobWithAssertionsTest::setQueue('some-queue');
AsJobWithAssertionsTest::dispatch($user);

// Then we can assert it has been dispatched with these parameters on that queue.
AsJobWithAssertionsTest::assertPushedWithParamsOn('some-queue', $user->is(...));
AsJobWithAssertionsTest::assertPushedWithParamsOn('some-queue', [$user]);
})->with('custom job decorators');

it('asserts an action has been pushed with params on a given queue - failure (wrong params)', function () {
loadMigrations();
$userA = createUser();
$userB = createUser();

// When we dispatch the action with some parameters on "some-queue".
AsJobWithAssertionsTest::setQueue('some-queue');
AsJobWithAssertionsTest::dispatch($userA);

$this->expectException(ExpectationFailedException::class);
$this->expectExceptionMessage('The expected ['.AsJobWithAssertionsTest::class.'] job was not pushed');

// Then we can expect a failure when asserting it has been dispatched with other parameters on that queue.
AsJobWithAssertionsTest::assertPushedWithParamsOn('some-queue', $userB->is(...));
})->with('custom job decorators');

it('asserts an action has been pushed with params on a given queue - failure (wrong queue)', function () {
loadMigrations();
$user = createUser();

// When we dispatch the action with some parameters on "some-queue".
AsJobWithAssertionsTest::setQueue('some-queue');
AsJobWithAssertionsTest::dispatch($user);

$this->expectException(ExpectationFailedException::class);
$this->expectExceptionMessage('The expected ['.AsJobWithAssertionsTest::class.'] job was not pushed');

// Then we can expect a failure when asserting it has been dispatched with these parameters on some other queue.
AsJobWithAssertionsTest::assertPushedWithParamsOn('some-other-queue', $user->is(...));
})->with('custom job decorators');

it('asserts an action has not been pushed with params - success', function () {
loadMigrations();
$userA = createUser();
Expand Down

0 comments on commit e1a20c4

Please sign in to comment.