diff --git a/location_gmap_find_address/location_gmap_find_address.info b/location_gmap_find_address/location_gmap_find_address.info index 4b70b1d..bcbebe9 100644 --- a/location_gmap_find_address/location_gmap_find_address.info +++ b/location_gmap_find_address/location_gmap_find_address.info @@ -1,6 +1,6 @@ name = Location + Gmap 'Find Address' button description = "Adds a 'Find Address' button to all location fields that use gmap" -version = 7.x-1.2 core = 7.x -dependencies[] = location +package = Location +dependencies[] = location_cck dependencies[] = gmap diff --git a/location_gmap_find_address/location_gmap_find_address.module b/location_gmap_find_address/location_gmap_find_address.module index d13534b..9e5dfdf 100644 --- a/location_gmap_find_address/location_gmap_find_address.module +++ b/location_gmap_find_address/location_gmap_find_address.module @@ -23,7 +23,6 @@ function location_gmap_find_address_form_alter(&$form, &$form_state, $form_id) { * After build event for this form */ function location_gmap_find_address_after_build($form, &$form_state) { - foreach ($form['#location_gmap_find_address_fields'] as $field_name) { $field_instance_count = $form[$field_name]['und']['#max_delta']; for ($i = 0; $i <= $field_instance_count; $i++) { diff --git a/tests/gmap.test b/tests/gmap.test index 07f73a3..ce64866 100644 --- a/tests/gmap.test +++ b/tests/gmap.test @@ -259,3 +259,79 @@ class testGmapTaxonomyFormsTestCase extends DrupalWebTestCase { return (file_exists("../checkout") || file_exists("../site_under_test")); } } + +/** + * WebTest tests for location_gmap_find_address.module. + */ + +class LGFATestCase extends DrupalWebTestCase { + + protected $privileged_user; + + public static function getInfo() { + return array( + 'name' => 'Location Gmap Find Address button checks', + 'description' => 'Test the Location Gmap Find Address button checks.', + 'group' => 'GMap', + ); + } + + public function setUp() { + + parent::setUp('location', 'gmap', 'location_cck', 'field_ui', 'location_gmap_find_address'); + } + + public function testGmapSaveConfig() { + + // login with user + $this->privileged_user = $this->drupalCreateUser(array( + 'administer site configuration', + 'administer content types', + 'bypass node access', + )); + $this->drupalLogin($this->privileged_user); + + // array for form + $edit = array( + 'location_usegmap' => 1, + 'location_default_country' => 'ua', + ); + + // change location default option + $this->drupalPost('admin/config/content/location', $edit, t('Save configuration')); + $this->assertText(t('The configuration options have been saved.')); + + // change gmap API key + // array for form + $edit2 = array( + 'gmap_api_key' => 'AIzaSyAe2PAkh_qvTq-3WkXQrVwVwh3Lo9FDvkk', + ); + + $this->drupalPost('admin/config/services/gmap', $edit2, t('Save configuration')); + $this->assertText(t('The configuration options have been saved.')); + + // add location field to Basic page type + $edit3 = array( + 'fields[_add_new_field][label]' => 'Location', + 'fields[_add_new_field][field_name]' => 'location', + 'fields[_add_new_field][type]' => 'location', + 'fields[_add_new_field][widget_type]' => 'location', + ); + + $this->drupalPost('admin/structure/types/manage/page/fields', $edit3, t('Save')); + $this->assertText(t('These settings apply to the Location field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.')); + + // admin/structure/types/manage/page/fields/field_location + $edit4 = array( + 'field_location[und][0][country]' => 'ua', + 'field[settings][gmap_marker]' => 'small red', + ); + + $this->drupalPost('admin/structure/types/manage/page/fields/field_location', $edit4, t('Save settings')); + $this->assertText(t('Saved Location configuration.')); + + // check $form["#after_build"][] = "location_gmap_find_address_after_build"; + $this->drupalGet('node/add/page'); + $this->assertText(t('Find Address on Map')); + } +}