/** * @test */ public function matchRecordGeneratesProperXml() { $match = new Match(); $match->setOffice('001'); $match->setCode('170'); // fixed $match->setDate('20160908'); $i = 0; $line = new MatchLine(); $line->setTransCode('INCASSO-OW'); $line->setTransNumber('1000'); // Twinfield generated ID for memorial transaction $line->setTransLine(2); $match->addLine($line); $line = new MatchLine(); $line->setTransCode('VRK'); $line->setTransNumber('20160001'); // Twinfield generated ID for invoice transaction $line->setTransLine(1); $line->setMatchValue(100); $match->addLine($line); $matchDocument = new MatchDocument(); $matchDocument->addMatch($match); $generatedXml = $matchDocument; $expectedXml = new DOMDocument(); $expectedXml->loadXml('<match> <set> <office>001</office> <matchcode>170</matchcode> <matchdate>20160908</matchdate> <lines> <line> <transcode>INCASSO-OW</transcode> <transnumber>1000</transnumber> <transline>2</transline> </line> <line> <transcode>VRK</transcode> <transnumber>20160001</transnumber> <transline>1</transline> <matchvalue>100.00</matchvalue> </line> </lines> </set> </match>'); $this->assertEqualXMLStructure($expectedXml->documentElement, $generatedXml->documentElement); return $match; }
/** * Sends a \Pronamic\Twinfield\Match\Match instance to Twinfield * to update or add. * * First attempts to login with the passed configuration in the constructor. * If successful will get the secure Service class. * * It will then make an instance of * \Pronamic\Twinfield\Customer\DOM\MatchDocument where it will * pass in the Match class in this methods parameter. * * It will then attempt to send the DOM document from MatchsDocument * and set the response to this instances method setResponse() (which you * can get with getResponse()) * * If successful will return true, else will return false. * * If you want to map the response back into a Artoc;e use getResponse()-> * getResponseDocument()->asXML() into the MatchMapper::map method. * * @access public * @param \Pronamic\Twinfield\Match\Match $match * @return boolean */ public function send(Match $match) { // Attempts the process login if ($this->getLogin()->process()) { // Gets the secure service $service = $this->getService(); // Gets a new instance of matchDocument and sets the $Match $matchDocument = new DOM\MatchDocument(); $matchDocument->addMatch($match); // Send the DOM document request and set the response $response = $service->send($matchDocument); $this->setResponse($response); // Return a bool on status of response. if ($response->isSuccessful()) { return true; } else { return false; } } }