/** * @test * @expectedException \EDI\Exception\MandatorySegmentPieceMissing */ public function should_detect_mandatory_field_part_missing() { $populator = $this->givenPopulator(); $fixtureDir = realpath(__DIR__ . '/../fixtures'); $parser = new Parser(); $data = $parser->parse($fixtureDir . '/invalid_message_missing_value_part.edi'); $populator->populate($data); }
public function testNoErrors() { $p = new Parser(); $string = "LOC+9+VNSGN'\nLOC+11+ITGOA'"; $p->parse($string); $result = $p->errors(); $this->assertEmpty($result); }
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); }
/** @test */ public function should_handle_multiple_messages() { $loader = new MappingLoader(realpath(__DIR__ . '/../../src/EDI/Mapping')); $segmentPopulator = $this->givenSegmentPopulator(); $populator = $this->givenPopulator($segmentPopulator, $loader); $fixtureDir = realpath(__DIR__ . '/../fixtures'); $parser = new Parser(); $data = $parser->parse($fixtureDir . '/invoic_three_messages.edi'); $messages = $populator->populate($data); $this->assertCount(3, $messages); }