You are here

protected function LocationCCK2Test::addLocationContentType2 in Location 7.3

3 calls to LocationCCK2Test::addLocationContentType2()
LocationCCK2Test::getTestContentName in tests/location_cck2.test
LocationCCK2Test::getTestFieldName in tests/location_cck2.test
LocationCCK2Test::testCCK2 in tests/location_cck2.test

File

tests/location_cck2.test, line 68

Class

LocationCCK2Test

Code

protected function addLocationContentType2(&$settings, $add = array()) {
  if (!self::$name) {
    self::$name = strtolower($this
      ->randomName(8));
    $form = array(
      'name' => self::$name,
      'type' => self::$name,
    );

    // creates content type
    $this
      ->drupalPost('admin/structure/types/add', $form, 'Save content type');
    $this
      ->assertText(t('The content type ' . self::$name . ' has been added'));
    unset($form);
    if (!self::$field_name) {
      self::$field_name = strtolower($this
        ->randomName(8));
      $form = array(
        'fields[_add_new_field][label]' => self::$field_name,
        'fields[_add_new_field][field_name]' => self::$field_name,
        'fields[_add_new_field][type]' => 'location',
        'fields[_add_new_field][widget_type]' => 'location',
      );

      // adds field
      $this
        ->drupalPost('admin/structure/types/manage/' . self::$name . '/fields', $form, t('Save'));
      unset($form);

      // check field defaults
      $form = array();
      $this
        ->drupalPost(NULL, $form, t('Save field settings'));
      unset($form);
      $this
        ->assertText(t('Updated field ' . self::$field_name . ' field settings.'));

      // fills field custom defaults
      $form = array(
        'field_' . self::$field_name . '[und][0][name]' => 'Kyiv',
        'field_' . self::$field_name . '[und][0][country]' => 'ua',
        'field_' . self::$field_name . '[und][0][locpick][user_latitude]' => 50,
        'field_' . self::$field_name . '[und][0][locpick][user_longitude]' => 30,
      );
      $this
        ->drupalPost(NULL, $form, t('Save settings'));
      unset($form);
      $this
        ->assertText(t('Saved ' . self::$field_name . ' configuration.'));
    }
  }
}