コード例 #1
0
 /** @test */
 public function should_load_codes_from_file()
 {
     $loader = new MappingLoader(__DIR__ . '/../fixtures');
     $result = $loader->loadCodes('D', '96A');
     $this->assertEquals(1, count($result));
     $this->assertEquals('1', $result['1001'][0]->getId());
     $this->assertEquals('Certificate of analysis', $result['1001'][0]->getDesc());
     $this->assertEquals('2', $result['1001'][1]->getId());
     $this->assertEquals('Certificate of conformity', $result['1001'][1]->getDesc());
     $this->assertEquals('3', $result['1001'][2]->getId());
     $this->assertEquals('Certificate of quality', $result['1001'][2]->getDesc());
 }
コード例 #2
0
ファイル: Reader.php プロジェクト: progrupa/edifact
 /**
  * @param $version
  * @return Populator
  * @throws MappingNotFoundException
  */
 protected function updatePopulatorConfiguration($version)
 {
     $dir = realpath($this->mappingDirectory . "/{$version}");
     if (!file_exists($dir)) {
         throw new MappingNotFoundException(sprintf("Mapping directory '%s' not found", $this->mappingDirectory));
     }
     $segmentsFile = $dir . '/segments.xml';
     if (!file_exists($segmentsFile) || !is_readable($segmentsFile)) {
         throw new MappingNotFoundException(sprintf("segments.xml mapping file not found in directory '%s'", $this->mappingDirectory));
     }
     $this->populator->setSegments($this->mappingLoader->loadSegments($segmentsFile));
     $codesFile = $dir . '/codes.xml';
     if (!file_exists($codesFile) || !is_readable($codesFile)) {
         throw new MappingNotFoundException(sprintf("codes.xml mapping file not found in directory '%s'", $this->mappingDirectory));
     }
     $this->populator->setCodes($this->mappingLoader->loadCodes($codesFile));
 }