Ejemplo n.º 1
0
 /**
  * Run the helper.
  *
  * @param  string  $filename    Configuration filename.
  * @param  array   $content     Configuration content (as an array, not as
  *                              JSON).
  * @return string
  */
 function __invoke($filename, array $content = null)
 {
     $file = (string) file::get($filename);
     if (null !== $content) {
         file_put_contents($file, json_encode($content, JSON_PRETTY_PRINT));
     }
     return $file;
 }
Ejemplo n.º 2
0
 /**
  * Queue of the component.
  *
  * @param   string  $queue    Queue of the component (generally, a filename,
  *                            with probably a query).
  * @return  mixed
  */
 public function reach($queue = null)
 {
     if (null === $queue) {
         return null;
     }
     $components = parse_url($queue);
     $path =& $components['path'];
     if (isset($components['query'])) {
         parse_str($components['query'], $queries);
     } else {
         $queries = ['type' => 'file'];
     }
     if (isset($queries['type']) && 'directory' === $queries['type']) {
         $file = atoum\mock\streams\fs\directory::get($path);
         $file->dir_opendir = true;
     } else {
         $file = atoum\mock\streams\fs\file::get($path);
     }
     $parentDirectory = dirname($path);
     if (isset($this->_streams[$parentDirectory])) {
         $this->_streams[$parentDirectory]->dir_readdir[] = $file;
     }
     foreach ($queries as $query => $value) {
         switch ($query) {
             case 'atime':
             case 'ctime':
             case 'mtime':
                 $file->getStat()[$query] = intval($value);
                 break;
             case 'permissions':
                 $value = sprintf('%04d', $value);
                 $file->setPermissions($value);
                 break;
         }
     }
     $this->_streams[$path] = $file;
     return (string) $file;
 }
Ejemplo n.º 3
0
namespace {
    class Task
    {
    }
    class FileSet
    {
    }
    class BuildException extends Exception
    {
    }
}
namespace tests\units {
    use atoum, AtoumTask as testedClass;
    require_once __DIR__ . '/../../runner.php';
    define('mageekguy\\atoum\\phing\\task\\path', atoum\mock\streams\fs\file::get());
    require_once __DIR__ . '/../../../../resources/phing/AtoumTask.php';
    class AtoumTask extends atoum
    {
        public function test__construct()
        {
            $this->given($task = new testedClass())->then->object($task->getRunner())->isInstanceOf('mageekguy\\atoum\\runner')->variable($task->getBootstrap())->isNull()->boolean($task->getCodeCoverage())->isFalse()->variable($task->getAtoumPharPath())->isNull()->variable($task->getPhpPath())->isNull()->boolean($task->getShowCodeCoverage())->isTrue()->boolean($task->getShowDuration())->isTrue()->boolean($task->getShowMemory())->isTrue()->boolean($task->getShowMissingCodeCoverage())->isTrue()->boolean($task->getShowProgress())->isTrue()->variable($task->getAtoumAutoloaderPath())->isNull()->variable($task->getCodeCoverageReportPath())->isNull()->variable($task->getCodeCoverageReportUrl())->isNull()->variable($task->getCodeCoverageXunitPath())->isNull()->variable($task->getCodeCoverageCloverPath())->isNull()->integer($task->getMaxChildren())->isZero()->if($task = new testedClass($runner = new atoum\runner()))->then->object($task->getRunner())->isIdenticalTo($runner)->variable($task->getBootstrap())->isNull()->boolean($task->getCodeCoverage())->isFalse()->variable($task->getAtoumPharPath())->isNull()->variable($task->getPhpPath())->isNull()->boolean($task->getShowCodeCoverage())->isTrue()->boolean($task->getShowDuration())->isTrue()->boolean($task->getShowMemory())->isTrue()->boolean($task->getShowMissingCodeCoverage())->isTrue()->boolean($task->getShowProgress())->isTrue()->variable($task->getAtoumAutoloaderPath())->isNull()->variable($task->getCodeCoverageReportPath())->isNull()->variable($task->getCodeCoverageReportUrl())->isNull()->variable($task->getCodeCoverageXunitPath())->isNull()->variable($task->getCodeCoverageCloverPath())->isNull()->integer($task->getMaxChildren())->isZero();
        }
        public function testGetSetRunner()
        {
            $this->given($task = new testedClass())->then->object($task->setRunner($runner = new atoum\runner()))->isIdenticalTo($task)->object($task->getRunner())->isIdenticalTo($runner)->object($task->setRunner())->isIdenticalTo($task)->object($task->getRunner())->isInstanceOf('mageekguy\\atoum\\runner')->isNotIdenticalTo($runner);
        }
        public function testCodeCoverageEnabled()
        {
            $this->given($task = new testedClass())->then->boolean($task->codeCoverageEnabled())->isFalse()->if($task->setCodeCoverageReportPath(uniqid()))->then->boolean($task->codeCoverageEnabled())->isTrue()->if($task = new testedClass())->and($task->setCodeCoverageTreemapPath(uniqid()))->then->boolean($task->codeCoverageEnabled())->isTrue()->if($task = new testedClass())->and($task->setCodeCoverage(true))->then->boolean($task->codeCoverageEnabled())->isTrue();
        }