Ejemplo n.º 1
0
 /**
  *    Invokes a test method whilst trapping expected
  *    exceptions. Any left over unthrown exceptions
  *    are then reported as failures.
  *    @param string $method    Test method to call.
  */
 function invoke($method)
 {
     $trap = SimpleTest::getContext()->get('SimpleExceptionTrap');
     $trap->clear();
     try {
         $has_thrown = false;
         parent::invoke($method);
     } catch (Exception $exception) {
         $has_thrown = true;
         if (!$trap->isExpected($this->getTestCase(), $exception)) {
             $this->getTestCase()->exception($exception);
         }
         $trap->clear();
     }
     if ($message = $trap->getOutstanding()) {
         $this->getTestCase()->fail($message);
     }
     if ($has_thrown) {
         try {
             parent::getTestCase()->tearDown();
         } catch (Exception $e) {
         }
     }
 }