/**
  * @param Iterator $iterator
  * @return ImportResult
  */
 public function import(Iterator $iterator)
 {
     $importResult = new ImportResult();
     foreach ($iterator as $key => $row) {
         if ($key < 2 && $row[0] === 'order_ref') {
             continue;
         }
         $orderExternalId = $row[0];
         $invoiceExternalId = $row[1];
         $amount = $this->convertDollarToCents($row[2]);
         $checkNumber = $row[3];
         $date = $row[4];
         $order = $this->orderRepository->findOneByExternalId($orderExternalId);
         try {
             if (!empty($checkNumber)) {
                 $payment = new CheckPayment($amount, $checkNumber, new DateTime($date));
             } else {
                 $payment = new CashPayment($amount);
             }
             $payment->setCreated(new DateTime($date));
             $payment->setOrder($order);
             $this->throwValidationErrors($payment);
             $this->paymentRepository->persist($payment);
             $importResult->incrementSuccess();
         } catch (KommerceException $e) {
             $importResult->addFailedRow($row);
             $importResult->addErrorMessage($e->getMessage());
         }
     }
     $this->paymentRepository->flush();
     return $importResult;
 }
 public function testFindCheckPayment()
 {
     $originalPayment = $this->dummyData->getCheckPayment();
     $this->setupPayment($originalPayment);
     $this->entityManager->clear();
     $this->setCountLogger();
     $payment = $this->paymentRepository->findOneById($originalPayment->getId());
     $payment->getOrder()->getCreated();
     $this->assertEquals($originalPayment->getId(), $payment->getId());
     $this->assertSame(100, $payment->getAmount());
     $this->assertSame('0001234', $payment->getCheckNumber());
     $this->assertSame('memo area', $payment->getMemo());
     $this->assertEquals(new DateTime('4/13/2016'), $payment->getCheckDate());
     $this->assertSame(3, $this->getTotalQueries());
 }