Exemplo n.º 1
0
 /**
  * When you have codes that indicate they are to be disabled and
  * there are no coded given from which to disable them from the
  * setLevel will use the current reporting level instead
  *
  * @return null
  */
 public function testSetGetLevelNoEnableWithDisable()
 {
     /* set current reporting level */
     error_reporting(E_ALL | E_STRICT);
     $codes = '-error, -warning, -parse';
     $this->assertNull($this->error->setLevel($codes));
     $level = (E_ALL | E_STRICT) & ~(E_ERROR | E_WARNING | E_PARSE);
     $this->assertEquals($level, error_reporting());
     $result = $this->error->getLevel();
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('enabled', $result);
     $this->assertArrayHasKey('disabled', $result);
     $this->assertInternalType('array', $result['enabled']);
     $this->assertInternalType('array', $result['disabled']);
     $this->assertEquals(3, count($result['disabled']));
     $this->assertEquals(12, count($result['enabled']));
     $this->assertContains('error', $result['disabled']);
     $this->assertContains('warning', $result['disabled']);
     $this->assertContains('parse', $result['disabled']);
     $expected = array('notice', 'core_error', 'core_warning', 'compile_error', 'compile_warning', 'user_error', 'user_warning', 'user_notice', 'strict', 'recoverable_error', 'deprecated', 'user_deprecated');
     $this->assertEquals(count($expected), count($result['enabled']));
     foreach ($expected as $code) {
         $this->assertContains($code, $result['enabled']);
     }
 }
Exemplo n.º 2
0
 /**
  * Initializing the fault handler will set the error_reporting level 
  * enable or disable displaying errors and register error and exception
  * handlers
  *
  * @return	KernelInitializer
  */
 public function initFaultHandling()
 {
     $isErrorDisabled = KernelRegistry::getParam('disable-af-errors', false);
     $isFaultDisabled = KernelRegistry::getParam('disable-af-fault-handler', false);
     $isErrorDisabled = $isErrorDisabled === true ? true : false;
     $report = '';
     if (false === $isErrorDisabled) {
         $display = KernelRegistry::getParam('display-errors', 'off');
         if (null !== $display) {
             $errorDisplay = new Error\ErrorDisplay();
             $errorDisplay->set($display);
             $report .= 'display error ';
         }
         $level = KernelRegistry::getParam('error-level', 'all,strict');
         if (null !== $level) {
             $errorReporting = new Error\ErrorLevel();
             $errorReporting->setLevel($level);
             $report .= 'error reporting ';
         }
     }
     $isFaultDisabled = $isFaultDisabled === true ? true : false;
     if (false === $isFaultDisabled) {
         $handler = new FaultHandler();
         set_error_handler(array($handler, 'handleError'));
         set_exception_handler(array($handler, 'handleException'));
         $report .= 'fault handling';
     }
     self::$status['kernel:app-dependency'] = "initialized: {$report}";
     return $this;
 }