/** * Исключение, если данные не найдены */ public function testExpcetionIfDataNotFound() { $email = new myCreateEmailAmtImport($data = $this->_getData()); $getEmail = new myParseEmailAmtImport((string) $email); $this->setExpectedException('Exception', 'not found'); $getEmail->getAmtData(); }
/** * Run */ public function execute($arguments = array(), $options = array()) { // From file if ($arguments['file']) { if (!is_readable($arguments['file'])) { $this->logSection('import', "Failed to read file `{$arguments['file']}`", null, 'ERROR'); return 1; } $input = file_get_contents($arguments['file']); // STDIN } else { $input = ''; while ($row = fgets(STDIN)) { $input .= $row; } $input = trim($input); } if (!$input) { $this->logging("Expected not empty input", $input); return 1; } try { $getEmail = new myParseEmailAmtImport($input); $operationData = $getEmail->getAmtData(); } catch (Exception $e) { $this->logging($e->getMessage(), $input); return 2; } // Инициализировать соединение с БД $databaseManager = new sfDatabaseManager($this->configuration); // Форма/Сохранить операцию $form = new OperationImportAmtForm(); $form->bind($operationData); if ($form->isValid()) { $form->save(); } else { $this->logging($form->getErrorSchema(), $input); return 3; } $this->logSection('import', 'Done'); return 0; }