public function setUp() { $this->dispatcherMock = $this->getMockBuilder(EventDispatcher::class)->setMethods(['dispatch'])->getMock(); $this->command = new RunTestsCommand($this->dispatcherMock); $this->input = new StringInput('staging firefox'); $this->input->bind($this->command->getDefinition()); $this->bufferedOutput = new BufferedOutput(); $this->bufferedOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $this->bufferedOutput->setDecorated(false); $this->publisherMock = $this->getMockBuilder(XmlPublisher::class)->disableOriginalConstructor()->getMock(); $this->creator = new ProcessSetCreator($this->command, $this->input, $this->bufferedOutput, $this->publisherMock); }
public function testLogsFromListeners() { $output = new BufferedOutput(); $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); $handler = new ConsoleHandler(null, false); $logger = new Logger('app'); $logger->pushHandler($handler); $dispatcher = new EventDispatcher(); $dispatcher->addListener(ConsoleEvents::COMMAND, function () use($logger) { $logger->addInfo('Before command message.'); }); $dispatcher->addListener(ConsoleEvents::TERMINATE, function () use($logger) { $logger->addInfo('Before terminate message.'); }); $dispatcher->addSubscriber($handler); $dispatcher->addListener(ConsoleEvents::COMMAND, function () use($logger) { $logger->addInfo('After command message.'); }); $dispatcher->addListener(ConsoleEvents::TERMINATE, function () use($logger) { $logger->addInfo('After terminate message.'); }); $event = new ConsoleCommandEvent(new Command('foo'), $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'), $output); $dispatcher->dispatch(ConsoleEvents::COMMAND, $event); $this->assertContains('Before command message.', $out = $output->fetch()); $this->assertContains('After command message.', $out); $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'), $output, 0); $dispatcher->dispatch(ConsoleEvents::TERMINATE, $event); $this->assertContains('Before terminate message.', $out = $output->fetch()); $this->assertContains('After terminate message.', $out); }
/** * Test that the execution is successful. * * @return void */ public function testExecution() { $project = $this->getMockBuilder('CyberSpectrum\\PharPiler\\Project')->disableOriginalConstructor()->getMock(); $task = new RunCommandTask(['command' => 'echo "hello world"', 'working_dir' => getcwd(), 'timeout' => null]); $task->setLogger(new ConsoleLogger($output = new BufferedOutput())); $output->setVerbosity(BufferedOutput::VERBOSITY_DEBUG); $task->execute($project); $this->assertEquals('[info] echo "hello world": hello world' . "\n" . '[info] echo "hello world": ' . "\n", $output->fetch()); }
/** * @dataProvider inputProvider * @param string $stringInput * @param string $expectedIdeKey */ public function testShouldGetIdeKeyFromCommandOptionOnCommandInitialization($stringInput, $expectedIdeKey) { $this->mockXdebugExtension($isExtensionLoaded = true, $isRemoteEnabled = true); $command = new RunCommand(new EventDispatcher()); $input = new StringInput($stringInput); $output = new BufferedOutput(); $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); // Trigger event to add the xdebug option to the command and bind the definition to the input $this->listener->onCommandConfigure(new BasicConsoleEvent($command)); $input->bind($command->getDefinition()); // Trigger command initialization event $event = new ExtendedConsoleEvent($command, $input, $output); $this->listener->onCommandRunTestsInit($event); if ($expectedIdeKey !== null) { $this->assertContains('Xdebug remote debugging initialized with IDE key: ' . $expectedIdeKey, $output->fetch()); } else { // no output expected (xdebug not triggered) $this->assertEmpty($output->fetch()); } }
/** * @test */ public function registerCustomAutoloaders() { $array = array('autoloaders' => array('$prefix' => '$path'), 'autoloaders_psr4' => array('$prefix\\' => '$path')); $output = new BufferedOutput(); $config = new Config(array(), false, $output); $config->setConfig($array); $autloader = new ClassLoader(); $config->registerCustomAutoloaders($autloader); $output->setVerbosity($output::VERBOSITY_DEBUG); $config->registerCustomAutoloaders($autloader); }