You are here

class FeedsMapperFileTestCase in Feeds 7.2

Test case for Filefield mapper mappers/filefield.inc.

Hierarchy

Expanded class hierarchy of FeedsMapperFileTestCase

File

tests/feeds_mapper_file.test, line 11
Contains FeedsMapperFileTestCase.

View source
class FeedsMapperFileTestCase extends FeedsMapperTestCase {

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return array(
      'name' => 'Mapper: File field',
      'description' => 'Test Feeds Mapper support for file fields. <strong>Requires SimplePie library</strong>.',
      'group' => 'Feeds',
    );
  }

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp(array(
      'dblog',
    ));

    // If this is unset (or FALSE) http_request.inc will use curl, and will
    // generate a 404 for the feed url provided by feeds_tests. However, if
    // feeds_tests was enabled in your site before running the test, it will
    // work fine. Since it is truly screwy, lets just force it to use
    // drupal_http_request() for this test case.
    variable_set('feeds_never_use_curl', TRUE);

    // Get our defined constants and any helper functions.
    module_load_include('inc', 'feeds', 'mappers/file');
  }

  /**
   * Basic test loading a single entry CSV file.
   */
  public function test() {

    // Only download simplepie if the plugin doesn't already exist somewhere.
    // People running tests locally might have it.
    $this
      ->requireSimplePie();
    $typename = $this
      ->createContentType(array(), array(
      'files' => array(
        'type' => 'file',
        'instance_settings' => array(
          'instance[settings][file_extensions]' => 'png, gif, jpg, jpeg',
        ),
      ),
    ));

    // 1) Test mapping remote resources to file field.
    // Create importer configuration.
    $this
      ->createImporterConfiguration();
    $this
      ->setPlugin('syndication', 'FeedsSimplePieParser');
    $this
      ->setSettings('syndication', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->addMappings('syndication', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'timestamp',
        'target' => 'created',
      ),
      2 => array(
        'source' => 'enclosures',
        'target' => 'field_files:uri',
      ),
    ));
    $nid = $this
      ->createFeedNode('syndication', $GLOBALS['base_url'] . '/testing/feeds/flickr.xml', 'Test Title');
    $this
      ->assertText('Created 5 nodes');
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'syndication')
      ->execute();
    foreach ($entities as $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertText(str_replace(' ', '_', array_shift($files)));
    }

    // 2) Test mapping local resources to file field.
    // Copy directory of files, CSV file expects them in public://images, point
    // file field to a 'resources' directory. Feeds should copy files from
    // images/ to resources/ on import.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', 'public://images');
    $edit = array(
      'instance[settings][file_directory]' => 'resources',
    );
    $this
      ->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_files', $edit, t('Save settings'));

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV', 'node');
    $this
      ->setPlugin('node', 'FeedsCSVParser');
    $this
      ->setSettings('node', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->setSettings('node', NULL, array(
      'content_type' => '',
    ));
    $this
      ->addMappings('node', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
      ),
    ));

    // Import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => url('testing/feeds/files.csv', array(
        'absolute' => TRUE,
      )),
    );
    $this
      ->drupalPost('import/node', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert: files should be in resources/.
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'node')
      ->execute();
    foreach ($entities as $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertRaw('resources/' . rawurlencode(array_shift($files)));
    }

    // 3) Test mapping of local resources, this time leave files in place.
    $this
      ->drupalPost('import/node/delete-items', array(), 'Delete');

    // Setting the fields file directory to images will make copying files
    // obsolete.
    $edit = array(
      'instance[settings][file_directory]' => 'images',
    );
    $this
      ->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_files', $edit, t('Save settings'));
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv',
    );
    $this
      ->drupalPost('import/node', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert: files should be in images/ now.
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'node')
      ->execute();
    foreach ($entities as $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertRaw('images/' . rawurlencode(array_shift($files)));
    }

    // Deleting all imported items will delete the files from the images/ dir.
    $this
      ->drupalPost('import/node/delete-items', array(), 'Delete');
    foreach ($this
      ->listTestFiles() as $file) {
      $this
        ->assertFalse(is_file("public://images/{$file}"));
    }
  }

  /**
   * Test mapping of local resources with the file exists "Rename" setting.
   *
   * In this test, files to import should be renamed if files with the same name
   * already exist in the destination folder.
   * Example: on the destination folder there exist a file named 'foo.jpg'. When
   * importing a file with the same name, that file should be renamed to
   * 'foo_0.jpg'.
   */
  public function testFileExistsRename() {

    // Copy the files to import to the folder 'images'.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', 'public://images');

    // Create a content type. Save imported files into the directory
    // 'destination_rename'.
    $typename = $this
      ->createContentTypeWithFileField('destination_rename');

    // Copy files with the same names to the destination folder. These files
    // should remain intact, while the files to import should get renamed.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', 'public://destination_rename');

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV -- File Exists Rename', 'node_rename');
    $this
      ->setSettings('node_rename', NULL, array(
      'content_type' => '',
    ));
    $this
      ->setPlugin('node_rename', 'FeedsCSVParser');
    $this
      ->setSettings('node_rename', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->addMappings('node_rename', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
        'file_exists' => FILE_EXISTS_RENAME,
      ),
    ));

    // Perform the import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv',
    );
    $this
      ->drupalPost('import/node_rename', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert: all imported files should be renamed.
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'node_rename')
      ->execute();
    foreach ($entities as $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $f = new FeedsEnclosure(array_shift($files), NULL);
      $renamed_file = str_replace('.jpeg', '_0.jpeg', $f
        ->getUrlEncodedValue());
      $this
        ->assertRaw('destination_rename/' . $renamed_file);
    }

    // Clean up the last import.
    $this
      ->drupalPost('import/node_rename/delete-items', array(), 'Delete');
  }

  /**
   * Test mapping of local resources with the file exists "Replace" setting.
   *
   * In this test, files to import should be replaced if files with the same
   * name already exist in the destination folder.
   * Example: on the destination folder there exist a file named 'foo.jpg'.
   * When importing a file with the same name, that file should replace the
   * existing 'foo.jpg'.
   */
  public function testFileExistsReplace() {
    $source = 'public://images';
    $dest = 'public://destination_replace';

    // Copy the files to import to the folder 'images'.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $source);

    // Create a content type. Save imported files into the directory
    // 'destination_replace'.
    $typename = $this
      ->createContentTypeWithFileField('destination_replace');

    // Copy files with the same name to the destination folder, but make sure
    // that the files are different by shuffling the file names. These files
    // should get overwritten upon import.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $dest, $this
      ->listTestFilesNameMap());

    // Confirm the files from the source folder are all different from the
    // destination folder.
    foreach (@scandir($source) as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} is not the same as {$dest}/{$file}";
        $this
          ->assertFalse(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV -- File Exists Replace', 'node_replace');
    $this
      ->setSettings('node_replace', NULL, array(
      'content_type' => '',
    ));
    $this
      ->setPlugin('node_replace', 'FeedsCSVParser');
    $this
      ->setSettings('node_replace', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->addMappings('node_replace', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
        'file_exists' => FILE_EXISTS_REPLACE,
      ),
    ));

    // Perform the import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv',
    );
    $this
      ->drupalPost('import/node_replace', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert: all files in the destination folder should be exactly the same as
    // the files in the source folder.
    foreach (@scandir($source) as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} is the same as {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Clean up the last import.
    $this
      ->drupalPost('import/node_replace/delete-items', array(), 'Delete');
  }

  /**
   * Test mapping of local resources with the file exists "Rename if different"
   * setting.
   *
   * In this test, files to import should only be renamed under the following
   * circumstances:
   * - A file the same name already exist in the destination folder;
   * - AND this file is different.
   *
   * Example: on the destination folder there exist two files: one called
   * 'foo.jpg' and an other called 'bar.jpg'. On an import two files with the
   * same name are imported. The 'foo.jpg' is exactly the same as the one that
   * already exist on the destination, but 'bar.jpg' is different. In this case,
   * only 'bar.jpg' should get imported and it should be renamed to 'bar_0.jpg'.
   * Importing 'foo.jpg' should be skipped as it is already there. The file's
   * timestamp will remain the same.
   */
  public function testFileExistsRenameIfDifferent() {
    $source = 'public://images';
    $dest = 'public://destination_rename_diff';

    // Copy the files to import to the folder 'images'.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $source);

    // Create a content type. Save imported files into the directory
    // 'destination_rename_diff'.
    $typename = $this
      ->createContentTypeWithFileField('destination_rename_diff');

    // Shuffle a couple of the file names so the files appear to be different.
    // Leave a few others the same.
    $same = array(
      'foosball.jpeg' => 'foosball.jpeg',
      'attersee.jpeg' => 'attersee.jpeg',
      'hstreet.jpeg' => 'hstreet.jpeg',
    );
    $different = array(
      'la fayette.jpeg' => 'tubing.jpeg',
      'tubing.jpeg' => 'la fayette.jpeg',
    );

    // Copy files with the same name to the destination folder. A few of them
    // however, will be different. Only these files should get renamed upon
    // import.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $dest, $same + $different);

    // Note the timestamps that the files got in the destination folder.
    $file_timestamps = array();
    foreach (@scandir($dest) as $file) {
      $file_timestamps[$file] = filemtime("{$dest}/{$file}");
    }

    // Confirm that some of the files are the same.
    foreach ($same as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} IS the same as {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Confirm that some of the files are different.
    foreach ($different as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} is NOT the same as {$dest}/{$file}";
        $this
          ->assertFalse(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV -- File Exists Rename if Different', 'node_rename_diff');
    $this
      ->setSettings('node_rename_diff', NULL, array(
      'content_type' => '',
    ));
    $this
      ->setPlugin('node_rename_diff', 'FeedsCSVParser');
    $this
      ->setSettings('node_rename_diff', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->addMappings('node_rename_diff', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
        'file_exists' => FEEDS_FILE_EXISTS_RENAME_DIFFERENT,
      ),
    ));

    // Perform the import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv',
    );
    $this
      ->drupalPost('import/node_rename_diff', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert that only files that were different should have been renamed.
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'node_rename_diff')
      ->execute();
    foreach ($entities as $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $f = new FeedsEnclosure(array_shift($files), NULL);
      $original_file = $f
        ->getUrlEncodedValue();
      $renamed_file = str_replace('.jpeg', '_0.jpeg', $f
        ->getUrlEncodedValue());
      if (isset($same[$original_file])) {

        // Assert that the file still has the same name.
        $this
          ->assertRaw('destination_rename_diff/' . $original_file);
      }
      else {

        // Assert that the file still has been renamed.
        $this
          ->assertRaw('destination_rename_diff/' . $renamed_file);
      }
    }

    // Assert that some files have been kept the same.
    foreach ($same as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} is STILL the same as {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
        $message = "{$dest}/{$file} was not replaced (modification time is the same as before import)";
        $this
          ->assertEqual(filemtime("{$dest}/{$file}"), $file_timestamps[$file], $message);
      }
    }

    // Clean up the last import.
    $this
      ->drupalPost('import/node_rename_diff/delete-items', array(), 'Delete');
  }

  /**
   * Test mapping of local resources with the file exists "Replace if different"
   * setting.
   *
   * In this test, files to import should only be replaced under the following
   * circumstances:
   * - A file the same name already exist in the destination folder;
   * - AND this file is different.
   *
   * Example: on the destination folder there exist two files: one called
   * 'foo.jpg' and an other called 'bar.jpg'. On an import two files with the
   * same name are imported. The 'foo.jpg' is exactly the same as the one that
   * already exist on the destination, but 'bar.jpg' is different. In this case,
   * only 'bar.jpg' should get imported and it should overwrite the existing
   * 'bar.jpg'. Importing 'foo.jpg' should be skipped as it is already there.
   * The file's timestamp will remain the same.
   */
  public function testFileExistsReplaceIfDifferent() {
    $source = 'public://images';
    $dest = 'public://destination_replace_diff';

    // Copy the files to import to the folder 'images'.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $source);

    // Create a content type. Save imported files into the directory
    // 'destination_replace_diff'.
    $typename = $this
      ->createContentTypeWithFileField('destination_replace_diff');

    // Shuffle a couple of the file names so the files appear to be different.
    // Leave a few others the same.
    $same = array(
      'foosball.jpeg' => 'foosball.jpeg',
      'attersee.jpeg' => 'attersee.jpeg',
      'hstreet.jpeg' => 'hstreet.jpeg',
    );
    $different = array(
      'la fayette.jpeg' => 'tubing.jpeg',
      'tubing.jpeg' => 'la fayette.jpeg',
    );

    // Copy files with the same name to the destination folder. A few of them
    // however, will be different. Only these files should get replaced upon
    // import.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $dest, $same + $different);

    // Note the timestamps that the files got in the destination folder.
    $file_timestamps = array();
    foreach (@scandir($dest) as $file) {
      $file_timestamps[$file] = filemtime("{$dest}/{$file}");
    }

    // Confirm that some of the files are the same.
    foreach ($same as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} IS the same as {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Confirm that some of the files are different.
    foreach ($different as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} is NOT the same as {$dest}/{$file}";
        $this
          ->assertFalse(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV -- File Exists Replace if Different', 'node_replace_diff');
    $this
      ->setSettings('node_replace_diff', NULL, array(
      'content_type' => '',
    ));
    $this
      ->setPlugin('node_replace_diff', 'FeedsCSVParser');
    $this
      ->setSettings('node_replace_diff', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->addMappings('node_replace_diff', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
        'file_exists' => FEEDS_FILE_EXISTS_REPLACE_DIFFERENT,
      ),
    ));

    // Perform the import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv',
    );
    $this
      ->drupalPost('import/node_replace_diff', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert that some files have been kept the same.
    foreach ($same as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} is STILL the same as {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
        $message = "{$dest}/{$file} was not replaced (modification time is the same as before import)";
        $this
          ->assertEqual(filemtime("{$dest}/{$file}"), $file_timestamps[$file], $message);
      }
    }

    // Assert that some files were replaced.
    foreach ($different as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} successfully replaced {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
        $this
          ->assertNotEqual(filemtime("{$dest}/{$file}"), $file_timestamps[$file], $message);
      }
    }

    // Clean up the last import.
    $this
      ->drupalPost('import/node_replace_diff/delete-items', array(), 'Delete');
  }

  /**
   * Test mapping of local resources with the file exists "Skip existig"
   * setting.
   *
   * In this test, files should only be imported if no file exist yet with the
   * given name.
   * Example: on the destination folder there exist a file named 'foo.jpg'. When
   * importing a file with the same name, that file should not be imported
   * as there already is a file with that name.
   */
  public function testFileExistsSkip() {
    $source = 'public://images';
    $dest = 'public://destination_skip';

    // Copy the files to import to the folder 'images'.
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $source);

    // Create a content type. Save imported files into the directory
    // 'destination_skip'.
    $typename = $this
      ->createContentTypeWithFileField('destination_skip');

    // Copy a few images also to the destination directory.
    $same = array(
      'foosball.jpeg' => 'foosball.jpeg',
      'attersee.jpeg' => 'attersee.jpeg',
      'hstreet.jpeg' => 'hstreet.jpeg',
    );
    $different = array(
      'la fayette.jpeg' => FALSE,
      'tubing.jpeg' => FALSE,
    );
    $this
      ->copyDir($this
      ->absolutePath() . '/tests/feeds/assets', $dest, $same + $different);

    // Note the timestamps that the files got in the destination folder.
    $file_timestamps = array();
    foreach (@scandir($dest) as $file) {
      $file_timestamps[$file] = filemtime("{$dest}/{$file}");
    }

    // Confirm that some of the files are the same.
    foreach ($same as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$source}/{$file} IS the same as {$dest}/{$file}";
        $this
          ->assertTrue(file_feeds_file_compare("{$source}/{$file}", "{$dest}/{$file}"), $message);
      }
    }

    // Confirm that some of the files do not exist.
    foreach ($different as $file => $value) {
      $message = "{$dest}/{$file} does not exist.";
      $this
        ->assertFalse(file_exists("{$dest}/{$file}"), $message);
    }

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV -- File Exists Replace if Different', 'node_skip');
    $this
      ->setSettings('node_skip', NULL, array(
      'content_type' => '',
    ));
    $this
      ->setPlugin('node_skip', 'FeedsCSVParser');
    $this
      ->setSettings('node_skip', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->addMappings('node_skip', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
        'file_exists' => FEEDS_FILE_EXISTS_SKIP,
      ),
    ));

    // Perform the import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/testing/feeds/files.csv',
    );
    $this
      ->drupalPost('import/node_skip', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert that files that were already in the destination folder were not
    // overwritten.
    foreach ($same as $file) {
      if (is_file("{$source}/{$file}")) {
        $message = "{$dest}/{$file} was skipped (modification time is the same as before import)";
        $this
          ->assertEqual(filemtime("{$dest}/{$file}"), $file_timestamps[$file], $message);
      }
    }

    // Assert that the other files were added with the expected names.
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'node_skip')
      ->execute();
    foreach ($entities as $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $f = new FeedsEnclosure(array_shift($files), NULL);
      $this
        ->assertRaw('destination_skip/' . $f
        ->getUrlEncodedValue());
    }
  }

  /**
   * Tests mapping to an image field.
   */
  public function testImages() {
    variable_set('feeds_never_use_curl', TRUE);
    $typename = $this
      ->createContentType(array(), array(
      'images' => 'image',
    ));

    // Enable title and alt mapping.
    $edit = array(
      'instance[settings][alt_field]' => 1,
      'instance[settings][title_field]' => 1,
    );
    $this
      ->drupalPost("admin/structure/types/manage/{$typename}/fields/field_images", $edit, t('Save settings'));

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV', 'image_test');
    $this
      ->setPlugin('image_test', 'FeedsCSVParser');
    $this
      ->setSettings('image_test', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->setSettings('image_test', NULL, array(
      'content_type' => '',
    ));
    $this
      ->addMappings('image_test', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_images:uri',
      ),
      2 => array(
        'source' => 'title2',
        'target' => 'field_images:title',
      ),
      3 => array(
        'source' => 'alt',
        'target' => 'field_images:alt',
      ),
    ));

    // Import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => url('testing/feeds/files-remote.csv', array(
        'absolute' => TRUE,
      )),
    );
    $this
      ->drupalPost('import/image_test', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert files exist.
    $files = $this
      ->listTestFiles();
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'image_test')
      ->execute();
    foreach ($entities as $i => $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertRaw(str_replace(' ', '_', array_shift($files)));
      $this
        ->assertRaw("Alt text {$i}");
      $this
        ->assertRaw("Title text {$i}");
    }
  }

  /**
   * {@inheritdoc}
   */
  public function testInvalidFileExtension() {
    variable_set('feeds_never_use_curl', TRUE);
    $typename = $this
      ->createContentType(array(), array(
      'files' => array(
        'type' => 'file',
        'instance_settings' => array(
          'instance[settings][file_extensions]' => 'txt',
        ),
      ),
    ));

    // Create a CSV importer configuration.
    $this
      ->createImporterConfiguration('Node import from CSV', 'invalid_extension');
    $this
      ->setPlugin('invalid_extension', 'FeedsCSVParser');
    $this
      ->setSettings('invalid_extension', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
    ));
    $this
      ->setSettings('invalid_extension', NULL, array(
      'content_type' => '',
    ));
    $this
      ->addMappings('invalid_extension', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      1 => array(
        'source' => 'file',
        'target' => 'field_files:uri',
      ),
    ));

    // Import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => url('testing/feeds/files-remote.csv', array(
        'absolute' => TRUE,
      )),
    );
    $this
      ->drupalPost('import/invalid_extension', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');
    foreach (range(1, 5) as $nid) {
      $node = node_load($nid);
      $this
        ->assertTrue(empty($node->field_files));
    }
    foreach ($this
      ->listTestFiles() as $filename) {
      $message = t('The file @file has an invalid extension.', array(
        '@file' => $filename,
      ));
      $this
        ->assertTrue(db_query("SELECT 1 FROM {watchdog} WHERE message = :message", array(
        ':message' => $message,
      ))
        ->fetchField());
    }

    // Test that query string and fragments are removed.
    $enclosure = new FeedsEnclosure('http://example.com/image.jpg?thing=stuff', 'text/plain');
    $this
      ->assertEqual($enclosure
      ->getLocalValue(), 'image.jpg');
    $enclosure = new FeedsEnclosure('http://example.com/image.jpg#stuff', 'text/plain');
    $this
      ->assertEqual($enclosure
      ->getLocalValue(), 'image.jpg');
    $enclosure = new FeedsEnclosure('http://example.com/image.JPG?thing=stuff#stuff', 'text/plain');
    $this
      ->assertEqual($enclosure
      ->getLocalValue(), 'image.JPG');
  }

  /**
   * Tests if values are cleared out when an empty value or no value
   * is provided.
   */
  public function testClearOutValues() {
    variable_set('feeds_never_use_curl', TRUE);
    $this
      ->createContentType(array(), array(
      'files' => 'file',
    ));
    $typename = $this
      ->createContentType(array(), array(
      'images' => 'image',
    ));

    // Enable title and alt mapping.
    $edit = array(
      'instance[settings][alt_field]' => 1,
      'instance[settings][title_field]' => 1,
    );
    $this
      ->drupalPost("admin/structure/types/manage/{$typename}/fields/field_images", $edit, t('Save settings'));

    // Create and configure importer.
    $this
      ->createImporterConfiguration('Content CSV', 'csv');
    $this
      ->setSettings('csv', NULL, array(
      'content_type' => '',
      'import_period' => FEEDS_SCHEDULE_NEVER,
    ));
    $this
      ->setPlugin('csv', 'FeedsCSVParser');
    $this
      ->setSettings('csv', 'FeedsNodeProcessor', array(
      'bundle' => $typename,
      'update_existing' => 1,
    ));
    $this
      ->addMappings('csv', array(
      0 => array(
        'source' => 'guid',
        'target' => 'guid',
        'unique' => TRUE,
      ),
      1 => array(
        'source' => 'title',
        'target' => 'title',
      ),
      2 => array(
        'source' => 'file',
        'target' => 'field_images:uri',
      ),
      3 => array(
        'source' => 'title2',
        'target' => 'field_images:title',
      ),
      4 => array(
        'source' => 'alt',
        'target' => 'field_images:alt',
      ),
    ));

    // Import.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => url('testing/feeds/files-remote.csv', array(
        'absolute' => TRUE,
      )),
    );
    $this
      ->drupalPost('import/csv', $edit, 'Import');
    $this
      ->assertText('Created 5 nodes');

    // Assert files exist.
    $files = $this
      ->listTestFiles();
    foreach ($files as $file) {
      $file_path = drupal_realpath('public://') . '/' . str_replace(' ', '_', $file);
      $this
        ->assertTrue(file_exists($file_path), format_string('The file %file exists.', array(
        '%file' => $file_path,
      )));
    }

    // Assert files exists with the expected alt/title on node edit form.
    $entities = db_select('feeds_item')
      ->fields('feeds_item', array(
      'entity_id',
    ))
      ->condition('id', 'csv')
      ->execute()
      ->fetchAll();
    foreach ($entities as $i => $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertRaw(str_replace(' ', '_', array_shift($files)));
      $this
        ->assertRaw("Alt text {$i}");
      $this
        ->assertRaw("Title text {$i}");
    }

    // Import CSV with empty alt/title fields and check if these are removed.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => url('testing/feeds/files-empty-alt-title.csv', array(
        'absolute' => TRUE,
      )),
    );
    $this
      ->drupalPost('import/csv', $edit, 'Import');
    $this
      ->assertText('Updated 5 nodes');
    $files = $this
      ->listTestFiles();
    foreach ($entities as $i => $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertRaw(str_replace(' ', '_', array_shift($files)));
      $this
        ->assertNoRaw("Alt text {$i}");
      $this
        ->assertNoRaw("Title text {$i}");
    }

    // Import CSV with empty file fields and check if all files are removed.
    $edit = array(
      'feeds[FeedsHTTPFetcher][source]' => url('testing/feeds/files-empty.csv', array(
        'absolute' => TRUE,
      )),
    );
    $this
      ->drupalPost('import/csv', $edit, 'Import');
    $this
      ->assertText('Updated 5 nodes');

    // Assert files are removed.
    $files = $this
      ->listTestFiles();
    foreach ($files as $file) {
      $file_path = drupal_realpath('public://') . '/' . str_replace(' ', '_', $file);
      $this
        ->assertFalse(file_exists($file_path), format_string('The file %file no longer exists.', array(
        '%file' => $file_path,
      )));
    }

    // Check if the files are removed from the node edit form as well.
    foreach ($entities as $i => $entity) {
      $this
        ->drupalGet('node/' . $entity->entity_id . '/edit');
      $this
        ->assertNoRaw(str_replace(' ', '_', array_shift($files)));
    }
  }

  /**
   * Creates a content type with a file field.
   *
   * @param string $dest
   *   The folder to save files to. Leave empty to not set that.
   *
   * @return string
   *   The name of the content type that was created.
   */
  protected function createContentTypeWithFileField($dest = '') {
    $typename = $this
      ->createContentType(array(), array(
      'files' => array(
        'type' => 'file',
        'instance_settings' => array(
          'instance[settings][file_extensions]' => 'png, gif, jpg, jpeg',
        ),
      ),
    ));

    // Set a destination folder, if given.
    if ($dest) {
      $edit = array(
        'instance[settings][file_directory]' => $dest,
      );
      $this
        ->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_files', $edit, t('Save settings'));
    }
    return $typename;
  }

  /**
   * Checks if SimplePie is available and eventually downloads it.
   */
  protected function requireSimplePie() {
    if (!feeds_simplepie_exists()) {
      $this
        ->downloadExtractSimplePie('1.3');
      $this
        ->assertTrue(feeds_simplepie_exists());

      // Reset all the caches!
      $this
        ->resetAll();
    }
  }

  /**
   * Lists test files.
   */
  protected function listTestFiles() {
    return array(
      'tubing.jpeg',
      'foosball.jpeg',
      'attersee.jpeg',
      'hstreet.jpeg',
      'la fayette.jpeg',
    );
  }

  /**
   * Lists test files mapping.
   *
   * Used to rename images so the ::testFileExistsReplace() test can check if
   * they are replaced on import.
   *
   * @see testFileExistsReplace()
   */
  protected function listTestFilesNameMap() {
    return array(
      'la fayette.jpeg' => 'tubing.jpeg',
      'tubing.jpeg' => 'foosball.jpeg',
      'foosball.jpeg' => 'attersee.jpeg',
      'attersee.jpeg' => 'hstreet.jpeg',
      'hstreet.jpeg' => 'la fayette.jpeg',
    );
  }

}

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
FeedsMapperFileTestCase::createContentTypeWithFileField protected function Creates a content type with a file field.
FeedsMapperFileTestCase::getInfo public static function
FeedsMapperFileTestCase::listTestFiles protected function Lists test files.
FeedsMapperFileTestCase::listTestFilesNameMap protected function Lists test files mapping.
FeedsMapperFileTestCase::requireSimplePie protected function Checks if SimplePie is available and eventually downloads it.
FeedsMapperFileTestCase::setUp public function Sets up a Drupal site for running functional and integration tests. Overrides FeedsWebTestCase::setUp
FeedsMapperFileTestCase::test public function Basic test loading a single entry CSV file.
FeedsMapperFileTestCase::testClearOutValues public function Tests if values are cleared out when an empty value or no value is provided.
FeedsMapperFileTestCase::testFileExistsRename public function Test mapping of local resources with the file exists "Rename" setting.
FeedsMapperFileTestCase::testFileExistsRenameIfDifferent public function Test mapping of local resources with the file exists "Rename if different" setting.
FeedsMapperFileTestCase::testFileExistsReplace public function Test mapping of local resources with the file exists "Replace" setting.
FeedsMapperFileTestCase::testFileExistsReplaceIfDifferent public function Test mapping of local resources with the file exists "Replace if different" setting.
FeedsMapperFileTestCase::testFileExistsSkip public function Test mapping of local resources with the file exists "Skip existig" setting.
FeedsMapperFileTestCase::testImages public function Tests mapping to an image field.
FeedsMapperFileTestCase::testInvalidFileExtension public function
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.