Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daVitekPL committed Jul 24, 2024
1 parent 02bdefe commit 5ebf8f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Core/SmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function sections(): Collection
*/
private static function sendMessage(User $user, array $sections): bool
{
// @phpstan-ignore-next-line
if (!$user->phone) {
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Testing/SmsFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ public function dispatch(): void
$this->sms[] = new Sms($this->recipient, $this->body, [], []);
}

public function assertSent(Closure $callback): void
public function assertSent(Closure|string $callback): void
{
PHPUnit::assertTrue(
$this->sent($callback)->count() > 0,
);
}

public function assertSentTimes(Closure $callback, int $times = 1): void
public function assertSentTimes(Closure|string $callback, int $times = 1): void
{
PHPUnit::assertCount(
$times, $this->sent($callback)
);
}

public function assertNotSent(Closure $callback): void
public function assertNotSent(Closure|string $callback): void
{
PHPUnit::assertCount(
0, $this->sent($callback)
Expand All @@ -63,13 +63,13 @@ public function assertNotSent(Closure $callback): void
/**
* @return Collection<int, Sms>
*/
private function sent(Closure $callback = null): Collection
private function sent(Closure|string $callback = null): Collection
{
$callback = $this->prepare($callback);
return (new Collection($this->sms))->filter($callback);
}

private function prepare(Closure $callback = null): Closure
private function prepare(Closure|string $callback = null): Closure
{
if ($callback instanceof Closure) {
$callback = function (Sms $sms) use ($callback) {
Expand Down

0 comments on commit 5ebf8f0

Please sign in to comment.