public function testGettingTheDefinitionWillReturnADomDocumentWithValidDefinitionFile()
    {
        $xml = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<chart name="Personal">
    <account nominal="0000" type="real" name="COA">
        <account nominal="1000" type="real" name="Balance Sheet"/>
    </account>
</chart>
EOT;
        $root = vfsStream::setup();
        $file = vfsStream::newFile('test3.xml')->withContent($xml)->at($root);
        $sut = new ChartDefinition(new StringType($file->url()));
        $this->assertInstanceOf('DOMDocument', $sut->getDefinition());
    }
Example #2
0
 /**
  * Create a new Chart
  *
  * @param StringType $chartName
  * @param Organisation $org
  * @param ChartDefinition $def
  *
  * @return Chart
  */
 public function createChart(StringType $chartName, Organisation $org, ChartDefinition $def)
 {
     return FFor::create()->dom(function () use($def) {
         return $def->getDefinition();
     })->xpath(function ($dom) {
         return new \DOMXPath($dom);
     })->root(function ($xpath) {
         return $xpath->query('/chart/account')->item(0);
     })->tree(function () {
         return new Node();
     })->chart(function ($tree) use($chartName, $org) {
         return new Chart($chartName, $org, $tree);
     })->build(function ($root, $tree, $chart) {
         $this->buildTree($tree, $root, $chart, AccountType::toArray());
     })->fyield('chart');
 }