Exemplo n.º 1
0
<?php

use mageekguy\atoum, mageekguy\atoum\scripts;
require_once __DIR__ . '/../classes/autoloader.php';
$builder = new scripts\builder(__FILE__);
set_error_handler(function ($error, $message, $file, $line) use($builder) {
    if (error_reporting() !== 0) {
        $builder->writeError($message);
        exit($error);
    }
});
try {
    $builder->run();
} catch (\exception $exception) {
    $builder->writeError($exception->getMessage());
    exit($exception->getCode());
}
exit(0);
Exemplo n.º 2
0
 public function testWriteInErrorDirectory()
 {
     $this->if($adapter = new atoum\test\adapter())->and($adapter->file_put_contents = function () {
     })->and($builder = new testedClass(uniqid(), $adapter))->then->variable($builder->getErrorsDirectory())->isNull()->object($builder->writeErrorInErrorsDirectory(uniqid()))->isIdenticalTo($builder)->adapter($adapter)->call('file_put_contents')->never()->if($builder->setErrorsDirectory($errorDirectory = uniqid()))->then->string($builder->getErrorsDirectory())->isEqualTo($errorDirectory)->exception(function () use($builder) {
         $builder->writeErrorInErrorsDirectory(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic')->hasMessage('Revision is undefined')->adapter($adapter)->call('file_put_contents')->never()->if->mockGenerator->shunt('__construct')->and($builder->setVcs($vcs = new \mock\mageekguy\atoum\scripts\builder\vcs()))->and($vcs->setRevision($revision = rand(1, PHP_INT_MAX)))->then->string($builder->getErrorsDirectory())->isEqualTo($errorDirectory)->object($builder->writeErrorInErrorsDirectory($message = uniqid()))->isIdenticalTo($builder)->adapter($adapter)->call('file_put_contents')->withArguments($errorDirectory . \DIRECTORY_SEPARATOR . $revision, $message, \LOCK_EX | \FILE_APPEND)->once()->if($adapter->resetCalls())->and($adapter->file_put_contents = false)->then->string($builder->getErrorsDirectory())->isEqualTo($errorDirectory)->exception(function () use($builder, &$message) {
         $builder->writeErrorInErrorsDirectory($message = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Unable to save error in file \'' . $errorDirectory . \DIRECTORY_SEPARATOR . $revision . '\'')->adapter($adapter)->call('file_put_contents')->withArguments($errorDirectory . \DIRECTORY_SEPARATOR . $revision, $message, \LOCK_EX | \FILE_APPEND)->once();
 }
Exemplo n.º 3
0
<?php

use mageekguy\atoum, mageekguy\atoum\scripts;
require_once __DIR__ . '/../classes/autoloader.php';
$builder = new scripts\builder(__FILE__);
set_error_handler(function ($error, $message, $file, $line) use($builder) {
    if (error_reporting() !== 0) {
        $builder->writeError(sprintf($builder->getLocale()->_('Error: %s'), $message));
        exit($error);
    }
});
try {
    $builder->run();
} catch (\exception $exception) {
    $builder->writeError(sprintf($builder->getLocale()->_('Exception: %s'), $exception->getMessage()));
    exit($exception->getCode());
}
exit(0);