public function testParseSimple() { $p = new Parser(); $array = array("LOC+9+VNSGN'", "LOC+11+ITGOA'", "MEA+WT++KGM:9040'"); $expected = [["LOC", "9", "VNSGN"], ["LOC", "11", "ITGOA"], ["MEA", "WT", "", ["KGM", "9040"]]]; $p->parse($array); $result = $p->get(); $this->assertEquals($expected, $result); }
public function testSegmentWithMultipleSingleQuotes() { $string = ["EQD+CX'DU12?+3456+2?:0'", "EQD+CXDU12?+3456+2?:0'"]; $p = new Parser(); $p->parse($string); $result = $p->get(); $experror = "There's a ' not escaped in the data; string EQD+CX'DU12?+3456+2?:0"; $error = $p->errors(); $this->assertContains($experror, $error); }
public function testProcess() { $parser = new Parser(__DIR__ . "/../files/example.edi"); $parsed = $parser->get(); $this->assertEquals(15, count($parsed)); $analyser = new Analyser(__DIR__ . "/../files/example.edi"); $codesXml = __DIR__ . "/../../src/EDI/Mapping/D07A/segments.xml"; //$analyser->loadSegmentsXml($codesXml); $result = $analyser->process($parsed); $this->assertEquals(399, strlen($result)); }
public function testNotEscapedSegment() { $string = "EQD+CX?DU12?+3456+2?:0'"; $expected = [["EQD", "CX?DU12+3456", "2:0"]]; $p = new Parser($string); $result = $p->get(); $experror = "There's a character not escaped with ? in the data; string CX?DU12?+3456"; $error = $p->errors(); $this->assertEquals($expected, $result); $this->assertContains($experror, $error); }
public function testDESADV() { $parser = new Parser(__DIR__ . "/../files/D96ADESADV.edi"); $mapping = new \EDI\Mapping\MappingProvider('D96A'); $analyser = new Analyser(); $segs = $analyser->loadSegmentsXml($mapping->getSegments()); $svc = $analyser->loadSegmentsXml($mapping->getServiceSegments(3)); $interpreter = new Interpreter($mapping->getMessage('desadv'), $segs, $svc); $interpreter->prepare($parser->get()); $this->assertJsonStringEqualsJsonFile(__DIR__ . "/../files/D96ADESADV.json", $interpreter->getJson(true), "JSON does not match expected output"); $this->assertCount(2, $interpreter->getMessages()); $this->assertCount(1, $interpreter->getErrors()); $this->assertCount(2, $interpreter->getServiceSegments()); $this->assertEquals([[]], $interpreter->getErrors()); }