public function testCreateCsvEricsson()
 {
     $csvFileName = tempnam('/tmp', '_csvParserTest_');
     file_put_contents($csvFileName, '8934071279000005005,GEM17223,2,SIM_Model,APN1,10.1.2.1,1,TM SPAIN');
     $parser = new App_Parser_CsvParser($csvFileName);
     $list = $parser->parse();
     unlink($csvFileName);
     try {
         $this->assertNotNull($this->stockMapper->createCsvEricsson($list));
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
 public function getData($filename, $mime)
 {
     // I'm not sure... I don't like it.
     set_time_limit(0);
     /**
      * According to its mime type, call the
      * correct parser.
      */
     switch ($mime) {
         case 'text/plain':
             /**
              * Try to parse the file as MSISDN data
              */
             $parser = new \App_Parser_MSISDNParser($filename);
             $fileType = "csvMsisdn";
             $data = $parser->parse();
             $firstError = $parser->getErrors(0);
             if (!$data && $firstError && $firstError->code === ValidationCodes::FILE_TYPE_UNKNOWN) {
                 // If it's not MSISDN data, try the CSV parser
                 $parser = new \App_Parser_CsvParser($filename);
                 $fileType = "csvData";
                 $data = $parser->parse();
             }
             $firstError = $parser->getErrors(0);
             break;
         case 'application/xml':
             $parser = new \App_Parser_SimManufacturerParser($filename);
             $fileType = "xml";
             $data = $parser->parse();
             $firstError = $parser->getErrors(0);
             break;
         default:
             $firstError = \App_Parser_AbstractParser::createUnknownFileTypeError();
             throw new AppEx\StockParserException('Invalid parameter value: attached file', array('errorMessages' => array($firstError)));
     }
     if ($firstError && $firstError->code === ValidationCodes::FILE_TYPE_UNKNOWN) {
         \App::log()->warn("Error parsing file: \n" . implode("\n", $parser->getErrors()));
         throw new AppEx\StockParserException('Invalid parameter value: attached file', array('errorMessages' => array($firstError)));
     }
     $errors = $parser->getErrors();
     $errors = array_reverse($errors, false);
     $count = $parser->getItemParsedCount();
     if (!$data) {
         \App::log()->warn("Error parsing file: \n" . implode("\n", $errors));
         throw new AppEx\InvalidFileContentException('Invalid parameter value: attached file', array('errorMessages' => $errors, 'fileType' => $fileType, 'simParsed' => $count));
     }
     return array('data' => $data, 'errors' => $errors, 'count' => $count);
 }