1<?php 2class Issue1351Test extends PHPUnit_Framework_TestCase 3{ 4 protected $instance; 5 6 /** 7 * @runInSeparateProcess 8 */ 9 public function testFailurePre() 10 { 11 $this->instance = new ChildProcessClass1351(); 12 $this->assertFalse(true, 'Expected failure.'); 13 } 14 15 public function testFailurePost() 16 { 17 $this->assertNull($this->instance); 18 $this->assertFalse(class_exists('ChildProcessClass1351', false), 'ChildProcessClass1351 is not loaded.'); 19 } 20 21 /** 22 * @runInSeparateProcess 23 */ 24 public function testExceptionPre() 25 { 26 $this->instance = new ChildProcessClass1351(); 27 try { 28 throw new LogicException('Expected exception.'); 29 } catch (LogicException $e) { 30 throw new RuntimeException('Expected rethrown exception.', 0, $e); 31 } 32 } 33 34 public function testExceptionPost() 35 { 36 $this->assertNull($this->instance); 37 $this->assertFalse(class_exists('ChildProcessClass1351', false), 'ChildProcessClass1351 is not loaded.'); 38 } 39 40 public function testPhpCoreLanguageException() 41 { 42 // User-space code cannot instantiate a PDOException with a string code, 43 // so trigger a real one. 44 $connection = new PDO('sqlite::memory:'); 45 $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 46 $connection->query("DELETE FROM php_wtf WHERE exception_code = 'STRING'"); 47 } 48} 49