BreakExceptionTest.php 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2023 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Psy\Test\Exception;
  11. use Psy\Exception\BreakException;
  12. use Psy\Exception\Exception;
  13. class BreakExceptionTest extends \Psy\Test\TestCase
  14. {
  15. public function testInstance()
  16. {
  17. $e = new BreakException();
  18. $this->assertInstanceOf(Exception::class, $e);
  19. $this->assertInstanceOf(BreakException::class, $e);
  20. }
  21. public function testMessage()
  22. {
  23. $e = new BreakException('foo');
  24. $this->assertStringContainsString('foo', $e->getMessage());
  25. $this->assertSame('foo', $e->getRawMessage());
  26. }
  27. public function testExitShell()
  28. {
  29. $this->expectException(\Psy\Exception\BreakException::class);
  30. $this->expectExceptionMessage('Goodbye');
  31. BreakException::exitShell();
  32. $this->fail();
  33. }
  34. }