Inheritance: extends mageekguy\atoum\script\configurable
コード例 #1
0
ファイル: AtoumCommand.php プロジェクト: SelviA/AtoumBundle
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new runner('atoum');
     $bundles = $input->getArgument('bundles');
     if (count($bundles) > 0) {
         foreach ($bundles as $k => $bundleName) {
             $bundles[$k] = $this->extractBundleConfigurationFromKernel($bundleName);
         }
     } else {
         $bundles = $this->getContainer()->get('atoum.configuration.bundle.container')->all();
     }
     foreach ($bundles as $bundle) {
         $directories = array_filter($bundle->getDirectories(), function ($dir) {
             return is_dir($dir);
         });
         if (empty($directories)) {
             $output->writeln(sprintf('<error>There is no test found on "%s".</error>', $bundle->getName()));
         }
         foreach ($directories as $directory) {
             $runner->getRunner()->addTestsFromDirectory($directory);
         }
     }
     $defaultBootstrap = sprintf('%s/autoload.php', $this->getApplication()->getKernel()->getRootDir());
     $bootstrap = $input->getOption('bootstrap-file') ?: $defaultBootstrap;
     $this->setAtoumArgument('--bootstrap-file', $bootstrap);
     if ($input->getOption('no-code-coverage')) {
         $this->setAtoumArgument('-ncc');
     }
     if ($input->getOption('max-children-number')) {
         $this->setAtoumArgument('--max-children-number', (int) $input->getOption('max-children-number'));
     }
     $runner->run($this->getAtoumArguments());
 }
コード例 #2
0
    /**
     * @return void
     */
    protected function configure()
    {
        if (null === ($atoumPath = \sfConfig::get('sf_atoum_path'))) {
            $atoumPath = dirname(__FILE__) . '/../../../../lib/vendor/atoum/';
        }
        require_once $atoumPath . '/classes/autoloader.php';
        $this->namespace = 'atoum';
        $this->name = 'test';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
EOF;
        $runner = new scripts\runner(__FILE__);
        $builder = new \sfAtoumPlugin\arguments\builder($runner->getHelp());
        $builder->setDefaultTypes($this->getDefaultTypes())->setDefaultOptions($this->getDefaultArguments());
        $this->addOptions($builder->getSfOptions());
    }
コード例 #3
0
ファイル: watcher.php プロジェクト: atoum/autoloop-extension
 /**
  * @return string
  */
 public function runAgain()
 {
     /** @var \mageekguy\atoum\writers\std\out $outputWriter */
     $outputWriter = $this->runner->getOutputWriter();
     $watcher = new ResourceWatcher();
     $onEvent = function (FilesystemEvent $event) use($watcher, $outputWriter) {
         $outputWriter->write((string) $event->getResource() . " has been modified." . PHP_EOL);
         $watcher->stop();
     };
     foreach ($this->configuration->getWatchedFiles() as $watchedFile) {
         $watcher->track($watchedFile, $watchedFile);
         $watcher->addListener($watchedFile, $onEvent);
     }
     foreach ($this->runner->getRunner()->getTestPaths() as $path) {
         $watcher->track($path, $path);
         $watcher->addListener($path, $onEvent);
     }
     $outputWriter->write('Waiting for a file to change to run the test(s)... (Use CTRL+C to stop)' . PHP_EOL);
     $watcher->start();
     return '';
 }
コード例 #4
0
ファイル: coverage.php プロジェクト: xihewang/atoum
 protected function setArgumentHandlers()
 {
     return parent::setArgumentHandlers()->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) === 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setReportFormat(current($values));
     }, array('-fmt', '--format'), '<xml|clover|html|treemap>', $this->locale->_('Coverage report format'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) === 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setReportOutputPath(current($values));
     }, array('-o', '--output'), '<path/to/file/or/directory>', $this->locale->_('Coverage report output path'));
 }
コード例 #5
0
ファイル: AtoumTask.php プロジェクト: xihewang/atoum
 public function main()
 {
     if ($this->codeCoverage && extension_loaded('xdebug') === false) {
         throw new exception('AtoumTask depends on Xdebug being installed to gather code coverage information');
     }
     if ($this->atoumPharPath !== null) {
         require_once $this->atoumPharPath;
     } else {
         if ($this->atoumAutoloaderPath !== null) {
             require_once $this->atoumAutoloaderPath;
         } else {
             if (class_exists('mageekguy\\atoum\\scripts\\runner', false) === false) {
                 throw new exception('Unknown class mageekguy\\atoum\\scripts\\runner, consider setting atoumPharPath parameter');
             }
         }
     }
     atoum\scripts\runner::disableAutorun();
     foreach ($this->getFiles() as $file) {
         include_once $file;
     }
     return $this->execute();
 }
コード例 #6
0
ファイル: extension.php プロジェクト: atoum/reports-extension
 public function test__construct()
 {
     $this->if($script = new atoum\scripts\runner(uniqid()))->and($script->setArgumentsParser($parser = new \mock\mageekguy\atoum\script\arguments\parser()))->and($configurator = new \mock\mageekguy\atoum\configurator($script))->then->object($extension = new testedClass())->if($this->resetMock($parser))->and($extension = new testedClass($configurator))->then->mock($parser)->call('addHandler')->twice();
 }
コード例 #7
0
ファイル: stub.php プロジェクト: GuillaumeDievart/atoum
 protected function setArgumentHandlers()
 {
     return parent::setArgumentHandlers()->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->infos();
     }, array('-i', '--infos'), null, $this->locale->_('Display informations, do not run any script'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->signature();
     }, array('-s', '--signature'), null, $this->locale->_('Display phar signature, do not run any script'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->extractTo($values[0]);
     }, array('-e', '--extract-to'), '<directory>', $this->locale->_('Extract all file from phar to <directory>, do not run any script'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->extractResourcesTo($values[0]);
     }, array('-er', '--extract-resources-to'), '<directory>', $this->locale->_('Extract resources from phar to <directory>, do not run any script'))->addArgumentHandler(function ($script, $argument, $values, $position) {
         if ($position !== 1 || sizeof($values) !== 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         unset($_SERVER['argv'][1]);
         unset($_SERVER['argv'][2]);
         $script->useScript($values[0]);
     }, array('-u', '--use'), '<script> <args>', $this->locale->_('Run script <script> from PHAR with <args> as arguments (this argument must be the first)'), 4)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) > 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->listScripts();
     }, array('-ls', '--list-scripts'), null, $this->locale->_('List available scripts'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) > 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->update();
     }, array('--update'), null, $this->locale->_('Update atoum'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) > 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->listAvailableVersions();
     }, array('-lav', '--list-available-versions'), null, $this->locale->_('List available versions in the PHAR'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->enableVersion($values[0]);
     }, array('-ev', '--enable-version'), '<version>', $this->locale->_('Enable version <version>'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->deleteVersion($values[0]);
     }, array('-dv', '--delete-version'), '<version>', $this->locale->_('Delete version <version>'));
     return $this;
 }
コード例 #8
0
<?php

use mageekguy\atoum;
use mageekguy\atoum\scripts;
if (defined('mageekguy\\atoum\\scripts\\runner') === true && version_compare(constant('mageekguy\\atoum\\version'), '2.9.0-beta', '>=') === true) {
    scripts\runner::addConfigurationCallable(function (atoum\configurator $script, atoum\runner $runner) {
        $extension = new atoum\blackfire\extension($script);
        $extension->addToRunner($runner);
    });
}
コード例 #9
0
ファイル: runner.php プロジェクト: eroluysal/atoum
 public function testAutorun()
 {
     $this->if($script = new testedClass(uniqid()))->and($script->setAdapter($adapter = new atoum\test\adapter()))->and($adapter->realpath = function ($path) {
         return $path;
     })->when(function () {
         if (isset($_SERVER['argv']) === true) {
             unset($_SERVER['argv']);
         }
     })->then->boolean($script->autorun())->isTrue()->if($_SERVER['argv'] = array())->then->boolean($script->autorun())->isTrue()->if($_SERVER['argv'][0] = $script->getName())->then->boolean($script->autorun())->isFalse()->if($adapter->realpath = uniqid())->then->boolean($script->autorun())->isTrue();
 }
コード例 #10
0
ファイル: runner.php プロジェクト: ronan-gloo/atoum
 public function testGetSubDirectoryPath()
 {
     $this->array(scripts\runner::getSubDirectoryPath(''))->isEmpty()->array(scripts\runner::getSubDirectoryPath('', '/'))->isEmpty()->array(scripts\runner::getSubDirectoryPath('', '\\'))->isEmpty()->array(scripts\runner::getSubDirectoryPath('/', '/'))->isEqualTo(array('/'))->array(scripts\runner::getSubDirectoryPath('/foo', '/'))->isEqualTo(array('/', '/foo/'))->array(scripts\runner::getSubDirectoryPath('/foo/', '/'))->isEqualTo(array('/', '/foo/'))->array(scripts\runner::getSubDirectoryPath('/foo/bar', '/'))->isEqualTo(array('/', '/foo/', '/foo/bar/'))->array(scripts\runner::getSubDirectoryPath('/foo/bar/', '/'))->isEqualTo(array('/', '/foo/', '/foo/bar/'))->array(scripts\runner::getSubDirectoryPath('c:\\', '\\'))->isEqualTo(array('c:\\'))->array(scripts\runner::getSubDirectoryPath('c:\\foo', '\\'))->isEqualTo(array('c:\\', 'c:\\foo\\'))->array(scripts\runner::getSubDirectoryPath('c:\\foo\\', '\\'))->isEqualTo(array('c:\\', 'c:\\foo\\'))->array(scripts\runner::getSubDirectoryPath('c:\\foo\\bar', '\\'))->isEqualTo(array('c:\\', 'c:\\foo\\', 'c:\\foo\\bar\\'))->array(scripts\runner::getSubDirectoryPath('c:\\foo\\bar\\', '\\'))->isEqualTo(array('c:\\', 'c:\\foo\\', 'c:\\foo\\bar\\'));
 }
コード例 #11
0
ファイル: extension.php プロジェクト: atoum/bdd-extension
 public function should_construct_and_set_test_command_line_handlers()
 {
     $this->given($script = new atoum\scripts\runner(uniqid()), $parser = new \mock\mageekguy\atoum\script\arguments\parser(), $configurator = new \mock\mageekguy\atoum\configurator($script), $script->setArgumentsParser($parser), $this->resetMock($parser))->if($this->newTestedInstance($configurator))->then->mock($parser)->call('addHandler')->twice()->boolean($parser->argumentHasHandler('--test-it'))->isTrue()->boolean($parser->argumentHasHandler('--test-ext'))->isTrue();
 }
コード例 #12
0
ファイル: runner.php プロジェクト: ronan-gloo/atoum
<?php

namespace mageekguy\atoum;

use mageekguy\atoum\scripts;
require_once __DIR__ . '/../classes/autoloader.php';
if (defined(__NAMESPACE__ . '\\scripts\\runner') === false) {
    define(__NAMESPACE__ . '\\scripts\\runner', __FILE__);
}
if (scripts\runner::autorunMustBeEnabled() === true) {
    scripts\runner::enableAutorun(constant(__NAMESPACE__ . '\\scripts\\runner'));
}
コード例 #13
0
<?php

if (defined('mageekguy\\atoum\\scripts\\runner') === true && version_compare(constant('mageekguy\\atoum\\version'), '2.9.0-beta', '>=') === true) {
    \mageekguy\atoum\scripts\runner::addConfigurationCallable(function ($script, $runner) {
        $runner->addExtension(new \mageekguy\atoum\autoloop\extension($script));
    });
}