예제 #1
0
 /**
  * @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);
 }
예제 #2
0
 public function testNoErrors()
 {
     $p = new Parser();
     $string = "LOC+9+VNSGN'\nLOC+11+ITGOA'";
     $p->parse($string);
     $result = $p->errors();
     $this->assertEmpty($result);
 }
예제 #3
0
 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));
 }
예제 #4
0
 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());
 }
예제 #5
0
 public function testLoadWrappedFile()
 {
     $p = new Parser(__DIR__ . "/../files/example_wrapped.edi");
     $result = $p->errors();
     $this->assertEmpty($result);
 }
예제 #6
0
 /** @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);
 }