You are here

class OpenLayersCCKWidgetTest in Openlayers 6.2

OpenLayers Test Class

Hierarchy

Expanded class hierarchy of OpenLayersCCKWidgetTest

File

modules/openlayers_cck/tests/openlayers_cck.test, line 16
OpenLayers CCK tests

View source
class OpenLayersCCKWidgetTest extends ContentCrudTestCase {
  function getInfo() {
    return array(
      'name' => t('OpenLayers CCK widget'),
      'description' => t('Tests the OpenLayers CCK Widget.'),
      'group' => t('OpenLayers'),
    );
  }
  function setUp() {

    // Note that the CRUD testing for CCK assumes the following modules
    // as well as these: content, text, schema
    // Often one does not have schema available and exceptions will happen.
    parent::setUp('ctools', 'openlayers', 'openlayers_cck');
    $this
      ->loginWithPermissions();
    $this
      ->acquireContentTypes(1);
    module_load_include('inc', 'cck', 'tests/content.crud.test');
  }

  /**
   * OpenLayers CCK Widget
   */
  function testOpenLayersCCK() {
    $type = $this->content_types[0];
    $type_url = str_replace('_', '-', $type->type);
    $settings = array(
      'type' => 'openlayers_wkt',
      'widget_type' => 'openlayers_wkt_widget',
    );
    $field = $this
      ->createField($settings, 0);
    $field_name = $field['field_name'];

    // Create a node with the checkbox on.
    $edit = array(
      'title' => $this
        ->randomName(20),
      'body' => $this
        ->randomName(20),
      $field_name . '[openlayers_wkt]' => 'POINT(1 1)',
    );
    $this
      ->drupalPost('node/add/' . $type_url, $edit, 'Save');
    $node = node_load(array(
      'title' => $edit['title'],
    ));
    $this
      ->assertEqual($node->{$field_name}[0]['openlayers_wkt'], 'POINT(1 1)', 'Point: saved in the correct place');
    $this
      ->drupalGet('node/' . $node->nid);

    // Edit the node and uncheck the box.
    $edit = array(
      $field_name . '[openlayers_wkt]' => 'POINT(4 4)',
    );
    $this
      ->drupalPost('node/' . $node->nid . '/edit', $edit, 'Save');
    $node = node_load($node->nid, NULL, TRUE);
    $this
      ->drupalGet('node/' . $node->nid);
  }

}

Members