You are here

class FeedsMapperMultilingualFieldsTestCase in Feeds 7.2

Tests field mapping with multiple languages.

Hierarchy

Expanded class hierarchy of FeedsMapperMultilingualFieldsTestCase

File

tests/feeds_mapper_multilingual_fields.test, line 11
Contains FeedsMapperMultilingualFieldsTestCase.

View source
class FeedsMapperMultilingualFieldsTestCase extends FeedsMapperTestCase {

  /**
   * Name of created content type.
   *
   * @var string
   */
  private $contentType;

  /**
   * @var array
   */
  protected $fields = array();

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return array(
      'name' => 'Mapper: Multilingual fields',
      'description' => 'Tests Feeds multilingual support.',
      'group' => 'Feeds',
      'dependencies' => array(
        'date',
        'entity_translation',
        'i18n_taxonomy',
        'link',
      ),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    $modules = array(
      'locale',
      'entity_translation',
      'date',
      'link',
      'list',
      'number',
    );
    $permissions = array(
      'administer entity translation',
      'translate any entity',
      'administer languages',
    );
    parent::setUp($modules, $permissions);

    // Include FeedsProcessor.inc so processor related constants are available.
    module_load_include('inc', 'feeds', 'plugins/FeedsProcessor');

    // Add French language.
    $this
      ->addLanguage('fr', 'French');

    // Add Categories vocabulary.
    $edit = array(
      'name' => 'Categories',
      'machine_name' => 'categories',
    );
    $this
      ->drupalPost('admin/structure/taxonomy/add', $edit, 'Save');

    // Create content type.
    $this->fields = array(
      'date' => array(
        'type' => 'date',
        'settings' => array(
          'field[settings][granularity][hour]' => FALSE,
          'field[settings][granularity][minute]' => FALSE,
          'field[settings][tz_handling]' => 'none',
        ),
      ),
      'datestamp' => array(
        'type' => 'datestamp',
        'settings' => array(
          'field[settings][granularity][second]' => TRUE,
          'field[settings][tz_handling]' => 'utc',
        ),
      ),
      'datetime' => array(
        'type' => 'datetime',
        'settings' => array(
          'field[settings][granularity][second]' => TRUE,
          'field[settings][tz_handling]' => 'utc',
        ),
      ),
      'image' => array(
        'type' => 'image',
        'instance_settings' => array(
          'instance[settings][alt_field]' => 1,
          'instance[settings][title_field]' => 1,
        ),
      ),
      'link' => 'link_field',
      'list_boolean' => 'list_boolean',
      'number_integer' => 'number_integer',
      'number_decimal' => 'number_decimal',
      'number_float' => 'number_float',
      'text' => 'text',
    );
    $this->contentType = $this
      ->createContentType(array(), $this->fields);

    // Create term reference field.
    $field = array(
      'field_name' => 'field_category',
      'type' => 'taxonomy_term_reference',
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
      'settings' => array(
        'allowed_values' => array(
          array(
            'vocabulary' => 'categories',
            'parent' => 0,
          ),
        ),
      ),
    );
    field_create_field($field);

    // Add term reference field to article bundle.
    $this->instance = array(
      'field_name' => 'field_category',
      'bundle' => $this->contentType,
      'entity_type' => 'node',
      'widget' => array(
        'type' => 'taxonomy_autocomplete',
      ),
      'display' => array(
        'default' => array(
          'type' => 'taxonomy_term_reference_link',
        ),
      ),
    );
    field_create_instance($this->instance);

    // Make content type and fields multilingual.
    $field_names = array(
      'body',
      'field_category',
    );
    foreach ($this->fields as $field_name => $field_type) {
      $field_names[] = 'field_' . $field_name;
    }
    $this
      ->setupMultilingual($this->contentType, $field_names);

    // Copy directory of source files, CSV file expects them in public://images.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', 'public://images');

    // Create an importer configuration with basic mapping.
    $this
      ->createImporterConfiguration('Test multilingual fields import from CSV', 'node');
    $this
      ->setPlugin('node', 'FeedsCSVParser');
    $this
      ->setPlugin('node', 'FeedsFileFetcher');
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'bundle' => $this->contentType,
      'language' => 'en',
    ));

    // Add language neutral mappings.
    $this
      ->addMappings('node', array(
      0 => array(
        'source' => 'guid',
        'target' => 'guid',
        'unique' => 1,
      ),
      1 => array(
        'source' => 'title',
        'target' => 'title',
      ),
    ));
  }

  /**
   * Tests multilingual mappings to translatable fields (entity translation).
   */
  public function testMultilingualFieldMappings() {

    // Add English mappers.
    $index = 2;
    $mappings = $this
      ->getMappingsInLanguage('en', $index);

    // Append "_en" to each source name.
    foreach ($mappings as &$mapping) {
      $mapping['source'] .= '_en';
    }
    $this
      ->addMappings('node', $mappings);
    $index += count($mappings);

    // Add French mappers.
    $mappings = $this
      ->getMappingsInLanguage('fr', $index);

    // Append "_fr" to each source name.
    foreach ($mappings as &$mapping) {
      $mapping['source'] .= '_fr';
    }
    $this
      ->addMappings('node', $mappings);

    // Import file that has items with both English and French field values.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_en_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Load node.
    $node = node_load(1, NULL, TRUE);

    // Inspect availability of English values.
    $english = $this
      ->getEnglishValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['en'][0]['tid'],
      ),
    );
    foreach ($english as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The English field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }

    // Inspect availability of French values.
    $french = $this
      ->getFrenchValues($node) + array(
      'field_category' => array(
        'expected' => 2,
        'actual' => $node->field_category['fr'][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The French field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if values of fields in other languages are kept when not importing
   * in that language.
   */
  public function testChangedLanguageImport() {

    // Add Dutch language.
    $this
      ->addLanguage('nl', 'Dutch');

    // Import an item first in the Dutch language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'nl',
    ));
    $mappings = $this
      ->getMappingsInLanguage('nl', 2);
    $this
      ->addMappings('node', $mappings);
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_nl.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Assert that Dutch values were created.
    $node = node_load(1, NULL, TRUE);
    $dutch = $this
      ->getDutchValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['nl'][0]['tid'],
      ),
    );
    foreach ($dutch as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The Dutch field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }

    // Set import to update existing nodes.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'update_existing' => FEEDS_UPDATE_EXISTING,
    ));

    // Change mappers language to French.
    $path = 'admin/structure/feeds/node/mapping';
    foreach ($mappings as $i => $mapping) {
      $this
        ->drupalPostAJAX($path, array(), 'mapping_settings_edit_' . $i);
      $edit = array(
        "config[{$i}][settings][field_language]" => 'fr',
      );
      $this
        ->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_' . $i);
      $this
        ->drupalPost(NULL, array(), t('Save'));
    }

    // Import French item.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Updated 1 node'));

    // Assert that French values were created.
    $node = node_load(1, NULL, TRUE);
    $french = $this
      ->getFrenchValues($node) + array(
      'field_category' => array(
        'expected' => 2,
        'actual' => $node->field_category['fr'][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The French field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }

    // Assert that Dutch values still exist.
    $dutch = $this
      ->getDutchValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['nl'][0]['tid'],
      ),
    );
    foreach ($dutch as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The Dutch field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if values of fields in other languages are kept when not importing
   * in that language for nodes that were not created by Feeds.
   */
  public function testChangedLanguageImportForExistingNode() {

    // Add Dutch language.
    $this
      ->addLanguage('nl', 'Dutch');

    // Date settings.
    foreach (array(
      'datestamp',
      'datetime',
    ) as $field) {
      $field = 'field_' . $field;
      $edit = array(
        'field[settings][granularity][second]' => 1,
      );
      $this
        ->drupalPost('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field . '/field-settings', $edit, 'Save field settings');
    }

    // Hack to get date fields to not round to every 15 seconds.
    foreach (array(
      'date',
      'datestamp',
      'datetime',
    ) as $field) {
      $field = 'field_' . $field;
      $edit = array(
        'widget_type' => 'date_select',
      );
      $this
        ->drupalPost('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field . '/widget-type', $edit, 'Continue');
      $edit = array(
        'instance[widget][settings][increment]' => 1,
        'field[settings][enddate_get]' => 1,
      );
      $this
        ->drupalPost('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field, $edit, 'Save settings');
      $edit = array(
        'widget_type' => 'date_text',
      );
      $this
        ->drupalPost('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field . '/widget-type', $edit, 'Continue');
    }

    // Create a node with Dutch values (except for the title, which is used as
    // unique target).
    $edit = array(
      'title' => 'Teste Feeds Multilingue 1',
      'language' => 'nl',
    );
    $this
      ->drupalPost('node/add/' . $this->contentType, $edit, t('Save'));

    // Add values for Dutch fields.
    $edit = array(
      'body[nl][0][value]' => 'Dit is de berichttekst',
      'field_date[nl][0][value][date]' => '07/29/1985',
      'field_datestamp[nl][0][value][date]' => '07/29/1985 - 04:48:12',
      'field_datetime[nl][0][value][date]' => '07/29/1985 - 04:48:12',
      'field_link[nl][0][url]' => 'http://google.nl',
      'field_list_boolean[nl]' => '1',
      'field_number_decimal[nl][0][value]' => '30.3',
      'field_number_float[nl][0][value]' => '30.2795',
      'field_number_integer[nl][0][value]' => '30',
      'field_text[nl][0][value]' => 'Wortelen',
      'files[field_image_nl_0]' => drupal_realpath('public://images/attersee.jpeg'),
      'field_category[nl]' => 'Nieuws',
    );
    $this
      ->drupalPost('node/1/edit/nl', $edit, t('Save'));

    // Add alt/title to the image.
    $edit = array(
      'field_image[nl][0][alt]' => 'Bij het zien',
      'field_image[nl][0][title]' => 'Bij het zien van de groene vloeistof',
    );
    $this
      ->drupalPost('node/1/edit/nl', $edit, t('Save'));
    $this
      ->drupalGet('node/1/edit/nl');

    // Assert that the Dutch values were put in as expected.
    $node = node_load(1, NULL, TRUE);
    $dutch = $this
      ->getDutchValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['nl'][0]['tid'],
      ),
    );
    foreach ($dutch as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The Dutch field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }

    // Change unique target from guid (0) to title (1).
    $path = 'admin/structure/feeds/node/mapping';
    $this
      ->drupalPostAJAX($path, array(), 'mapping_settings_edit_0');
    $edit = array(
      "config[0][settings][unique]" => FALSE,
    );
    $this
      ->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_0');
    $this
      ->drupalPost(NULL, array(), t('Save'));
    $this
      ->drupalPostAJAX($path, array(), 'mapping_settings_edit_1');
    $edit = array(
      "config[1][settings][unique]" => 1,
    );
    $this
      ->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_1');
    $this
      ->drupalPost(NULL, array(), t('Save'));

    // Update this item with Feeds.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'update_existing' => FEEDS_UPDATE_EXISTING,
    ));
    $this
      ->addMappings('node', $this
      ->getMappingsInLanguage('fr'));
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Updated 1 node'));

    // Assert that French values were created.
    $node = node_load(1, NULL, TRUE);
    $french = $this
      ->getFrenchValues($node) + array(
      'field_category' => array(
        'expected' => 2,
        'actual' => $node->field_category['fr'][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The French field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }

    // Assert that Dutch values still exist.
    $dutch = $this
      ->getDutchValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['nl'][0]['tid'],
      ),
    );
    foreach ($dutch as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The Dutch field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if fields still are imported in their language when the
   * entity_translation module gets disabled.
   *
   * The entity_translation module is mainly an UI module for configuring field
   * language and disabling that module should not have effect on importing
   * values in a specific language for fields.
   */
  public function testWithDisabledEntityTranslationModule() {
    module_disable(array(
      'entity_translation',
    ));

    // Make sure that entity info is reset.
    drupal_flush_all_caches();
    drupal_static_reset();

    // Configure importer to import in French language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'fr',
    ));
    $this
      ->addMappings('node', $this
      ->getMappingsInLanguage('fr'));

    // Import content.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Assert that the fields were all created in French.
    $node = node_load(1, NULL, TRUE);
    $french = $this
      ->getFrenchValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['fr'][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if fields are still imported in their language when the
   * entity_translation module gets uninstalled.
   *
   * @see testWithDisabledEntityTranslationModule()
   */
  public function testWithUninstalledEntityTranslationModule() {
    module_disable(array(
      'entity_translation',
    ));
    drupal_uninstall_modules(array(
      'entity_translation',
    ));

    // Make sure that entity info is reset.
    drupal_flush_all_caches();
    drupal_static_reset();

    // Configure importer to import in French language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'fr',
    ));
    $this
      ->addMappings('node', $this
      ->getMappingsInLanguage('fr'));

    // Import content.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Assert that the fields were all created in French.
    $node = node_load(1, NULL, TRUE);
    $french = $this
      ->getFrenchValues($node) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category['fr'][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if fields are imported in LANGUAGE_NONE if the field's language gets
   * disabled after configuring.
   */
  public function testDisabledLanguage() {

    // Configure importer to import in French language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'fr',
    ));
    $this
      ->addMappings('node', $this
      ->getMappingsInLanguage('fr'));

    // Now disable the French language.
    $path = 'admin/config/regional/language';
    $edit = array(
      'enabled[fr]' => FALSE,
    );
    $this
      ->drupalPost($path, $edit, t('Save configuration'));

    // Reset static cache to update the available languages.
    drupal_static_reset();

    // Ensure no error messages are shown on the mappings page.
    $this
      ->drupalGet('admin/structure/feeds/node/mapping');

    // Import content.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Assert that the fields were all created in LANGUAGE_NONE.
    $node = node_load(1, NULL, TRUE);
    $french = $this
      ->getFrenchValues($node, LANGUAGE_NONE) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category[LANGUAGE_NONE][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if fields are imported in LANGUAGE_NONE if the field's language gets
   * removed after configuring.
   */
  public function testRemovedLanguage() {

    // Configure importer to import in French language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'fr',
    ));
    $this
      ->addMappings('node', $this
      ->getMappingsInLanguage('fr'));

    // Now remove the French language.
    $path = 'admin/config/regional/language/delete/fr';
    $this
      ->drupalPost($path, array(), t('Delete'));

    // Reset static cache to update the available languages.
    drupal_static_reset();

    // Import content.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Assert that the fields were all created in LANGUAGE_NONE.
    $node = node_load(1, NULL, TRUE);
    $french = $this
      ->getFrenchValues($node, LANGUAGE_NONE) + array(
      'field_category' => array(
        'expected' => 1,
        'actual' => $node->field_category[LANGUAGE_NONE][0]['tid'],
      ),
    );
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if autocreated terms are in the language that was set on the target configuration
   * in case the taxonomy is multilingual.
   */
  public function testAutocreatedTermLanguage() {
    module_enable(array(
      'i18n_taxonomy',
    ));

    // Make sure that entity info is reset.
    drupal_flush_all_caches();
    drupal_static_reset();

    // Enable multilingual taxonomy.
    $edit = array(
      'i18n_mode' => 4,
    );
    $this
      ->drupalPost('admin/structure/taxonomy/categories/edit', $edit, 'Save');

    // Configure importer to import in French language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'fr',
    ));
    $this
      ->addMappings('node', array(
      2 => array(
        'source' => 'term',
        'target' => 'field_category',
        'autocreate' => TRUE,
        'field_language' => 'fr',
      ),
    ));

    // Import French item.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Assert that the created term is in the French language.
    $term = taxonomy_term_load(1);
    $this
      ->assertEqual('fr', entity_language('taxonomy_term', $term));
  }

  /**
   * Tests if values are cleared out when an empty value or no value is
   * provided.
   */
  public function testClearOutValues() {

    // Set to update existing nodes.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'update_existing' => FEEDS_UPDATE_EXISTING,
    ));

    // Add English mappers.
    $index = 2;
    $mappings = $this
      ->getMappingsInLanguage('en', $index);

    // Append "_en" to each source name.
    foreach ($mappings as &$mapping) {
      $mapping['source'] .= '_en';
    }
    $this
      ->addMappings('node', $mappings);
    $index += count($mappings);

    // Add French mappers.
    $mappings = $this
      ->getMappingsInLanguage('fr', $index);

    // Append "_fr" to each source name.
    foreach ($mappings as &$mapping) {
      $mapping['source'] .= '_fr';
    }
    $this
      ->addMappings('node', $mappings);

    // Import file that has items with both English and French field values.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_en_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Now import a file where the French remained, but the English values were
    // removed.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_en_fr_empty.csv');
    $this
      ->assertText(t('Updated 1 node'));

    // Load node.
    $node = node_load(1, NULL, TRUE);

    // Check that the English values are gone, but the French values are still
    // there.
    $fields = array(
      'body',
      'field_date',
      'field_datestamp',
      'field_datetime',
      'field_image',
      'field_link',
      'field_list_boolean',
      'field_number_decimal',
      'field_number_float',
      'field_number_integer',
      'field_category',
      'field_text',
    );
    foreach ($fields as $field_name) {
      $this
        ->assertTrue(empty($node->{$field_name}['en']), format_string('The field %field is empty.', array(
        '%field' => $field_name,
      )));
    }

    // Inspect availability of French values.
    $french = $this
      ->getFrenchValues($node) + array(
      'field_category' => array(
        'expected' => 2,
        'actual' => $node->field_category['fr'][0]['tid'],
      ),
    );

    // Since the image was placed on the node again, its file name is now
    // "la fayette_0.jpeg."
    $french['field_image']['expected'] = 'la fayette_0.jpeg';
    foreach ($french as $field_name => $value) {
      $this
        ->assertEqual($value['expected'], $value['actual'], format_string('The French field %field has the expected value (actual: @actual).', array(
        '%field' => $field_name,
        '@actual' => $value['actual'],
      )));
    }
  }

  /**
   * Tests if values are cleared out when an empty value is provided for a
   * language that got disabled.
   */
  public function testClearOutValuesWithDisabledLanguage() {

    // Set to update existing nodes.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'update_existing' => FEEDS_UPDATE_EXISTING,
    ));

    // Configure importer to import in French language.
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'language' => 'fr',
    ));
    $this
      ->addMappings('node', $this
      ->getMappingsInLanguage('fr'));

    // Now disable the French language.
    $path = 'admin/config/regional/language';
    $edit = array(
      'enabled[fr]' => FALSE,
    );
    $this
      ->drupalPost($path, $edit, t('Save configuration'));

    // Ensure no error messages are shown on the mappings page.
    $this
      ->drupalGet('admin/structure/feeds/node/mapping');

    // Import content. Since the French language was disabled, the content
    // should be imported as LANGUAGE_NONE.
    // @see ::testDisabledLanguage()
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_fr.csv');
    $this
      ->assertText(t('Created 1 node'));

    // Now import a file with empty values.
    $this
      ->importFile('node', $this
      ->absolutePath() . '/tests/feeds/multilingual_empty.csv');
    $this
      ->assertText(t('Updated 1 node'));

    // Load node.
    $node = node_load(1, NULL, TRUE);

    // Check that the values in LANGUAGE_NONE are gone.
    $fields = array(
      'body',
      'field_date',
      'field_datestamp',
      'field_datetime',
      'field_image',
      'field_link',
      'field_list_boolean',
      'field_number_decimal',
      'field_number_float',
      'field_number_integer',
      'field_category',
      'field_text',
    );
    foreach ($fields as $field_name) {
      $this
        ->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE]), format_string('The field %field is empty.', array(
        '%field' => $field_name,
      )));
    }
  }

  /**
   * Adds a language to test with.
   *
   * @param string $langcode
   *   The language's langcode.
   * @param string $label
   *   The language human readable name.
   */
  protected function addLanguage($langcode, $label) {
    $edit = array(
      'langcode' => $langcode,
    );
    $this
      ->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
    $this
      ->assertText(format_string('The language @language has been created and can now be used.', array(
      '@language' => $label,
    )));
  }

  /**
   * Sets given content type and fields to be translatable.
   *
   * @param string $typename
   *   The machine name of the node type.
   * @param array $field_names
   *   The fields to enable multilingual support for.
   */
  protected function setupMultilingual($typename, array $field_names) {

    // Enable entity field translation for content type.
    $edit = array(
      'language_content_type' => 4,
      'entity_translation_hide_translation_links' => 1,
      'entity_translation_node_metadata' => 0,
    );
    $this
      ->drupalPost('admin/structure/types/manage/' . $typename, $edit, t('Save content type'));

    // Enable field translation on fields.
    $edit = array(
      'field[translatable]' => 1,
    );
    foreach ($field_names as $field_name) {
      $this
        ->drupalPost("admin/structure/types/manage/{$typename}/fields/{$field_name}", $edit, t('Save settings'));
    }

    // Reset static cache so that all languages are available when
    // field_available_languages() is called during node_load().
    drupal_static_reset();
  }

  /**
   * Adds mappings for each field in specified language.
   *
   * @param string $langcode
   *   The code of the desired language.
   * @param int $start
   *   The index number to start the array with. This must be
   *   specified in order to add mappings to the right index when
   *   calling FeedsWebTestCase::addMappings().
   */
  protected function getMappingsInLanguage($langcode, $start = 2) {
    $mappings = array(
      $start => array(
        'source' => 'body',
        'target' => 'body',
      ),
      array(
        'source' => 'date',
        'target' => 'field_date:start',
      ),
      array(
        'source' => 'datestamp',
        'target' => 'field_datestamp:start',
      ),
      array(
        'source' => 'datetime',
        'target' => 'field_datetime:start',
      ),
      array(
        'source' => 'image',
        'target' => 'field_image:uri',
      ),
      array(
        'source' => 'image_alt',
        'target' => 'field_image:alt',
      ),
      array(
        'source' => 'image_title',
        'target' => 'field_image:title',
      ),
      array(
        'source' => 'link',
        'target' => 'field_link:url',
      ),
      array(
        'source' => 'list_boolean',
        'target' => 'field_list_boolean',
      ),
      array(
        'source' => 'number_decimal',
        'target' => 'field_number_decimal',
      ),
      array(
        'source' => 'number_float',
        'target' => 'field_number_float',
      ),
      array(
        'source' => 'number_integer',
        'target' => 'field_number_integer',
      ),
      array(
        'source' => 'term',
        'target' => 'field_category',
        'autocreate' => TRUE,
      ),
      array(
        'source' => 'text',
        'target' => 'field_text',
      ),
    );
    foreach ($mappings as &$mapping) {
      $mapping['field_language'] = $langcode;
    }
    return $mappings;
  }

  /**
   * Returns expected and actual values of given node for the Dutch language.
   *
   * @param object $node
   *   The multilingual node.
   * @param string $langcode
   *   The used language code.
   *
   * @return array
   *   The expected and actual Dutch values.
   */
  protected function getDutchValues($node, $langcode = 'nl') {
    return array(
      'body' => array(
        'expected' => 'Dit is de berichttekst',
        'actual' => $node->body[$langcode][0]['value'],
      ),
      'field_date' => array(
        'expected' => '1985-07-29T00:00:00',
        'actual' => $node->field_date[$langcode][0]['value'],
      ),
      'field_datestamp' => array(
        'expected' => '491460492',
        'actual' => $node->field_datestamp[$langcode][0]['value'],
      ),
      'field_datetime' => array(
        'expected' => '1985-07-29 04:48:12',
        'actual' => $node->field_datetime[$langcode][0]['value'],
      ),
      'field_image' => array(
        'expected' => 'attersee.jpeg',
        'actual' => $node->field_image[$langcode][0]['filename'],
      ),
      'field_image:alt' => array(
        'expected' => 'Bij het zien',
        'actual' => $node->field_image[$langcode][0]['alt'],
      ),
      'field_image:title' => array(
        'expected' => 'Bij het zien van de groene vloeistof',
        'actual' => $node->field_image[$langcode][0]['title'],
      ),
      'field_link' => array(
        'expected' => 'http://google.nl',
        'actual' => $node->field_link[$langcode][0]['url'],
      ),
      'field_list_boolean' => array(
        'expected' => '1',
        'actual' => $node->field_list_boolean[$langcode][0]['value'],
      ),
      'field_number_decimal' => array(
        'expected' => 30.3,
        'actual' => $node->field_number_decimal[$langcode][0]['value'],
      ),
      'field_number_float' => array(
        'expected' => 30.2795,
        'actual' => $node->field_number_float[$langcode][0]['value'],
      ),
      'field_number_integer' => array(
        'expected' => 30,
        'actual' => $node->field_number_integer[$langcode][0]['value'],
      ),
      'field_text' => array(
        'expected' => 'Wortelen',
        'actual' => $node->field_text[$langcode][0]['value'],
      ),
    );
  }

  /**
   * Returns expected and actual values of given node for the English language.
   *
   * @param object $node
   *   The multilingual node.
   * @param string $langcode
   *   The used language code.
   *
   * @return array
   *   The expected and actual English values.
   */
  protected function getEnglishValues($node, $langcode = 'en') {
    return array(
      'body' => array(
        'expected' => 'This is the body',
        'actual' => $node->body[$langcode][0]['value'],
      ),
      'field_date' => array(
        'expected' => '2015-10-21T00:00:00',
        'actual' => $node->field_date[$langcode][0]['value'],
      ),
      'field_datestamp' => array(
        'expected' => '1445470140',
        'actual' => $node->field_datestamp[$langcode][0]['value'],
      ),
      'field_datetime' => array(
        'expected' => '2015-10-21 23:29:00',
        'actual' => $node->field_datetime[$langcode][0]['value'],
      ),
      'field_image' => array(
        'expected' => 'foosball.jpeg',
        'actual' => $node->field_image[$langcode][0]['filename'],
      ),
      'field_image:alt' => array(
        'expected' => 'Foosball',
        'actual' => $node->field_image[$langcode][0]['alt'],
      ),
      'field_image:title' => array(
        'expected' => 'Foosball played by two guys',
        'actual' => $node->field_image[$langcode][0]['title'],
      ),
      'field_link' => array(
        'expected' => 'http://google.ca',
        'actual' => $node->field_link[$langcode][0]['url'],
      ),
      'field_list_boolean' => array(
        'expected' => '0',
        'actual' => $node->field_list_boolean[$langcode][0]['value'],
      ),
      'field_number_decimal' => array(
        'expected' => 4.2,
        'actual' => $node->field_number_decimal[$langcode][0]['value'],
      ),
      'field_number_float' => array(
        'expected' => 3.1416,
        'actual' => $node->field_number_float[$langcode][0]['value'],
      ),
      'field_number_integer' => array(
        'expected' => 1000,
        'actual' => $node->field_number_integer[$langcode][0]['value'],
      ),
      'field_text' => array(
        'expected' => 'Carrots',
        'actual' => $node->field_text[$langcode][0]['value'],
      ),
    );
  }

  /**
   * Returns expected and actual values of given node for the French language.
   *
   * @param object $node
   *   The multilingual node.
   * @param string $langcode
   *   The used language code.
   *
   * @return array
   *   The expected and actual French values.
   */
  protected function getFrenchValues($node, $langcode = 'fr') {
    return array(
      'body' => array(
        'expected' => 'Ceci est la corps',
        'actual' => $node->body[$langcode][0]['value'],
      ),
      'field_date' => array(
        'expected' => '1955-11-05T00:00:00',
        'actual' => $node->field_date[$langcode][0]['value'],
      ),
      'field_datestamp' => array(
        'expected' => '-446731187',
        'actual' => $node->field_datestamp[$langcode][0]['value'],
      ),
      'field_datetime' => array(
        'expected' => '1955-11-05 12:00:13',
        'actual' => $node->field_datetime[$langcode][0]['value'],
      ),
      'field_image' => array(
        'expected' => 'la fayette.jpeg',
        'actual' => $node->field_image[$langcode][0]['filename'],
      ),
      'field_image:alt' => array(
        'expected' => 'La Fayette',
        'actual' => $node->field_image[$langcode][0]['alt'],
      ),
      'field_image:title' => array(
        'expected' => 'la Fayette dans les bois',
        'actual' => $node->field_image[$langcode][0]['title'],
      ),
      'field_link' => array(
        'expected' => 'http://google.fr',
        'actual' => $node->field_link[$langcode][0]['url'],
      ),
      'field_list_boolean' => array(
        'expected' => '1',
        'actual' => $node->field_list_boolean[$langcode][0]['value'],
      ),
      'field_number_decimal' => array(
        'expected' => 1.2,
        'actual' => $node->field_number_decimal[$langcode][0]['value'],
      ),
      'field_number_float' => array(
        'expected' => 5.6295,
        'actual' => $node->field_number_float[$langcode][0]['value'],
      ),
      'field_number_integer' => array(
        'expected' => 2000,
        'actual' => $node->field_number_integer[$langcode][0]['value'],
      ),
      'field_text' => array(
        'expected' => 'Carottes',
        'actual' => $node->field_text[$langcode][0]['value'],
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$useSetupInstallationCache public property Whether to cache the installation part of the setUp() method.
DrupalTestCase::$useSetupModulesCache public property Whether to cache the modules installation part of the setUp() method.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::run public function Run all tests in this class.
DrupalTestCase::verbose protected function Logs a verbose message in a text file.
DrupalWebTestCase::$additionalCurlOptions protected property Additional cURL options.
DrupalWebTestCase::$content protected property The content of the page currently loaded in the internal browser.
DrupalWebTestCase::$cookieFile protected property The current cookie file used by cURL.
DrupalWebTestCase::$cookies protected property The cookies of the page currently loaded in the internal browser.
DrupalWebTestCase::$curlHandle protected property The handle of the current cURL connection.
DrupalWebTestCase::$drupalSettings protected property The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser.
DrupalWebTestCase::$elements protected property The parsed version of the page.
DrupalWebTestCase::$generatedTestFiles protected property Whether the files were copied to the test files directory.
DrupalWebTestCase::$headers protected property The headers of the page currently loaded in the internal browser.
DrupalWebTestCase::$httpauth_credentials protected property HTTP authentication credentials (<username>:<password>).
DrupalWebTestCase::$httpauth_method protected property HTTP authentication method
DrupalWebTestCase::$loggedInUser protected property The current user logged in using the internal browser.
DrupalWebTestCase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing purposes.
DrupalWebTestCase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing purposes.
DrupalWebTestCase::$plainTextContent protected property The content of the page currently loaded in the internal browser (plain text version).
DrupalWebTestCase::$redirect_count protected property The number of redirects followed during the handling of a request.
DrupalWebTestCase::$session_id protected property The current session ID, if available.
DrupalWebTestCase::$session_name protected property The current session name, if available.
DrupalWebTestCase::$url protected property The URL currently loaded in the internal browser.
DrupalWebTestCase::assertField protected function Asserts that a field exists with the given name or ID.
DrupalWebTestCase::assertFieldById protected function Asserts that a field exists in the current page with the given ID and value.
DrupalWebTestCase::assertFieldByName protected function Asserts that a field exists in the current page with the given name and value.
DrupalWebTestCase::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
DrupalWebTestCase::assertLink protected function Pass if a link with the specified label is found, and optional with the specified index.
DrupalWebTestCase::assertLinkByHref protected function Pass if a link containing a given href (part) is found.
DrupalWebTestCase::assertMail protected function Asserts that the most recently sent e-mail message has the given value.
DrupalWebTestCase::assertMailPattern protected function Asserts that the most recently sent e-mail message has the pattern in it.
DrupalWebTestCase::assertMailString protected function Asserts that the most recently sent e-mail message has the string in it.
DrupalWebTestCase::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
DrupalWebTestCase::assertNoField protected function Asserts that a field does not exist with the given name or ID.
DrupalWebTestCase::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
DrupalWebTestCase::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
DrupalWebTestCase::assertNoFieldByXPath protected function Asserts that a field doesn't exist or its value doesn't match, by XPath.
DrupalWebTestCase::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
DrupalWebTestCase::assertNoLink protected function Pass if a link with the specified label is not found.
DrupalWebTestCase::assertNoLinkByHref protected function Pass if a link containing a given href (part) is not found.
DrupalWebTestCase::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
DrupalWebTestCase::assertNoPattern protected function Will trigger a pass if the perl regex pattern is not present in raw content.
DrupalWebTestCase::assertNoRaw protected function Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertNoResponse protected function Asserts the page did not return the specified response code.
DrupalWebTestCase::assertNoText protected function Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertNoTitle protected function Pass if the page title is not the given string.
DrupalWebTestCase::assertNoUniqueText protected function Pass if the text is found MORE THAN ONCE on the text version of the page.
DrupalWebTestCase::assertOptionSelected protected function Asserts that a select option in the current page is checked.
DrupalWebTestCase::assertPattern protected function Will trigger a pass if the Perl regex pattern is found in the raw content.
DrupalWebTestCase::assertRaw protected function Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertResponse protected function Asserts the page responds with the specified response code.
DrupalWebTestCase::assertText protected function Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertTextHelper protected function Helper for assertText and assertNoText.
DrupalWebTestCase::assertThemeOutput protected function Asserts themed output.
DrupalWebTestCase::assertTitle protected function Pass if the page title is the given string.
DrupalWebTestCase::assertUniqueText protected function Pass if the text is found ONLY ONCE on the text version of the page.
DrupalWebTestCase::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
DrupalWebTestCase::assertUrl protected function Pass if the internal browser's URL matches the given path.
DrupalWebTestCase::buildXPathQuery protected function Builds an XPath query.
DrupalWebTestCase::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
DrupalWebTestCase::checkForMetaRefresh protected function Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
DrupalWebTestCase::checkPermissions protected function Check to make sure that the array of permissions are valid.
DrupalWebTestCase::clickLink protected function Follows a link by name.
DrupalWebTestCase::constructFieldXpath protected function Helper function: construct an XPath for the given set of attributes and value.
DrupalWebTestCase::copySetupCache protected function Copy the setup cache from/to another table and files directory.
DrupalWebTestCase::cronRun protected function Runs cron in the Drupal installed by Simpletest.
DrupalWebTestCase::curlClose protected function Close the cURL handler and unset the handler.
DrupalWebTestCase::curlExec protected function Initializes and executes a cURL request.
DrupalWebTestCase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
DrupalWebTestCase::curlInitialize protected function Initializes the cURL connection.
DrupalWebTestCase::drupalCompareFiles protected function Compare two files based on size and file name.
DrupalWebTestCase::drupalCreateContentType protected function Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateNode protected function Creates a node based on default settings.
DrupalWebTestCase::drupalCreateRole protected function Creates a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalGetAJAX protected function Retrieve a Drupal path or an absolute path and JSON decode the result.
DrupalWebTestCase::drupalGetContent protected function Gets the current raw HTML of requested page.
DrupalWebTestCase::drupalGetHeader protected function Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed…
DrupalWebTestCase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the…
DrupalWebTestCase::drupalGetMails protected function Gets an array containing all e-mails sent during this test case.
DrupalWebTestCase::drupalGetNodeByTitle function Get a node from the database based on its title.
DrupalWebTestCase::drupalGetSettings protected function Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::drupalGetTestFiles protected function Get a list files that can be used in tests.
DrupalWebTestCase::drupalGetToken protected function Generate a token for the currently logged in user.
DrupalWebTestCase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
DrupalWebTestCase::drupalLogin protected function Log in a user with the internal browser.
DrupalWebTestCase::drupalLogout protected function
DrupalWebTestCase::drupalPost protected function Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
DrupalWebTestCase::drupalPostAJAX protected function Execute an Ajax submission.
DrupalWebTestCase::drupalSetContent protected function Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.
DrupalWebTestCase::drupalSetSettings protected function Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
DrupalWebTestCase::getAllOptions protected function Get all option elements, including nested options, in a select.
DrupalWebTestCase::getSelectedItem protected function Get the selected value from a select field.
DrupalWebTestCase::getSetupCacheKey protected function Returns the cache key used for the setup caching.
DrupalWebTestCase::getUrl protected function Get the current URL from the cURL handler.
DrupalWebTestCase::handleForm protected function Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
DrupalWebTestCase::loadSetupCache protected function Copies the cached tables and files for a cached installation setup.
DrupalWebTestCase::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
DrupalWebTestCase::preloadRegistry protected function Preload the registry from the testing site.
DrupalWebTestCase::prepareDatabasePrefix protected function Generates a database prefix for running tests.
DrupalWebTestCase::prepareEnvironment protected function Prepares the current environment for running the test.
DrupalWebTestCase::recursiveDirectoryCopy protected function Recursively copy one directory to another.
DrupalWebTestCase::refreshVariables protected function Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. 1
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::storeSetupCache protected function Store the installation setup to a cache.
DrupalWebTestCase::tearDown protected function Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix. 6
DrupalWebTestCase::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
DrupalWebTestCase::xpath protected function Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.
DrupalWebTestCase::__construct function Constructor for DrupalWebTestCase. Overrides DrupalTestCase::__construct 1
FeedsMapperMultilingualFieldsTestCase::$contentType private property Name of created content type.
FeedsMapperMultilingualFieldsTestCase::$fields protected property
FeedsMapperMultilingualFieldsTestCase::addLanguage protected function Adds a language to test with.
FeedsMapperMultilingualFieldsTestCase::getDutchValues protected function Returns expected and actual values of given node for the Dutch language.
FeedsMapperMultilingualFieldsTestCase::getEnglishValues protected function Returns expected and actual values of given node for the English language.
FeedsMapperMultilingualFieldsTestCase::getFrenchValues protected function Returns expected and actual values of given node for the French language.
FeedsMapperMultilingualFieldsTestCase::getInfo public static function
FeedsMapperMultilingualFieldsTestCase::getMappingsInLanguage protected function Adds mappings for each field in specified language.
FeedsMapperMultilingualFieldsTestCase::setUp public function Sets up a Drupal site for running functional and integration tests. Overrides FeedsWebTestCase::setUp
FeedsMapperMultilingualFieldsTestCase::setupMultilingual protected function Sets given content type and fields to be translatable.
FeedsMapperMultilingualFieldsTestCase::testAutocreatedTermLanguage public function Tests if autocreated terms are in the language that was set on the target configuration in case the taxonomy is multilingual.
FeedsMapperMultilingualFieldsTestCase::testChangedLanguageImport public function Tests if values of fields in other languages are kept when not importing in that language.
FeedsMapperMultilingualFieldsTestCase::testChangedLanguageImportForExistingNode public function Tests if values of fields in other languages are kept when not importing in that language for nodes that were not created by Feeds.
FeedsMapperMultilingualFieldsTestCase::testClearOutValues public function Tests if values are cleared out when an empty value or no value is provided.
FeedsMapperMultilingualFieldsTestCase::testClearOutValuesWithDisabledLanguage public function Tests if values are cleared out when an empty value is provided for a language that got disabled.
FeedsMapperMultilingualFieldsTestCase::testDisabledLanguage public function Tests if fields are imported in LANGUAGE_NONE if the field's language gets disabled after configuring.
FeedsMapperMultilingualFieldsTestCase::testMultilingualFieldMappings public function Tests multilingual mappings to translatable fields (entity translation).
FeedsMapperMultilingualFieldsTestCase::testRemovedLanguage public function Tests if fields are imported in LANGUAGE_NONE if the field's language gets removed after configuring.
FeedsMapperMultilingualFieldsTestCase::testWithDisabledEntityTranslationModule public function Tests if fields still are imported in their language when the entity_translation module gets disabled.
FeedsMapperMultilingualFieldsTestCase::testWithUninstalledEntityTranslationModule public function Tests if fields are still imported in their language when the entity_translation module gets uninstalled.
FeedsMapperTestCase::$field_widgets private static property A lookup map to select the widget for each field type.
FeedsMapperTestCase::assertNodeFieldValue protected function Assert that a form field for the given field with the given value exists in the current form.
FeedsMapperTestCase::assertNoNodeFieldValue protected function Assert that a form field for the given field with the given value does not exist in the current form.
FeedsMapperTestCase::createContentType final protected function Create a new content-type, and add a field to it. Mostly copied from cck/tests/content.crud.test ContentUICrud::testAddFieldUI
FeedsMapperTestCase::getFormFieldsNames protected function Returns the form fields names for a given CCK field. Default implementation provides support for a single form field with the following name pattern <code>"field_{$field_name}[{$index}][value]"</code> 3
FeedsMapperTestCase::getFormFieldsValues protected function Returns the form fields values for a given CCK field. Default implementation returns a single element array with $value casted to a string. 1
FeedsMapperTestCase::selectFieldWidget protected function Select the widget for the field. Default implementation provides widgets for Date, Number, Text, Node reference, User reference, Email, Emfield, Filefield, Image, and Link.
FeedsWebTestCase::$profile protected property The profile to install as a basis for testing. Overrides DrupalWebTestCase::$profile 1
FeedsWebTestCase::absolute public function Absolute path to Drupal root.
FeedsWebTestCase::absolutePath public function Get the absolute directory path of the feeds module.
FeedsWebTestCase::addMappings public function Adds mappings to a given configuration.
FeedsWebTestCase::assertFieldByXPath protected function Overrides DrupalWebTestCase::assertFieldByXPath(). Overrides DrupalWebTestCase::assertFieldByXPath
FeedsWebTestCase::assertFieldDisabled protected function Asserts that a field in the current page is disabled.
FeedsWebTestCase::assertFieldEnabled protected function Asserts that a field in the current page is enabled.
FeedsWebTestCase::assertNodeCount protected function Asserts that the given number of nodes exist.
FeedsWebTestCase::assertPlugins public function Assert a feeds configuration's plugins.
FeedsWebTestCase::changeNodeAuthor protected function Changes the author of a node and asserts the change in the UI.
FeedsWebTestCase::copyDir public function Copies a directory.
FeedsWebTestCase::createFeedNode public function Create a test feed node. Test user has to have sufficient permissions:.
FeedsWebTestCase::createFeedNodes public function Batch create a variable amount of feed nodes. All will have the same URL configured.
FeedsWebTestCase::createImporterConfiguration public function Create an importer configuration.
FeedsWebTestCase::downloadExtractSimplePie public function Download and extract SimplePIE.
FeedsWebTestCase::editFeedNode public function Edit the configuration of a feed node to test update behavior.
FeedsWebTestCase::generateOPML public function Generate an OPML test feed.
FeedsWebTestCase::getCurrentMappings public function Gets an array of current mappings from the feeds_importer config.
FeedsWebTestCase::getNid public function Helper function, retrieves node id from a URL.
FeedsWebTestCase::importFile public function Import a file through the import form. Assumes FeedsFileFetcher in place.
FeedsWebTestCase::importURL public function Import a URL through the import form. Assumes FeedsHTTPFetcher in place.
FeedsWebTestCase::mappingExists public function Determines if a mapping exists for a given importer.
FeedsWebTestCase::removeMappings public function Remove mappings from a given configuration.
FeedsWebTestCase::setPlugin public function Choose a plugin for a importer configuration and assert it.
FeedsWebTestCase::setSettings public function Set importer or plugin settings.