function testRenderAsListItemEdit_DESCRIPTION() { $pe = Authoritative_Plant_Extra::getOneFromDb(['authoritative_plant_extra_id' => 5104], $this->DB); $canonical = ''; $canonical .= '<li id="authoritative_plant_extra_5104" class="authoritative-plant-extra-edit authoritative-plant-extra" data-authoritative_plant_extra_id="5104" data-created_at="' . $pe->created_at . '" data-updated_at="' . $pe->updated_at . '" data-authoritative_plant_id="5001" data-type="description" data-value="description of american chestnut" data-ordering="1.00000" data-flag_active="1" data-flag_delete="0">' . "\n"; $canonical .= ' ' . util_orderingUpDownControls('authoritative_plant_extra_5104') . "\n"; $canonical .= ' <div class="authoritative-plant-extra embedded">' . "\n"; $canonical .= ' <div id="form-edit-authoritative-plant-extra-5104" class="form-edit-authoritative-plant-extra" data-authoritative_plant_extra_id="5104">' . "\n"; $canonical .= ' <div class="field-label">description : </div><div class="field-value"><input type="text" name="authoritative_plant_extra-description_5104" id="authoritative_plant_extra-description_5104" value="description of american chestnut"/></div>' . "\n"; $canonical .= ' </div>' . "\n"; $canonical .= ' <button class="btn btn-danger button-mark-authoritative-plant-extra-for-delete" title="Mark this for removal - the actual removal occurs on update" data-do-mark-title="Mark this for removal - the actual removal occurs on update" data-remove-mark-title="Undo the mark for removal" data-for_dom_id="authoritative_plant_extra_5104" data-authoritative_plant_extra_id="5104"><i class="icon-remove-sign icon-white"></i></button>' . "\n"; $canonical .= ' </div>' . "\n"; $canonical .= '</li>'; $rendered = $pe->renderAsListItemEdit(); // echo "<pre>\n".htmlentities($canonical)."\n------------------\n".htmlentities($rendered)."\n</pre>"; $this->assertEqual($canonical, $rendered); }
// images can only be added and removed - not edited/modified $req_ape_value = trim($_REQUEST['authoritative_plant_extra_' . $db_ape->authoritative_plant_extra_id . '-value']); if ($db_ape->value != $req_ape_value) { $db_ape->value = $req_ape_value; $db_ape->updateDb(); } } } // new ones $created_authoritative_plant_extra_ids = explode(',', $_REQUEST['created_authoritative_plant_extra_ids']); foreach ($created_authoritative_plant_extra_ids as $created_authoritative_plant_extra_id) { if ($created_authoritative_plant_extra_id) { // echo "handling auth plant extra creation for $created_authoritative_plant_extra_id<br/>\n"; // util_prePrintR($_REQUEST); $new_ape_type = 'authoritative_plant_extra_' . $created_authoritative_plant_extra_id . '-type'; $new_ape = Authoritative_Plant_Extra::createNewAuthoritativePlantExtraFor($new_ape_type, $ap->authoritative_plant_id, $DB); $new_ape->notebook_page_field_id = $created_authoritative_plant_extra_id; $new_ape->setFromArray($_REQUEST); if ($new_ape->value != false) { $new_ape->authoritative_plant_extra_id = 'NEW'; $new_ape->updateDb(); } } } ///////////////////// // third, any specimens // deleted $deleted_specimen_ids = explode(',', $_REQUEST['deleted_specimen_ids']); if ($deleted_specimen_ids) { foreach ($deleted_specimen_ids as $deleted_specimen_id) { if ($deleted_specimen_id) {
public function loadExtras() { $this->extras = Authoritative_Plant_Extra::getAllFromDb(['authoritative_plant_id' => $this->authoritative_plant_id, 'flag_delete' => FALSE], $this->dbConnection); usort($this->extras, 'Authoritative_Plant_Extra::cmp'); }
function testBaseDataUpdate() { $this->doLoginAdmin(); $this->get('http://localhost/digitalfieldnotebooks/app_code/authoritative_plant.php?action=edit&authoritative_plant_id=5001'); $this->checkBasicAsserts(); /////////////////////////////// //// set form fields ////// NOTE: the identifier to use for setField is the value of the name attribute of the field $this->assertTrue($this->setField('authoritative_plant-class_5001', '')); $this->assertTrue($this->setField('authoritative_plant-order_5001', 'neworder')); $this->assertTrue($this->setField('authoritative_plant-species_5001', 'newspecies')); // // alter common name $this->assertTrue($this->setField('authoritative_plant_extra_5103-value', 'altered common name')); // // alter description $this->assertTrue($this->setField('authoritative_plant_extra_5104-value', 'altered description')); // // alter specimen $this->assertTrue($this->setField('specimen-name_8001', 'altered specimen name')); // JS-driven - can't test here // $this->todo('add new APE'); // $this->todo('delete existing APE'); // // $this->todo('add new specimen'); // $this->todo('delete specimen'); // $this->showContent(); // exit; //// NOTE: the identifier to use for buttons is the value of the value attribute of the button /////////////////////////////// //// submit the form $this->click('<i class="icon-ok-sign icon-white"></i> ' . util_lang('update', 'properize')); // $this->showContent(); // exit; //// /////////////////////////////// //// check the resulting page $this->checkBasicAsserts(); $this->assertNoText('class :'); $this->assertText('neworder'); $this->assertText('newspecies'); $this->assertText('altered common name'); $this->assertText('altered description'); $this->assertText('altered specimen name'); // JS-driven - can't test here // $this->todo('web - check add new APE'); // $this->todo('web - check delete existing APE'); // $this->todo('web - add new specimen'); // $this->todo('web - delete specimen'); /////////////////////////////// //// check the db records $ap = Authoritative_Plant::getOneFromDb(['authoritative_plant_id' => 5001], $this->DB); $this->assertEqual($ap->class, ''); $this->assertEqual($ap->order, 'neworder'); $this->assertEqual($ap->genus, 'AP_A_genus'); $this->assertEqual($ap->species, 'newspecies'); $apeCN = Authoritative_Plant_Extra::getOneFromDb(['authoritative_plant_extra_id' => 5103], $this->DB); $apeDe = Authoritative_Plant_Extra::getOneFromDb(['authoritative_plant_extra_id' => 5104], $this->DB); $spec = Specimen::getOneFromDb(['specimen_id' => 8001], $this->DB); $this->assertEqual('altered common name', $apeCN->value); $this->assertEqual('altered description', $apeDe->value); $this->assertEqual('altered specimen name', $spec->name); // JS-driven - can't test here // $this->todo('db - check add new APE'); // $this->todo('db - check delete existing APE'); // $this->todo('db - add new specimen'); // $this->todo('db - delete specimen'); }