use Peridot\Concurrency\Runner\StreamSelect\Message\TestMessage; use Peridot\Concurrency\Runner\StreamSelect\Model\Suite; use Peridot\Concurrency\Runner\StreamSelect\Model\Test; use Peridot\Configuration; use Prophecy\Argument; require 'TestMessageReader.php'; describe('Application', function () { $this->peridotAddChildScope(new TestMessageReader()); beforeEach(function () { $this->emitter = new EventEmitter(); $this->readStream = tmpfile(); $this->writeStream = tmpfile(); $this->message = new TestMessage($this->writeStream); $environment = new Environment($this->emitter, $this->readStream, $this->writeStream); $config = new Configuration(); $config->setDsl(__DIR__ . '/../../../../fixtures/environment/dsl.php'); $config->setConfigurationFile(__DIR__ . '/../../../../fixtures/environment/peridot.php'); $reader = $this->getProphet()->prophesize('Peridot\\Concurrency\\Environment\\ReaderInterface'); $reader->getConfiguration()->willReturn($config); $looper = $this->getProphet()->prophesize('Peridot\\Concurrency\\Runner\\StreamSelect\\Application\\LooperInterface'); $looper->loop(Argument::type('Peridot\\Runner\\Context'), $environment, $this->message)->shouldBeCalled(); $this->application = new Application($environment, $reader->reveal(), $looper->reveal()); /** * An application does not listen until run. */ $this->application->run($this->message); }); afterEach(function () { fclose($this->readStream); fclose($this->writeStream); $this->getProphet()->checkPredictions();
<?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()); }); }); });