/** * Set ups up for each test. * * @return void * @author Eric Rochester <*****@*****.**> **/ public function setUp() { parent::setUp(); $this->_todel = array(); $this->user = $this->db->getTable('user')->find(1); $this->_authenticateUser($this->user); $this->phelper = new Omeka_Test_Helper_Plugin(); $this->phelper->setUp('NeatlineFeatures'); $this->_dbHelper = Omeka_Test_Helper_Db::factory($this->application); // Retrieve the element for some DC fields. $el_table = get_db()->getTable('Element'); $this->_title = $el_table->findByElementSetNameAndElementName('Dublin Core', 'Title'); $this->_subject = $el_table->findByElementSetNameAndElementName('Dublin Core', 'Subject'); $this->_coverage = $el_table->findByElementSetNameAndElementName('Dublin Core', 'Coverage'); $this->_cutil = new NeatlineFeatures_Utils_View(); $this->_cutil->setEditOptions(null, $this->_coverage, "", "Elements[38][0]", 0); $this->_item = new Item(); $this->_item->save(); $this->toDelete($this->_item); $t1 = $this->addElementText($this->_item, $this->_title, '<b>A Title</b>', 1); $t2 = $this->addElementText($this->_item, $this->_subject, 'Subject'); $this->toDelete($t1); $this->toDelete($t2); $this->_item->save(); }
/** * This tests that we can iterate over mixed coverages. * * This is a work-around for this spec no longer working, due to O2's * popping up a new window when you click "View Public Page." Technically, * this test should have been a unittest all along, but having it as a * feature keep the planning cleaner. * * @kml * @file_fixture @javascript * Scenario: Mixed Feature Coverages * Given I am logged into the admin console * And I replace "themes/default/items/show.php" with "plugins/NeatlineFeatures/features/data/show-display-coverage-test.php" * And I click "Add a new item" * And I enter "Cucumber: Test Iterate Mixed Feature Coverages" for the "Elements-50-0-text" # Title * And I enter "Iterate Mixed Feature Coverages" for the "Elements-49-0-text" # Subject * And I click "Use Map" checkbox in "#Elements-38-0-widget" * And I draw a line on "div#Elements-38-0-map.olMap" * And I click "add_element_38" * And I wait 15 seconds * And I enter "UVa" into "Elements-38-1-free" * And I click on "Add Item" * And I click "Test Iterate Mixed Feature Coverages" * When I click "View Public Page" * Then I should see the following output in unordered list "#item-coverage": * | true | * | false | * * @return void * @author Eric Rochester **/ public function testTestMixedFeatureCoverage() { $table = $this->db->getTable('NeatlineFeature'); $utils = new NeatlineFeatures_Utils_View(); $utils->setCoverageElement(); $item = new Item(); $item->save(); $this->toDelete($item); $this->_addElementTextDelete($item, $this->_title, "Unittest: Display All Feature Coverages", 1); $this->_addFeature($utils, $table, $item, "<kml xmlns=\"http://earth.google.com/kml/2.0\"><Folder><name>OpenLayers export</name><description>Exported on Thu Mar 07 2013 11:18:43 GMT-0500 (EST)</description><Placemark><name>OpenLayers.Feature.Vector_158</name><description>No description available</description><Polygon><outerBoundaryIs><LinearRing><coordinates>-10194865.083145,4313188.6314755 -9803507.4983789,3295658.9110849 -9744803.8606641,5017632.2840536 -10194865.083145,4313188.6314755</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>OpenLayers.Feature.Vector_182</name><description>No description available</description><LineString><coordinates>-8003262.6084573,5487261.3857724 -10097025.686953,6269976.5553037 -10958012.373438,4724114.0954794</coordinates></LineString></Placemark><Placemark><name>OpenLayers.Feature.Vector_194</name><description>No description available</description><LineString><coordinates>-10958012.373438,4724114.0954794 -10488383.271719,3119547.9979404</coordinates></LineString></Placemark></Folder></kml>|3|-9490421.4305667|3972279.4853711|osm\ncoverage a", 0); $this->_addElementTextDelete($item, $this->_coverage, "Charlottesville, VA", 1); $this->dispatch('/'); set_current_record('item', $item); $covs = metadata('item', array('Dublin Core', 'Coverage'), array('all' => true, 'no_filter' => true, 'no_escape' => true)); $this->assertCount(2, $covs); $this->assertTrue(NeatlineFeatures_Functions::isKmlCoverage($covs[0])); $this->assertFalse(NeatlineFeatures_Functions::isKmlCoverage($covs[1])); }
/** * This tests updateFeatures. * * @return void * @author Eric Rochester <*****@*****.**> **/ public function testUpdateFeatures() { $utils = new NeatlineFeatures_Utils_View(); $utils->setCoverageElement(); $et_table = $this->db->getTable('ElementText'); $item = new Item(); $item->save(); $this->toDelete($item); // First test with no features. $features = $this->table->updateFeatures($item, array()); $this->assertEmpty($features); // Now test with two features. $this->setupCoverageData($item, "Just Text.", 0, 0); $this->setupCoverageData($item, "WKT: POINT\n\nAnd Text.", 0, 1, 1); $features = $this->table->updateFeatures($item, $utils->getPost()); $this->assertCount(2, $features); $this->assertFalse((bool) $features[0]->is_map); $this->assertEquals("Just Text.", $et_table->find($features[0]->element_text_id)->getText()); $this->assertTrue((bool) $features[1]->is_map); $this->assertEquals("WKT: POINT\n\nAnd Text.", $et_table->find($features[1]->element_text_id)->getText()); // Finally, wipe those out and test with just one feature. $etexts = $et_table->fetchObjects($this->db->select()->from($et_table->getTableName())->where('element_id=?', $this->_coverage->id)->where('record_id=?', $item->id)); foreach ($etexts as $et) { $et->delete(); } $this->setupCoverageData($item, "Other Text.", 0, 0); $this->table->updateFeatures($item, $utils->getPost()); $features = $this->table->getItemFeatures($item); $this->assertCount(1, $features); $this->assertFalse((bool) $features[0]->is_map); $this->assertEquals("Other Text.", $et_table->find($features[0]->element_text_id)->getText()); }
/** * This returns the string to display a coverage field, whether a map or * not. * * @param string $text The original text for the element. * @param Omeka_Record $record The record that this text applies * to. * @param ElementText|NULL $elementText The ElementText record that stores * this text. (This is optional and defaults to NULL.) * * @return string * @author Eric Rochester <*****@*****.**> **/ public static function displayCoverage($text, $record, $elementText = NULL) { $util = new NeatlineFeatures_Utils_View(); $util->setCoverageElement(); $util->setViewOptions($text, $record, $elementText); $output = $util->getView(); return $output; }
/** * This overrides the definition for the coverage form input. * * @param string $html An empty string. * @param string $inputNameStem The stem of the input name. * @param string $value The initial value for the input. * @param array $options Additional options. * @param Omeka_Record $record The element's record. * @param Element $element The Element. * * @return string The string containing the HTML for the customized element * form. * @author Eric Rochester <*****@*****.**> **/ public function filterInputItemDublinCoreCoverage($components, $args) { // $args keys => input_name_stem, value, record, element, index, is_html $util = new NeatlineFeatures_Utils_View(); $util->setEditOptions($args['record'], $args['element'], $args['value'], $args['input_name_stem'], $args['index']); // Default $components['inputs']: // <div class="input-block"><div class="input"><textarea name="Elements[38][0][text]" id="Elements-38-0-text" rows="3" cols="50"></textarea></div><div class="controls"><input type="submit" name="" value="Remove" class="remove-element red button"></div><label class="use-html">Use HTML<input type="hidden" name="Elements[38][0][html]" value="0"><input type="checkbox" name="Elements[38][0][html]" id="Elements-38-0-html" value="1" class="use-html-checkbox"></label></div> $components['input'] = $util->getEditControl(); return $components; }