public function test_it_will_install_specified_version_of_behat_if_not_present() { $this->packageMock->expects(static::any())->method('hasPackage')->with('behat/behat', null, $this->inputMock, $this->outputMock)->willReturn(false); $this->questionMock->shouldReceive('ask')->once()->with($this->inputMock, $this->outputMock, Mockery::on(function (Question $question) { if (strpos($question->getQuestion(), 'What package version of behat do you want to install? [latest]: ') !== false) { return true; } return false; }))->andReturn($version = '>=2.5'); $this->requireMock->expects(static::once())->method('requirePackage')->with($this->outputMock, 'behat/behat', $version, true)->willReturn(0); static::assertEquals(0, $this->sut->run($this->inputMock, $this->outputMock)); }
public function test_it_will_install_code_sniffer_with_specified_version() { $this->packageMock->expects(static::any())->method('hasPackage')->with(CodeSnifferCommand::PACKAGE_NAME, null, $this->inputMock, $this->outputMock)->willReturn(false); $this->questionMock->shouldReceive('ask')->once()->with($this->inputMock, $this->outputMock, Mockery::on(function (Question $question) { if (strpos($question->getQuestion(), 'What package version of CodeSniffer do you want to install? [latest]: ') !== false) { return true; } return false; }))->andReturn($version = 'v1.0'); $this->requireMock->expects(static::once())->method('requirePackage')->with($this->outputMock, CodeSnifferCommand::PACKAGE_NAME, $version, true)->willReturn(0); static::assertEquals(0, $this->sut->run($this->inputMock, $this->outputMock)); }
public function test_it_will_generate_phpunit_configuration_after_overwrite_confirmation() { file_put_contents($this->configPath, '<phpunit>old</phpunit>'); $this->questionMock->shouldReceive('ask')->once()->with($this->inputMock, $this->outputMock, Mockery::on(function (Question $question) { if (strpos($question->getQuestion(), 'already exists, do you want to overwrite it?') !== false) { return true; } return false; }))->andReturn(true); $this->factoryMock->expects(static::any())->method('create')->with($this->inputMock, $this->outputMock, $this->questionMock)->willReturn($config = '<phpunit/>'); static::assertEquals(0, $this->sut->run($this->inputMock, $this->outputMock)); static::assertEquals($config, file_get_contents($this->configPath)); }
/** * @return string */ private function call_create_on_sut() { // low priority catchall $this->mockHelper->shouldReceive('ask')->withAnyArgs()->andReturn(); return $this->sut->create($this->mockInput, $this->mockOutput, $this->mockHelper); }