public function test_merge_default_configurations_if_not_specified() { $config = ['phpunit' => 'phpunit']; $merged = ['phpunit' => 'phpunit', 'ignore' => ['^vendor']]; $this->fs->saveConfigFile(new Config($config)); $this->assertEquals($merged, $this->fs->loadConfig()->getArrayCopy()); }
public static function createRunCommand() { $fs = new FileSystem(getcwd()); $config = $fs->loadConfig(); $cache = $fs->loadCache(); $phpunit = new Phpunit($config['phpunit']); return new RunCommand($phpunit, $cache, $fs); }
public function __construct() { $root = getcwd(); $fs = new FileSystem($root); $cache = $fs->loadCache(); $config = $fs->loadConfig(); if (function_exists('phpdbg_start_oplog')) { $driver = new PhpdbgDriver(); } else { $driver = new XdebugDriver(); } $this->handler = new DependencyHandler($driver, $cache, $config, $fs); }
private function findPhpunit() { $has_phpdbg = $this->fs->phpdbgExists(); if ($this->fs->fileExists('vendor/bin/phpunit')) { if ($has_phpdbg) { return "phpdbg -qrr " . implode(DIRECTORY_SEPARATOR, ['vendor', 'phpunit', 'phpunit', 'phpunit']); } else { return implode(DIRECTORY_SEPARATOR, ['vendor', 'bin', 'phpunit']); } } if ($this->fs->fileExists('phpunit.phar')) { if ($has_phpdbg) { return 'phpdbg -qrr phpunit.phar'; } else { return 'php phpunit.phar'; } } return ''; }
public function run(array $argv = []) { $config_file = $this->fs->getConfigFile(); if (file_exists($config_file)) { echo $this->fs->relativePath($config_file), " already exists.\n"; } else { echo 'Creating ' . $this->fs->relativePath($config_file), ".\n"; $this->fs->saveConfigFile($this->config_generator->generate()); } $phpunit_config_file = $this->fs->getPhpunitConfigFile(); if (file_exists($phpunit_config_file)) { echo $this->fs->relativePath($phpunit_config_file), " already exists.\n"; } else { echo 'Creating ' . $this->fs->relativePath($phpunit_config_file), ".\n"; $this->fs->savePhpUnitConfig($this->phpunitConfig($argv)); } }
public function test_remove_cache_if_files_do_not_exist() { $arg = 'src/Calc.php'; $related_tests = ['tests/BankAccountTest.php', 'tests/CalcTest.php']; $this->cache->get($arg)->shouldBeCalled()->willReturn($related_tests); $this->cache->remove('src/Calc.php', 'tests/BankAccountTest.php')->shouldBeCalled(); $this->fs->saveCache($this->cache)->shouldBeCalled(); $this->fs->cacheDir()->willReturn('.smartrunner'); $this->fs->fileExists('tests/BankAccountTest.php')->willReturn(false); $this->fs->fileExists('tests/CalcTest.php')->willReturn(true); $this->fs->saveSuiteFile(['tests/CalcTest.php'])->shouldBeCalled(); $this->command->run([$arg]); }
public function endTestSuite() { $this->fs->saveCache($this->cache); }