Inheritance: extends mageekguy\atoum\script\configurable
Esempio n. 1
0
 /**
  * {@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());
 }
    /**
     * @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());
    }
Esempio n. 3
0
 /**
  * @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 '';
 }
Esempio n. 4
0
 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'));
 }
Esempio n. 5
0
 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();
 }
Esempio n. 6
0
 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();
 }
Esempio n. 7
0
 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;
 }
<?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);
    });
}
Esempio n. 9
0
 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();
 }
Esempio n. 10
0
 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\\'));
 }
Esempio n. 11
0
 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();
 }
Esempio n. 12
0
<?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'));
}
Esempio n. 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));
    });
}