/** * Read configuration information from input * * @return Configuration */ public function read() { $configuration = new Configuration(); $options = ['grep' => [$configuration, 'setGrep'], 'no-colors' => [$configuration, 'disableColors'], 'force-colors' => [$configuration, 'enableColorsExplicit'], 'bail' => [$configuration, 'stopOnFailure'], 'configuration' => [$configuration, 'setConfigurationFile']]; if ($path = $this->input->getArgument('path')) { $configuration->setPath($path); } foreach ($options as $option => $callable) { $this->callForOption($option, $callable); } return $configuration; }
<?php use Peridot\Configuration; use Peridot\Concurrency\Environment\Reader; describe('Reader', function () { beforeEach(function () { $configuration = new Configuration(); //write config to environment $configuration->setDsl(__FILE__); $configuration->setGrep('*.test.php'); $configuration->setPath('/path/to/tests'); $configuration->setReporter('reporter'); $configuration->disableColors(); $configuration->stopOnFailure(); $this->configuration = $configuration; $this->reader = new Reader(new Configuration()); }); describe('->getConfiguration()', function () { it('should fetch a configuration object populated by environment', function () { $config = $this->reader->getConfiguration(); expect($config->getDsl())->to->equal($this->configuration->getDsl()); expect($config->getGrep())->to->equal($this->configuration->getGrep()); expect($config->getPath())->to->equal($this->configuration->getPath()); expect($config->getReporter())->to->equal($this->configuration->getReporter()); expect($config->areColorsEnabled())->to->equal($this->configuration->areColorsEnabled()); expect($config->shouldStopOnFailure())->to->equal($this->configuration->shouldStopOnFailure()); }); }); });
use Peridot\Plugin\Watcher\WatcherInterface; use Peridot\Plugin\Watcher\WatcherPlugin; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\OutputInterface; describe('WatcherPlugin', function () { beforeEach(function () { $this->emitter = new EventEmitter(); $this->watcher = new WatcherPlugin($this->emitter); }); context('when peridot.configure event fires', function () { it('should add the test path to tracked paths', function () { $configuration = new Configuration(); $configuration->setPath('/path/to/thing'); $this->emitter->emit('peridot.configure', [$configuration]); assert($this->watcher->getTrackedPaths()[0] == $configuration->getPath(), "should track config path"); }); }); $setupEnvironment = function () { $this->definition = new InputDefinition(); $this->environment = new Environment($this->definition, $this->emitter, []); }; context('when peridot.start event fires', function () use($setupEnvironment) { beforeEach($setupEnvironment); beforeEach(function () { $this->application = new Application($this->environment); $this->emitter->emit('peridot.start', [$this->environment, $this->application]); }); it('should add a watch option on the input definition', function () {