public function testCreateSimEricsson()
 {
     $xmlFileName = tempnam('/tmp', '_simManufacturerParserTest_');
     file_put_contents($xmlFileName, '<?xml version="1.0" encoding="UTF-8"?><schema><Header Template_Version="xsd_fichero_intercambio_v001" Date_of_Issuance="2009-05-21" Template_Version_History="Version 001" Comments="Version oficial xml"/><Label><Customer Data="TM SPAIN" Print="Y"/><Order Data="GEM17223" Print="Y"/><Class Data="JA" Print="Y"/><Logistics_Profile Data="P32" Print="Y"/><Operation_Zone Data="JAS" Print="Y"/><GICE Data="20110001790001" Print="Y"/><TME_Material Data="T064015020" Print="Y"/><Manufacturer_Material Data="G00154" Print="Y"/><SAP_Reference Data="4600005142" Print="Y"/><Warehouse Data="1410" Print="Y"/><EAN_Code Data="" Print="Y"/><Delivery_Date Data="2011-04-29" Print="Y"/><Comments Data="" Print="Y"/></Label><Description><Manufacturer>GEMPLUS PERSONALIZADAS</Manufacturer><UXP_Definition>P3264.0704022011.upx</UXP_Definition><Quantity>500</Quantity><Type>2</Type><Profile>64.07</Profile><Graph_Reference>16.18</Graph_Reference><Batch>17223</Batch><Artwork>UNIVERSAL 3G</Artwork><Algorithm>004</Algorithm><Transport_Key Version="2" Key_Id="020" /></Description><Input_List><Primary_Subscription ICC-ID="8934071279000005005" IMSI="214074200002135"/></Input_List><Output_List><TECH>00033</TECH><Perso_Date>2011-04-25</Perso_Date><Output_Data><Primary_Subscription ICC-ID="8934071279000005005" IMSI="214074200002135" K="CD17C5C731089C8409A90E0C0F3DD59D"/><PIN_PUK_Settings><PIN1_Settings><Data_Value>7170</Data_Value></PIN1_Settings><PIN2_Settings><Data_Value>2322</Data_Value></PIN2_Settings><PUK1_Settings><Data_Value>54333340</Data_Value></PUK1_Settings><PUK2_Settings><Data_Value>22941582</Data_Value></PUK2_Settings></PIN_PUK_Settings><ADM Name="ADM1" Data_Value="1BC2118413B4C7D9" /><SD><AID></AID><KeySet Name="05" Kid="77FED3C0CE7D859B" Kic="D38A46E596FA0E1F" DEK="" /></SD></Output_Data></Output_List></schema>');
     $parser = new App_Parser_SimManufacturerParser($xmlFileName);
     $list = $parser->parse();
     unlink($xmlFileName);
     try {
         $result = $this->stockMapper->createSimEricsson($list, $this->_user->getOrganizationId());
         $this->assertNotNull($result);
         $this->assertTrue(is_array($result));
     } 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);
 }