Example #1
0
 /**
  * Validate that a supplied configuration exists.
  *
  * @return void
  */
 protected function validateConfiguration()
 {
     if (!$this->environment->load(getcwd() . DIRECTORY_SEPARATOR . 'peridot.php')) {
         fwrite(STDERR, "Configuration file specified but does not exist" . PHP_EOL);
         exit(1);
     }
 }
 /**
  * @param Environment $environment
  */
 public function onPeridotStart(Environment $environment)
 {
     $definition = $environment->getDefinition();
     $definition->option('watch', null, InputOption::VALUE_NONE, "watch tests for changes and re-run them");
 }
 public function onPeridotStart(Environment $environment)
 {
     $environment->getDefinition()->option('code-coverage-path', null, InputOption::VALUE_REQUIRED, 'Set the output directory for code coverage reporter');
 }
Example #4
0
 /**
  * Return the peridot input definition defined by Environment
  *
  * @return InputDefinition
  */
 protected function getDefaultInputDefinition()
 {
     return $this->environment->getDefinition();
 }
use Peridot\Console\Environment;
use Peridot\Console\InputDefinition;
describe('Environment', function () {
    beforeEach(function () {
        $this->definition = new InputDefinition();
        $this->emitter = new EventEmitter();
        $configPath = __DIR__ . '/../fixtures/config.php';
        $this->environment = new Environment($this->definition, $this->emitter, array('c' => $configPath, 'configuration' => $configPath));
    });
    describe('->getDefinition()', function () {
        it('should return the input definition', function () {
            $definition = $this->environment->getDefinition();
            assert($definition === $this->definition, 'defintion should have been returned');
        });
    });
    describe('->load()', function () {
        it('should return true when it includes the config file', function () {
            assert($this->environment->load('somedefault.php'), "load should return true on success");
        });
        it('should return true when it includes the default config file', function () {
            $environment = new Environment($this->definition, $this->emitter, []);
            $path = __DIR__ . '/../fixtures/config2.php';
            $result = $environment->load($path);
            assert($result, "default config should have loaded");
        });
        it('should return false when it cant include the config file', function () {
            $environment = new Environment($this->definition, $this->emitter, ['c' => 'nope.php']);
            assert($environment->load('somedefault.php') == false, "load should return false on failure");
        });
    });
});
 /**
  * Registers a --concurrent option with Peridot
  *
  * @param Environment $env
  * @return void
  */
 public function onPeridotStart(Environment $env)
 {
     $definition = $env->getDefinition();
     $definition->option('concurrent', null, InputOption::VALUE_NONE, 'run specs concurrently');
     $definition->option('processes', 'p', InputOption::VALUE_REQUIRED, 'number of processes to use');
 }