function it_should_set_version_to_git_describe(VariableContainer $variableContainer, CommandAction $commandAction)
 {
     $commandAction->exec()->willReturn('1.2.6-77-abcd');
     $commandAction->setCommand('git describe')->shouldBeCalled();
     $variableContainer->setVariable('version', '1.2.6-77-abcd')->shouldBeCalled();
     $this->exec()->shouldReturn(true);
 }
예제 #2
0
 function it_should_parse_version(VariableContainer $variableContainer, VersionParser $versionParser)
 {
     $tmpVersion = '3.421.55';
     $variableContainer->getVariable('version')->willReturn('3.421.55');
     $variableContainer->setVariable('version', '4.0.0')->shouldBeCalled();
     $versionParser->parse($tmpVersion)->willReturn(array('major' => '3', 'minor' => '421', 'patch' => '55'));
     $params = array('variable' => 'version');
     $this->setVerbose(true);
     $this->setParams($params);
     $this->exec()->shouldReturn(true);
     $this->getOutput()->shouldReturn('major_up["version"="4.0.0"]');
 }
예제 #3
0
 function it_should_save_a_variable_to_file_in_dry_run_mode(VariableContainer $variableContainer, FileReader $fileReader)
 {
     $text = ' "name": "John Doe" ';
     $params = array('filename' => 'fake.file.json', 'variable' => 'person', 'src' => '/"name" *: *"[^"]+"/', 'dest' => '"name": "{{ person }}"');
     $fileReader->fileGetContents($params['filename'])->willReturn($text);
     //        $variableContainer->getVariable('person')->willReturn('Lorem Ipsum');
     $variableContainer->getVariables()->willReturn(array('person' => 'Lorem Ipsum'));
     $fileReader->filePutContents($params['filename'], ' "name": "Lorem Ipsum" ')->shouldBeCalled();
     $this->setParams($params);
     $this->setVerbose(true);
     $this->exec()->shouldReturn(true);
     $this->getOutput()->shouldReturn('save_variable_to_file["name": "Lorem Ipsum"]');
 }
예제 #4
0
 function it_should_not_run_command_in_dry_mode(VariableContainer $variableContainer, Process $process)
 {
     $params = array('commandTemplate' => 'echo "Hello, {{ subjectOfGreeting }}"');
     $variableContainer->getVariables()->willReturn(array('subjectOfGreeting' => 'WORLD'));
     $process->setCommandLine('echo "Hello, WORLD"')->shouldNotBeCalled();
     $process->disableOutput()->shouldNotBeCalled();
     $process->run()->shouldNotBeCalled();
     $process->getExitCode()->shouldNotBeCalled();
     $this->setParams($params);
     $this->setVerbose(true);
     $this->setDryRun(true);
     $this->exec()->shouldReturn(true);
     $this->getResult()->shouldReturn(null);
     $this->getOutput()->shouldReturn('command["echo "Hello, WORLD""]');
 }
 function it_should_parse_a_variable_from_file_in_verbose_mode(FileReader $fileReader, ParseVariableAction $variableParser, VariableContainer $variableContainer)
 {
     $text = '
         "name"  :   "Lorem"
     ';
     $params = array('filename' => 'f.json', 'regex' => '/"name" *: *"(?P<name>[^"]+)"/');
     $fileReader->fileGetContents($params['filename'])->willReturn($text);
     $variableParser->exec()->willReturn(true);
     $variableParser->getResult()->willReturn(array('name' => 'Lorem'));
     $variableParser->setParams(array('text' => $text, 'regex' => $params['regex']))->shouldBeCalled();
     $variableParser->getResult()->shouldBeCalled();
     $variableContainer->setVariable('name', 'Lorem')->shouldBeCalled();
     $this->setParams($params);
     $this->setVerbose(true);
     $this->exec()->shouldReturn(true);
     $this->getResult()->shouldReturn(array('name' => 'Lorem'));
     $this->getOutput()->shouldReturn('parse_variable_from_file["filename"="f.json"]["name"="Lorem"]');
 }