Пример #1
0
 /**
  * @test
  */
 public function factoryTest()
 {
     $document = new \SimpleXMLElement(file_get_contents(__DIR__ . '/Fixtures/sample.xml'));
     SaxParser::factory()->parse(new SampleXmlHandler(), $document, \Closure::bind(function () {
         $this->assertTrue(true, 'Parsing should be executed.');
     }, $this));
 }
 protected function assertParsing($pathToXmlInput, $pathToPhpOutput, $message = 'Should provide given rates.')
 {
     $rates = null;
     SaxParser::factory()->parse(new XmlParser(), fopen($pathToXmlInput, 'r'), function ($result) use(&$rates) {
         $rates = $result;
     });
     $this->assertSame(require_once $pathToPhpOutput, call_user_func(function ($rates) {
         $flatten = array();
         /**
          * @var RateInterface $rate
          */
         foreach ($rates as $rate) {
             $flatten[] = array('currencyCode' => $rate->getCurrencyCode(), 'rateType' => $rate->getRateType(), 'value' => (string) $rate->getValue(), 'date' => $rate->getDate()->format('Y-m-d'));
         }
         return $flatten;
     }, $rates), $message);
 }