ExceptionTest.php 1.0 KB

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. namespace Luolongfei\Tests\App;
  4. use Luolongfei\App\Exceptions\LlfException;
  5. use Luolongfei\App\Exceptions\WarningException;
  6. use Luolongfei\Tests\TestCase;
  7. final class ExceptionTest extends TestCase
  8. {
  9. public function testLlfExceptionFormatsMessageAndCode(): void
  10. {
  11. $exception = new LlfException(34520006, ['8.1', '7.1']);
  12. $this->assertStringContainsString('8.1', $exception->getMessage());
  13. $this->assertStringContainsString('7.1', $exception->getMessage());
  14. $this->assertStringContainsString('(Error code: 34520006)', $exception->getMessage());
  15. }
  16. public function testWarningExceptionFormatsMessageAndCode(): void
  17. {
  18. $exception = new WarningException(34520014, ['[email protected]', 'No domains']);
  19. $this->assertStringContainsString('[email protected]', $exception->getMessage());
  20. $this->assertStringContainsString('No domains', $exception->getMessage());
  21. $this->assertStringContainsString('(Warning code: 34520014)', $exception->getMessage());
  22. }
  23. }