function OpenLayersLayers::testOpenLayersLayers in Openlayers 6.2
Same name and namespace in other branches
- 7.2 tests/openlayers.test \OpenLayersLayers::testOpenLayersLayers()
File
- tests/
openlayers.test, line 163 - Main OpenLayers Test file
Class
- OpenLayersLayers
- Test OpenLayers layers.
Code
function testOpenLayersLayers() {
$user = $this
->drupalCreateUser(array(
'administer openlayers',
));
$this
->drupalLogin($user);
// New layers to add
$layer_inputs = array(
'openlayers_layer_type_osm' => array(
'name' => 'UnitLayerOSM',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_xyz' => array(
'name' => 'UnitLayerXYZ',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_kml' => array(
'name' => 'UnitLayerKML',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_wms' => array(
'name' => 'UnitLayerWMS',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_cloudmade' => array(
'name' => 'UnitLayerCloudMade',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_yahoo' => array(
'name' => 'UnitLayerYahoo',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_virtualearth' => array(
'name' => 'UnitLayerVirtualEarth',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
'openlayers_layer_type_google' => array(
'name' => 'UnitLayerGoogle',
'title' => 'Unit Layer',
'description' => 'Unit Layer for Drupal',
),
);
// Basic navigation.
$this
->drupalGet('admin/build/openlayers/layers/add');
$this
->assertResponse(200, t('User can reach layer add page.'));
// Go through each new layer for testing.
foreach ($layer_inputs as $layer_type => $input_data) {
// Test saving new layer.
$this
->drupalPost('admin/build/openlayers/layers/add/' . $layer_type, $input_data, t('Save'));
$this
->assertText(t('Layer saved.'), t('The layer was successfully saved.'));
// Ensure that the layer shows up in the list.
$this
->drupalGet('admin/build/openlayers/layers');
$this
->assertRaw($input_data['name'], t('A new layer of layer type %type_name has been added by the test', array(
'%type_name' => $layer_type,
)));
// Test removing layer.
$this
->drupalPost('admin/build/openlayers/layers/' . $input_data['name'] . '/delete', array(), t('Confirm'));
$this
->assertText($input_data['name'] . ' was deleted.', t('Layer removed succesfully.'));
}
}