BaseValidateTestCase.php 532 B

1234567891011121314151617181920212223242526272829
  1. <?php declare(strict_types=1);
  2. namespace Inhere\ValidateTest;
  3. use PHPUnit\Framework\TestCase;
  4. use RuntimeException;
  5. use Throwable;
  6. /**
  7. * class BaseValidateTestCase
  8. */
  9. abstract class BaseValidateTestCase extends TestCase
  10. {
  11. /**
  12. * @param callable $cb
  13. *
  14. * @return Throwable
  15. */
  16. protected function runAndGetException(callable $cb): Throwable
  17. {
  18. try {
  19. $cb();
  20. } catch (Throwable $e) {
  21. return $e;
  22. }
  23. return new RuntimeException('NO ERROR');
  24. }
  25. }