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); }
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"]'); }
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"]'); }