public function testFilterNotesImportFromBibleditGtkFile() { $session_logic = Session_Logic::getInstance(); $session_logic->setUsername("PHPUnit"); $_SERVER['HTTP_USER_AGENT'] = "PHPUnit"; $_SERVER['REMOTE_ADDR'] = "127.0.0.1"; $database_notes = Database_Notes::getInstance(); $filename = tempnam(sys_get_temp_dir(), ''); $data = <<<EOD 731157 Note Author Acts.3.13 No issue Ndebele 731157 umdumisile: Text was changed from "has given glory" to "has glorified". Logbook: EOD; file_put_contents($filename, $data); $identifier = Filter_Notes::importFromBibleditGtkFile($filename); $this->note_identifiers[] = $identifier; $bible = $database_notes->getBible($identifier); $this->assertEquals("Ndebele", $bible); $passages = $database_notes->getPassages($identifier); $this->assertEquals(array(array(44, 3, 13)), $passages); $summary = $database_notes->getSummary($identifier); $this->assertEquals("umdumisile: Text was changed from \"has given glory\" to \"has glorified\".", $summary); $status = $database_notes->getStatus($identifier); $this->assertEquals("No issue", $status); $data = <<<EOD 731157 Note Author Lev.26.16 Deut.28.22 No issue Ndebele 731157 umdumisile: Text was changed from "has given glory" to "has glorified". Logbook: EOD; file_put_contents($filename, $data); $identifier = Filter_Notes::importFromBibleditGtkFile($filename); $this->note_identifiers[] = $identifier; $passages = $database_notes->getPassages($identifier); $this->assertEquals(array(array(3, 26, 16), array(5, 28, 22)), $passages); $contents = $database_notes->getContents($identifier); $this->assertEquals("umdumisile: Text was changed from \"has given glory\" to \"has glorified\".\n\nLogbook:\n", $contents); // Tear down. unlink($filename); }
$database_logs = Database_Logs::getInstance(); $database_logs->log(Locale_Translate::_("Import consultation notes has started"), true); // Security: Page only runs from the cli SAPI. Filter_Cli::assert(); $folder = Filter_Cli::argument(@$argv, 1); $folder = "{$folder}/data"; $database_logs->log(Locale_Translate::_("Importing from folder:") . " " . $folder, true); $counter = 0; foreach (new DirectoryIterator($folder) as $fileInfo) { if ($fileInfo->isDot()) { continue; } if ($fileInfo->isDir()) { continue; } $counter++; $basename = $fileInfo->getFilename(); $information = Locale_Translate::_("Note") . " " . $basename . " ({$counter}) "; if (is_numeric($basename)) { $path = "{$folder}/{$basename}"; $note_identifier = Filter_Notes::importFromBibleditGtkFile($path); if (is_numeric($note_identifier)) { $database_logs->log($information . Locale_Translate::_("Imported"), true); } else { $database_logs->log($information . Locale_Translate::_("Could not import the note"), true); } } else { $database_logs->log($information . Locale_Translate::_("This is not a note"), true); } } $database_logs->log(Locale_Translate::_("Import consultation notes has finished"), true);