You are here

class FeedsTamperWebTestHelper in Feeds Tamper 7

Same name and namespace in other branches
  1. 6 tests/feeds_tamper.test \FeedsTamperWebTestHelper

Base class for Feeds Tamper tests.

Hierarchy

Expanded class hierarchy of FeedsTamperWebTestHelper

File

tests/feeds_tamper.test, line 11
Tests for feeds_tamper.module.

View source
class FeedsTamperWebTestHelper extends FeedsWebTestCase {
  public function setUp() {
    $args = func_get_args();

    // Build the list of required modules which can be altered by passing in an
    // array of module names to setUp().
    if (isset($args[0])) {
      if (is_array($args[0])) {
        $modules = $args[0];
      }
      else {
        $modules = $args;
      }
    }
    else {
      $modules = array();
    }
    if (isset($args[1]) && is_array($args[1])) {
      $permissions = $args[1];
    }
    else {
      $permissions = array();
    }
    $modules[] = 'feeds_tamper';
    parent::setUp($modules, $permissions);

    // Detect if Feeds menu structure has changed. This will take a while to be
    // released, but since I run dev it needs to work.
    $feeds_menu = feeds_ui_menu();
    if (isset($feeds_menu['admin/structure/feeds/list'])) {
      $this->feeds_base = 'admin/structure/feeds/edit';
    }
    else {
      $this->feeds_base = 'admin/structure/feeds';
    }
  }
  protected function addTamperPlugin($importer_id, $source, $plugin_id, $settings = array(), $description = '', $id = NULL) {
    $plugin_info = feeds_tamper_get_plugin($plugin_id);
    if ($plugin_info['validate']) {
      $plugin_info['validate']($settings);
    }
    $plugin = feeds_tamper_new_instance();
    if (!empty($settings)) {
      $plugin->settings = $settings;
    }
    $plugin->importer = $importer_id;
    $plugin->source = $source;
    $plugin->plugin_id = $plugin_id;
    if (!strlen($description)) {
      $description = $this
        ->randomString(255);
    }
    if (!isset($id)) {
      $id = $this
        ->randomName();
    }
    $plugin->id = $id;
    $plugin->description = $description;
    $this
      ->assertEqual(SAVED_NEW, feeds_tamper_save_instance($plugin));
    $result = db_query("SELECT * FROM {feeds_tamper} WHERE id = :id", array(
      ':id' => $plugin->id,
    ));

    // test that default weight is added.
    $instance = $result
      ->fetchObject();
    $this
      ->assertTrue($instance->weight >= 0);
    $this
      ->assertEqual($instance->description, $description);

    // Check for only 1 item.
    $this
      ->assertIdentical($result
      ->rowCount(), 1);
    return $id;
  }
  protected function disableTamperPlugin($id) {
    $plugin = feeds_tamper_load_instance($id);
    $plugin->disabled = TRUE;
    $this
      ->assertEqual(SAVED_UPDATED, feeds_tamper_save_instance($plugin));

    // reload and test that changes were kept.
    $plugin = feeds_tamper_load_instance($id);
    $this
      ->assertIdentical(TRUE, $plugin->disabled);
  }
  protected function setTamperPluginWeight($importer_id, $source, $id, $weight) {
  }
  protected function deleteTamperPlugin($id) {
    feeds_tamper_delete_instance($id);

    //$source = db_query("SELECT * FROM {feeds_source} WHERE feed_nid = :nid", array(':nid' => $nid))->fetchObject();
  }
  protected function assertUppercaseDevseedFeedContent() {
    $this
      ->drupalGet('node');
    $this
      ->assertText('SCALING THE OPEN ATRIUM UI');
    $this
      ->assertText("PERU'S SOFTWARE FREEDOM DAY: IMPRESSIONS & PHOTOS");
    $this
      ->assertText('WEEK IN DC TECH: SEPTEMBER 21 EDITION');
    $this
      ->assertText('INTEGRATING THE SITEMINDER ACCESS SYSTEM IN AN OPEN ATRIUM-BASED INTRANET');
    $this
      ->assertText('OPEN DATA FOR MICROFINANCE: THE NEW MIXMARKET.ORG');
    $this
      ->assertText('WEEK IN DC TECH: SEPTEMBER 28TH EDITION');
    $this
      ->assertText('SEPTEMBER GEODC MEETUP TONIGHT');
    $this
      ->assertText('MAPPING INNOVATION AT THE WORLD BANK WITH OPEN ATRIUM');
    $this
      ->assertText('WEEK IN DC TECH: OCTOBER 5TH EDITION');
    $this
      ->assertText('OPEN ATRIUM TRANSLATION WORKFLOW: TWO WAY TRANSLATION UPDATES');
  }
  protected function assertDevseedFeedContent() {
    $this
      ->drupalGet('node');
    $this
      ->asserttext('Scaling the Open Atrium UI');
    $this
      ->asserttext("Peru's Software Freedom Day: Impressions & Photos");
    $this
      ->asserttext('Week in DC Tech: September 21 Edition');
    $this
      ->asserttext('Integrating the Siteminder Access System in an Open Atrium-based Intranet');
    $this
      ->asserttext('Open Data for Microfinance: The New MIXMarket.org');
    $this
      ->asserttext('Week in DC Tech: September 28th Edition');
    $this
      ->asserttext('September GeoDC Meetup Tonight');
    $this
      ->asserttext('Mapping Innovation at the World Bank with Open Atrium');
    $this
      ->asserttext('Week in DC Tech: October 5th Edition');
    $this
      ->asserttext('Open Atrium Translation Workflow: Two Way Translation Updates');
  }
  protected function assertHashedDevseedFeedContent() {
    $this
      ->drupalGet('node');
    $this
      ->asserttext('b802e0e74831d506bcafd3e0d8339c0c');
    $this
      ->asserttext('40dd7b1ae61ad8b1fb55d662b8ca77c4');
    $this
      ->asserttext('40bcfee6c3ddb980236f2f1f2a519fb3');
    $this
      ->asserttext('5e0c93b1474072e82f4c53db02fc2c7f');
    $this
      ->asserttext('8611ee43370358cb8a12a9e87894cdca');
    $this
      ->asserttext('69691b749f4f8a512c9d4a74e50d2e0b');
    $this
      ->asserttext('520cd4cd49ae68c99cf5ed82d1dd6e02');
    $this
      ->asserttext('429b46ca20f2c36739ca4ec88459f826');
    $this
      ->asserttext('a6b22dae5037ba2d1d57d648fc220f04');
    $this
      ->asserttext('643f31f2955072c52390fd5828b2745a');
  }

}

Members