/** * @param string $variableName * @param string $value */ public function replaceValue($variableName, $value) { $variableDeclaration = $variableName . '=\'' . $value . '\''; if (null === $this->getValue($variableName)) { $contents = $this->fileManipulator->read() . PHP_EOL . $variableDeclaration; } else { $contents = preg_replace($this->getVariablePattern($variableName), $variableDeclaration, $this->fileManipulator->read()); } $this->fileManipulator->write($contents); }
/** * @Then the content of the file should be: */ public function theFollowingFileShouldBeWrittenIn(PyStringNode $string) { if ($this->fileManipulator->read() != $string->getRaw()) { throw new \RuntimeException(sprintf('Expected to have "%s" but got "%s"', $string->getRaw(), $this->fileManipulator->read())); } }