annotate vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@18 1 <?php
Chris@18 2 $localFile = __DIR__ . '/../../PEAR/Exception.php';
Chris@18 3 if (file_exists($localFile)) {
Chris@18 4 require_once $localFile;
Chris@18 5 } else {
Chris@18 6 require_once 'PEAR/Exception.php';
Chris@18 7 }
Chris@18 8
Chris@18 9 class PEAR_ExceptionTest extends PHPUnit_Framework_TestCase
Chris@18 10 {
Chris@18 11 /**
Chris@18 12 * @expectedException PEAR_Exception
Chris@18 13 * @expectedExceptionMessage foo
Chris@18 14 */
Chris@18 15 public function testThrow()
Chris@18 16 {
Chris@18 17 throw new PEAR_Exception('foo');
Chris@18 18 }
Chris@18 19
Chris@18 20 public function testGetCauseNone()
Chris@18 21 {
Chris@18 22 $e = new PEAR_Exception('foo bar');
Chris@18 23 $this->assertNull($e->getCause());
Chris@18 24 }
Chris@18 25
Chris@18 26 public function testGetCauseException()
Chris@18 27 {
Chris@18 28 $cause = new Exception('foo bar');
Chris@18 29 $e = new PEAR_Exception('I caught an exception', $cause);
Chris@18 30 $this->assertNotNull($e->getCause());
Chris@18 31 $this->assertInstanceOf('Exception', $e->getCause());
Chris@18 32 $this->assertEquals($cause, $e->getCause());
Chris@18 33 }
Chris@18 34
Chris@18 35 public function testGetCauseMessage()
Chris@18 36 {
Chris@18 37 $cause = new Exception('foo bar');
Chris@18 38 $e = new PEAR_Exception('I caught an exception', $cause);
Chris@18 39
Chris@18 40 $e->getCauseMessage($causes);
Chris@18 41 $this->assertEquals('I caught an exception', $causes[0]['message']);
Chris@18 42 $this->assertEquals('foo bar', $causes[1]['message']);
Chris@18 43 }
Chris@18 44
Chris@18 45 public function testGetTraceSafe()
Chris@18 46 {
Chris@18 47 $e = new PEAR_Exception('oops');
Chris@18 48 $this->assertInternalType('array', $e->getTraceSafe());
Chris@18 49 }
Chris@18 50
Chris@18 51 public function testGetErrorClass()
Chris@18 52 {
Chris@18 53 $e = new PEAR_Exception('oops');
Chris@18 54 $this->assertEquals('PEAR_ExceptionTest', $e->getErrorClass());
Chris@18 55 }
Chris@18 56
Chris@18 57 public function testGetErrorMethod()
Chris@18 58 {
Chris@18 59 $e = new PEAR_Exception('oops');
Chris@18 60 $this->assertEquals('testGetErrorMethod', $e->getErrorMethod());
Chris@18 61 }
Chris@18 62
Chris@18 63 public function test__toString()
Chris@18 64 {
Chris@18 65 $e = new PEAR_Exception('oops');
Chris@18 66 $this->assertInternalType('string', (string) $e);
Chris@18 67 $this->assertContains('oops', (string) $e);
Chris@18 68 }
Chris@18 69
Chris@18 70 public function testToHtml()
Chris@18 71 {
Chris@18 72 $e = new PEAR_Exception('oops');
Chris@18 73 $html = $e->toHtml();
Chris@18 74 $this->assertInternalType('string', $html);
Chris@18 75 $this->assertContains('oops', $html);
Chris@18 76 }
Chris@18 77 }
Chris@18 78 ?>