function SmartIPViewsBridgeFunctionalTestCase::testViewsEdit in Smart IP 7.2
Basic functional testing of Smart IP Views Bridge at Views edit page.
File
- modules/
smart_ip_views_bridge/ tests/ smart_ip_views_bridge.test, line 162 - Functionality tests for Smart IP Views Bridge.
Class
- SmartIPViewsBridgeFunctionalTestCase
- Test basic Smart IP Views Bridge functionality.
Code
function testViewsEdit() {
$this
->drupalGet('admin/structure/views/add');
$new_views_info = array(
'human_name' => t('Smart IP'),
'name' => 'smart_ip',
'page[create]' => FALSE,
'block[create]' => TRUE,
'block[title]' => t('Sample Smart IP Views Block'),
);
$this
->drupalPost(NULL, $new_views_info, t('Continue & edit'));
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->assertText(t('Smart IP: City'));
$this
->assertText(t('Smart IP: Coordinates'));
$this
->assertText(t('Smart IP: Country'));
$this
->assertText(t('Smart IP: Latitude'));
$this
->assertText(t('Smart IP: Longitude'));
$this
->assertText(t('Smart IP: Region'));
$this
->assertText(t('Smart IP: ZIP code'));
$fields_items = array(
'name[smartip.coordinates]' => TRUE,
'name[smartip.latitude]' => TRUE,
'name[smartip.longitude]' => TRUE,
'name[smartip.country]' => TRUE,
'name[smartip.region]' => TRUE,
);
// Add Smart IP Coordinates field
$this
->drupalPost(NULL, array(
'name[smartip.coordinates]' => TRUE,
), t('Add and configure fields'));
$this
->assertText(t('Decimal degrees format'));
$this
->assertText(t('Degrees, minutes, seconds format'));
$this
->drupalPost(NULL, array(
'options[style]' => 'dms',
'options[label]' => t('Your Coordinates'),
), t('Apply'));
// Add Smart IP Latitude field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.latitude]' => TRUE,
), t('Add and configure fields'));
$this
->assertText(t('Decimal degrees format'));
$this
->assertText(t('Degrees, minutes, seconds format'));
$this
->drupalPost(NULL, array(
'options[label]' => t('Your Latitude'),
), t('Apply'));
// Add Smart IP Longitude field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.longitude]' => TRUE,
), t('Add and configure fields'));
$this
->assertText(t('Decimal degrees format'));
$this
->assertText(t('Degrees, minutes, seconds format'));
$this
->drupalPost(NULL, array(
'options[label]' => t('Your Longitude'),
), t('Apply'));
// Add Smart IP Country field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.country]' => TRUE,
), t('Add and configure fields'));
$this
->assertText(t('Country name'));
$this
->assertText(t('ISO 3166 2-character country code'));
$this
->drupalPost(NULL, array(
'options[label]' => t('Your Country'),
), t('Apply'));
// Add Smart IP Country code field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.country]' => TRUE,
), t('Add and configure fields'));
$this
->drupalPost(NULL, array(
'options[style]' => 'code',
'options[label]' => t('Your Country code'),
), t('Apply'));
// Add Smart IP Region field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.region]' => TRUE,
), t('Add and configure fields'));
$this
->assertText(t('Region name'));
$this
->assertText(t('Region code (FIPS)'));
$this
->drupalPost(NULL, array(
'options[label]' => t('Your Region'),
), t('Apply'));
// Add Smart IP Region code field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.region]' => TRUE,
), t('Add and configure fields'));
$this
->drupalPost(NULL, array(
'options[style]' => 'code',
'options[label]' => t('Your Region code'),
), t('Apply'));
// Add Smart IP City field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.city]' => TRUE,
), t('Add and configure fields'));
$this
->drupalPost(NULL, array(
'options[label]' => t('Your City'),
), t('Apply'));
// Add Smart IP ZIP code field
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/field');
$this
->drupalPost(NULL, array(
'name[smartip.zip]' => TRUE,
), t('Add and configure fields'));
$this
->drupalPost(NULL, array(
'options[label]' => t('Your ZIP code'),
), t('Apply'));
// Add Smart IP Country Views filters
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/filter');
$this
->drupalPost(NULL, array(
'name[field_data_field_country.field_country_value]' => TRUE,
), t('Add and configure filter criteria'));
$this
->assertText(t("Smart IP: visitor's country"));
$this
->assertText(t("Smart IP: visitor's country code"));
$this
->assertText(t("Smart IP: visitor's region"));
$this
->assertText(t("Smart IP: visitor's region code"));
$this
->assertText(t("Smart IP: visitor's city"));
$this
->assertText(t("Smart IP: visitor's zip"));
$this
->drupalPost(NULL, array(
'options[operator]' => 'in',
'options[value][smart_ip.location.country_code]' => TRUE,
), t('Apply'));
// Add Smart IP City Views filters
$this
->drupalGet('admin/structure/views/nojs/add-item/smart_ip/block/filter');
$this
->drupalPost(NULL, array(
'name[field_data_field_city.field_city_value]' => TRUE,
), t('Add and configure filter criteria'));
$this
->assertText('smart_ip][location][country');
$this
->assertText('smart_ip][location][country_code');
$this
->assertText('smart_ip][location][region');
$this
->assertText('smart_ip][location][region_code');
$this
->assertText('smart_ip][location][city');
$this
->assertText('smart_ip][location][zip');
$this
->drupalPost(NULL, array(
'options[operator]' => '=',
'options[value]' => 'smart_ip][location][city',
), t('Apply'));
// Save the Views block
$this
->drupalGet('admin/structure/views/view/smart_ip/edit');
$this
->drupalPost(NULL, array(), t('Save'));
// Enable the Views block
$this
->drupalGet('admin/structure/block');
$this
->drupalPost(NULL, array(
'blocks[views_smart_ip-block][region]' => 'sidebar_first',
'blocks[device_geolocation_visitor_geolocation][region]' => 'sidebar_second',
), t('Save blocks'));
$this
->drupalGet('node');
}