/** * Тест парсинга xml. * @covers \Epay\Xml::parse() */ public function testParse() { $result = $this->xml->parse('<data attr="attr_value">char_value</data>'); $this->assertInternalType('array', $result); $this->assertArrayHasKey('DATA_ATTR', $result); $this->assertEquals($result['DATA_ATTR'], 'attr_value'); $this->assertArrayHasKey('DATA_CHARDATA', $result); $this->assertEquals($result['DATA_CHARDATA'], 'char_value'); }
/** * Проверят ответ от банка. * * @param $response * @return array|string */ public function processResponse($response) { $parser = new Xml(); $result = $parser->parse($response); if (in_array("ERROR", $result)) { return $result; } if (in_array("DOCUMENT", $result)) { $sign = new Sign($this->config); $sign->setInvert(true); $data = $this->splitSign($response, 'BANK'); $check = $sign->checkSign64($response, 'BANK'); switch ($check) { case 1: $data['CHECKRESULT'] = '[SIGN_GOOD]'; break; case 0: $data['CHECKRESULT'] = '[SIGN_BAD]'; break; default: $data['CHECKRESULT'] = '[SIGN_CHECK_ERROR]: '; // Как сюда засунуть результат? . $kkb->estatus; break; } return array_merge($result, $data); } return "[XML_DOCUMENT_UNKNOWN_TYPE]"; }