Fix output for tests to pass again

This commit is contained in:
Oliver Davies 2018-01-15 09:24:38 +00:00
parent 6d6f5596ce
commit b9b41aa437
3 changed files with 37 additions and 9 deletions

View file

@ -19,10 +19,21 @@ class Builder
*/
private $outputFile;
public function __construct(array $filters, $outputFile = 'filters.xml') {
/**
* @var bool
*/
private $writeFile;
/**
* @var string
*/
private $xml;
public function __construct(array $filters, $outputFile = 'filters.xml', $writeFile = true) {
$this->filesystem = new Filesystem();
$this->filters = $filters;
$this->outputFile = $outputFile;
$this->writeFile = $writeFile;
$this->build();
}
@ -32,6 +43,16 @@ class Builder
return $this->build();
}
/**
* Returns the generated XML.
*
* @return string
*/
public function getXml()
{
return $this->xml;
}
/**
* Build XML for a set of filters.
*
@ -46,9 +67,11 @@ class Builder
return $this->buildEntry($items);
})->implode(PHP_EOL);
$content = collect([$prefix, $xml, $suffix])->implode(PHP_EOL);
$this->xml = collect([$prefix, $xml, $suffix])->implode(PHP_EOL);
$this->filesystem->dumpFile($this->outputFile, $content);
if ($this->writeFile) {
$this->filesystem->dumpFile($this->outputFile, $this->xml);
}
}
/**