Beispiel #1
0
 public function testGetFirstError()
 {
     $this->if($includer = new testedClass($adapter = new atoum\test\adapter()))->then->variable($includer->getFirstError())->isNull()->if($adapter->set_error_handler = function ($errorHandler) {
         set_error_handler($errorHandler);
         return null;
     })->and($fileWithError = stream::get())->and($fileWithError->file_get_contents = '<?php trigger_error(\'' . ($message = uniqid()) . '\', E_USER_WARNING); ?>')->and($includer->includePath($fileWithError))->then->array($error = $includer->getFirstError())->isNotEmpty()->integer($error[0])->isEqualTo(E_USER_WARNING)->string($error[1])->isEqualTo($message);
 }
Beispiel #2
0
 public function testIncludePath()
 {
     $this->assert->if($includer = new atoum\includer())->and($unknownFile = stream::get())->then->exception(function () use($includer, $unknownFile) {
         $includer->includePath($unknownFile);
     })->isInstanceOf('mageekguy\\atoum\\includer\\exception')->hasMessage('Unable to include \'' . $unknownFile . '\'')->if($file = stream::get())->and($file->file_get_contents = $fileContents = uniqid())->then->object($includer->includePath($file))->isIdenticalTo($includer)->output->isEqualTo($fileContents)->if($fileWithError = stream::get())->and($fileWithError->file_get_contents = '<?php trigger_error(\'' . ($message = uniqid()) . '\', E_USER_WARNING); ?>')->then->object($includer->includePath($fileWithError))->isIdenticalTo($includer)->error->withType(E_USER_WARNING)->withMessage($message)->exists();
 }