geofield.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @file
  4. * Tests for geofield.module.
  5. */
  6. class GeoFieldTestCase extends DrupalWebTestCase {
  7. public static function getInfo() {
  8. return array(
  9. 'name' => 'Geofield',
  10. 'description' => "Test the creation of geofields.",
  11. 'group' => 'Field types'
  12. );
  13. }
  14. function setUp() {
  15. parent::setUp(array('geofield', 'field_test'));
  16. $this->admin_user = $this->drupalCreateUser(array('administer filters'));
  17. $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer modules'));
  18. $this->drupalLogin($this->web_user);
  19. }
  20. // Test fields.
  21. /**
  22. * Test widgets.
  23. */
  24. function testGeofieldWidgets() {
  25. $this->_testGeofieldWidgets('geofield_wkt');
  26. }
  27. /**
  28. * Helper function for testGeofieldWidgets().
  29. */
  30. function _testGeofieldWidgets($widget_type) {
  31. // Setup a field and instance
  32. $entity_type = 'test_entity';
  33. $this->field_name = drupal_strtolower($this->randomName());
  34. $this->field = array('field_name' => $this->field_name, 'type' => 'geofield');
  35. field_create_field($this->field);
  36. $this->instance = array(
  37. 'field_name' => $this->field_name,
  38. 'entity_type' => 'test_entity',
  39. 'bundle' => 'test_bundle',
  40. 'label' => $this->randomName() . '_label',
  41. 'settings' => array(
  42. ),
  43. 'widget' => array(
  44. 'type' => $widget_type,
  45. ),
  46. 'display' => array(
  47. 'full' => array(
  48. 'type' => 'geofield_wkt',
  49. ),
  50. ),
  51. );
  52. field_create_instance($this->instance);
  53. $langcode = LANGUAGE_NONE;
  54. // Display creation form.
  55. $this->drupalGet('test-entity/add/test-bundle');
  56. $this->assertFieldByName("{$this->field_name}[$langcode][0][wkt]", '', t('Widget is displayed'));
  57. }
  58. }