Example #1
0
 /**
  * test handleFatalError generating log.
  *
  * @return void
  */
 public function testHandleFatalErrorLog()
 {
     $this->_logger->expects($this->at(0))->method('log')->with('error', $this->logicalAnd($this->stringContains(__FILE__ . ', line ' . (__LINE__ + 9)), $this->stringContains('Fatal Error (1)'), $this->stringContains('Something wrong')));
     $this->_logger->expects($this->at(1))->method('log')->with('error', $this->stringContains('[Cake\\Error\\FatalErrorException] Something wrong'));
     $errorHandler = new TestErrorHandler(['log' => true]);
     $errorHandler->handleFatalError(E_ERROR, 'Something wrong', __FILE__, __LINE__);
 }
 /**
  * Tests Handling a PHP7 error
  *
  * @return void
  */
 public function testHandlePHP7Error()
 {
     $this->skipIf(!class_exists('Error'), 'Requires PHP7');
     $error = new PHP7ErrorException(new ParseError('Unexpected variable foo'));
     $errorHandler = new TestErrorHandler();
     $errorHandler->handleException($error);
     $this->assertContains('Unexpected variable foo', $errorHandler->response->body(), 'message missing.');
 }
 /**
  * Test increasing the memory limit.
  *
  * @dataProvider memoryLimitProvider
  * @return void
  */
 public function testIncreaseMemoryLimit($start, $adjust, $expected)
 {
     $initial = ini_get('memory_limit');
     $this->skipIf(strlen($initial) === 0, 'Cannot read memory limit, and cannot test increasing it.');
     // phpunit.xml often has -1 as memory limit
     ini_set('memory_limit', $start);
     $errorHandler = new TestErrorHandler();
     $this->assertNull($errorHandler->increaseMemoryLimit($adjust));
     $new = ini_get('memory_limit');
     $this->assertEquals($expected, $new, 'memory limit did not get increased.');
     ini_set('memory_limit', $initial);
 }