Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnourValar committed Sep 19, 2024
1 parent 05fac08 commit 70b4729
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Tests/ValidationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,26 @@ protected function assertDeleteValidationFailed(\Illuminate\Database\Eloquent\Mo
}
}
}

/**
* Asserts that custom action gets validation failure
*
* @param callable $closure
* @param mixed $message
* @return void
*/
protected function assertCustomValidationFailed(callable $closure, $message = true): void
{
try {
$closure();
$this->assertFalse(true);
} catch (\Illuminate\Validation\ValidationException $e) {
foreach ($e->validator->errors()->all() as $error) {
$this->assertStringNotContainsString('services/', $error);
if ($message !== true) {
$this->assertEquals($message, $error);
}
}
}
}
}

0 comments on commit 70b4729

Please sign in to comment.