function testNewPageFieldForm() { $this->doLoginBasic(); global $DB; $DB = $this->DB; $this->get('http://localhost/digitalfieldnotebooks/ajax_actions/notebook_page_field.php?action=create&unique=ABC123¬ebook_page_id=1101'); $this->checkBasicAsserts(); $expected = Notebook_Page_Field::renderFormInteriorForNewNotebookPageField('ABC123'); $results = json_decode($this->getBrowser()->getContent()); $this->assertEqual('success', $results->status); $this->assertEqual($expected, $results->html_output); }
$new_term_value_id = 0; } $new_npf_vals['notebook_page_field-value_metadata_term_value_id_' . $notebook_page_field_id] = $new_term_value_id; } $npf->setFromArray($new_npf_vals); $npf->updateDb(); } } } $created_notebook_page_field_ids = explode(',', $_REQUEST['created_page_field_ids']); foreach ($created_notebook_page_field_ids as $created_page_field_id) { // echo "TO BE IMPLEMENTED: handle creation of new notebook page fields"; if ($created_page_field_id) { // echo "handling page field creation for $created_page_field_id<br/>\n"; // util_prePrintR($_REQUEST); $new_npf = Notebook_Page_Field::createNewNotebookPageFieldForNotebookPage($notebook_page->notebook_page_id, $DB); $new_npf->notebook_page_field_id = $created_page_field_id; $new_npf->setFromArray($_REQUEST); if ($new_npf->label_metadata_structure_id != 0) { $new_npf->notebook_page_field_id = 'NEW'; $new_npf->updateDb(); } } } $deleted_specimen_ids = explode(',', $_REQUEST['deleted_specimen_ids']); // util_prePrintR($deleted_specimen_ids); if ($deleted_specimen_ids) { foreach ($deleted_specimen_ids as $deleted_specimen_id) { // util_prePrintR("handling $deleted_specimen_id\n"); if ($deleted_specimen_id) { // util_prePrintR("fetching for delete $deleted_specimen_id\n");
function testBaseDataUpdate() { $this->doLoginBasic(); $this->get('http://localhost/digitalfieldnotebooks/app_code/notebook_page.php?action=edit¬ebook_page_id=1101'); $this->checkBasicAsserts(); $new_notes = 'new notes for the page'; $new_specimen_notes = 'new notes for the specimen'; //// NOTE: the identifier to use for setField is the value of the name attribute of the field $this->setField('notes', $new_notes); // page field alteration $this->assertTrue($this->setField('page_field_select_1201', '6204')); $this->assertTrue($this->setField('page_field_open_value_1204', 'new open value')); // page field addition // $this->todo('figure out how to do page field addition'); // $this->todo('figure out how to do page deletion'); // specimen alteration $this->assertTrue($this->setField('specimen-notes_8002', $new_specimen_notes)); // $this->todo('figure out how to do specimen addition'); // $this->todo('figure out how to do specimen deletion'); // $this->showContent(); //// NOTE: the identifier to use for buttons is the value of the value attribute of the button $this->click('<i class="icon-ok-sign icon-white"></i> ' . util_lang('update', 'properize')); // // $this->showContent(); // $this->checkBasicAsserts(); $this->assertText($new_notes); // $np = Notebook_Page::getOneFromDb(['notebook_page_id' => 1101], $this->DB); $this->assertEqual($np->notes, $new_notes); // $this->todo('check page field alteration on 1201'); $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1201], $this->DB); $this->assertEqual($npf->value_metadata_term_value_id, 6204); $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1204], $this->DB); $this->assertEqual($npf->value_open, 'new open value'); // $this->todo('check page field addition'); // $this->todo('check page field deletion'); // $this->todo('check specimen alteration on 8002'); $s = Specimen::getOneFromDb(['specimen_id' => 8002], $this->DB); $this->assertEqual($s->notes, $new_specimen_notes); // $this->todo('check specimen addition'); // $this->todo('check specimen deletion'); // util_prePrintR(htmlentities($this->getBrowser()->getContent())); echo "<br><b>NOTE: skipping create and delete tests for pagefields and specimens because that requires javascript interaction</b><br/>\n"; }
public function loadPageFields() { $this->page_fields = Notebook_Page_Field::getAllFromDb(['notebook_page_id' => $this->notebook_page_id, 'flag_delete' => FALSE], $this->dbConnection); usort($this->page_fields, 'Notebook_Page_Field::cmp'); }
function testRenderAsListItemEdit_noTermSet() { $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1204], $this->DB); $mds = Metadata_Structure::getOneFromDb(['metadata_structure_id' => 6004], $this->DB); global $USER; $USER = User::getOneFromDb(['username' => TESTINGUSER], $this->DB); $canonical = '<li id="list_item-notebook_page_field_1204" data-notebook_page_field_id="1204" data-created_at="' . $npf->created_at . '" data-updated_at="' . $npf->updated_at . '" data-notebook_page_id="1101" data-label_metadata_structure_id="6004" data-value_metadata_term_value_id="0" data-value_open="wavy-ish" data-flag_delete="0">' . '<div class="notebook-page-field-label field-label" title="' . htmlentities($mds->description) . '">' . $mds->renderAsFullName() . '</div> : <div class="notebook-page-field-value field-value">' . util_lang('metadata_structure_has_no_term_set') . '; <input type="text" name="page_field_open_value_1204" id="page_field_open_value_1204" class="page_field_open_value" value="wavy-ish"/>' . '</div> <button class="btn btn-danger button-mark-pagefield-for-delete" title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-do-mark-title="' . util_lang('mark_for_delete', 'ucfirst') . '" data-remove-mark-title="' . util_lang('unmark_for_delete', 'ucfirst') . '" data-for_dom_id="list_item-notebook_page_field_1204" data-notebook_page_field_id="1204"><i class="icon-remove-sign icon-white"></i></button></li>'; $rendered = $npf->renderAsListItemEdit(); // echo "<pre>\n".htmlentities($canonical)."\n--------\n".htmlentities($rendered)."\n</pre>"; $this->assertEqual($canonical, $rendered); $this->assertNoPattern('/IMPLEMENTED/', $rendered); }
foreach ($USER->cached_role_action_targets_hash_by_target_type_by_id['global_notebook'] as $glob_rat) { if ($glob_rat->action_id == $ACTIONS['create']->action_id || $glob_rat->action_id == $ACTIONS['edit']->action_id) { $has_permission = true; break; } } } // and if not that, then check specific perms if (!$has_permission) { $notebook_page = Notebook_Page::getOneFromDb(['notebook_page_id' => $notebook_page_id], $DB); if (!$notebook_page->matchesDb) { $results['note'] = util_lang('msg_record_missing') . ' : notebook_page ' . htmlentities($notebook_page_id); echo json_encode($results); exit; } $has_permission = $USER->canActOnTarget($ACTIONS['edit'], $notebook_page); } } if (!$has_permission) { $results['note'] = util_lang('no_permission'); echo json_encode($results); exit; } # 3. branch behavior based on the action # create - return an appropriate form field set if ($has_permission && $action == 'create') { $results['html_output'] = Notebook_Page_Field::renderFormInteriorForNewNotebookPageField($unique_str); $results['status'] = 'success'; } echo json_encode($results); exit;
function testDoDelete() { $np = Notebook_Page::getOneFromDb(['notebook_page_id' => 1101], $this->DB); $np->loadSpecimens(); $np->loadPageFields(); $this->assertTrue($np->matchesDb); $this->assertTrue($np->page_fields[0]->matchesDb); $this->assertTrue($np->page_fields[1]->matchesDb); $this->assertTrue($np->page_fields[2]->matchesDb); $this->assertTrue($np->page_fields[3]->matchesDb); $this->assertTrue($np->specimens[0]->matchesDb); $this->assertTrue($np->specimens[1]->matchesDb); //*********** $np->doDelete(); //*********** $np2 = Notebook_Page::createNewNotebookPageForNotebook(1001, $this->DB); $this->assertFalse($np2->matchesDb); $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1201], $this->DB); $this->assertFalse($npf->matchesDb); $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1202], $this->DB); $this->assertFalse($npf->matchesDb); $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1203], $this->DB); $this->assertFalse($npf->matchesDb); $npf = Notebook_Page_Field::getOneFromDb(['notebook_page_field_id' => 1204], $this->DB); $this->assertFalse($npf->matchesDb); $s = Specimen::getOneFromDb(['specimen_id' => 8002], $this->DB); $this->assertFalse($s->matchesDb); $s = Specimen::getOneFromDb(['specimen_id' => 8003], $this->DB); $this->assertFalse($s->matchesDb); $si = Specimen_Image::getOneFromDb(['specimen_image_id' => 8103], $this->DB); $this->assertFalse($si->matchesDb); $si = Specimen_Image::getOneFromDb(['specimen_image_id' => 8104], $this->DB); $this->assertFalse($si->matchesDb); }