Example #1
0
File: test.php Project: atoum/atoum
 public function testErrorHandler()
 {
     $this->if($test = new emptyTest())->and($adapter = new atoum\test\adapter())->and($adapter->error_reporting = 0)->and($test->setAdapter($adapter))->then->boolean($test->errorHandler(rand(1, PHP_INT_MAX), uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($test->getScore()->getErrors())->isEmpty()->if($adapter->error_reporting = E_ALL)->then->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNotNull()->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isFalse()->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNotNull()->if($adapter->error_reporting = E_ALL & ~E_DEPRECATED)->then->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNull()->if($adapter->error_reporting = E_ALL & ~E_RECOVERABLE_ERROR)->then->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNull()->if($adapter->error_reporting = 32767)->and($factory = function ($class) use(&$reflection, &$filename, &$classname) {
         $reflection = new \mock\ReflectionClass($class);
         $reflection->getMockController()->getFilename = $filename = 'filename';
         $reflection->getMockController()->getName = $classname = 'classname';
         return $reflection;
     })->and($score = new \mock\mageekguy\atoum\test\score())->and($test = new emptyTest(null, null, null, null, $factory))->and($test->setAdapter($adapter))->and($test->setScore($score))->then->boolean($test->errorHandler($errno = E_NOTICE, $errstr = 'errstr', $errfile = 'errfile', $errline = rand(1, PHP_INT_MAX)))->isTrue()->mock($score)->call('addError')->withArguments($errfile, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, $errfile, $errline, null, null, null)->once()->boolean($test->errorHandler($errno, $errstr, null, $errline = rand(1, PHP_INT_MAX)))->isTrue()->mock($score)->call('addError')->withArguments($filename, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, null, $errline, null, null, null)->once();
 }