You are here

class FeedsTamperWebTestCase in Feeds Tamper 7

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

Simple tests for api functionality.

Hierarchy

Expanded class hierarchy of FeedsTamperWebTestCase

File

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

View source
class FeedsTamperWebTestCase extends FeedsTamperWebTestHelper {
  public static function getInfo() {
    return array(
      'name' => 'Feeds Tamper',
      'description' => 'Regression tests for Feeds Tamper.',
      'group' => 'Feeds Tamper',
    );
  }
  public function setUp() {
    parent::setUp();
    $this
      ->createImporterConfiguration();
    $this
      ->addMappings('syndication', array(
      0 => array(
        'source' => 'title',
        'target' => 'title',
        'unique' => FALSE,
      ),
      1 => array(
        'source' => 'guid',
        'target' => 'guid',
        'unique' => TRUE,
      ),
      2 => array(
        'source' => 'description',
        'target' => 'body',
      ),
    ));

    // Set update existing to simplify our lives.
    $this
      ->setSettings('syndication', 'FeedsNodeProcessor', array(
      'update_existing' => 1,
    ));
  }
  public function testBasic() {

    // Test basic plugin adding.
    // Add a no-op explode/implode sequence to verify that we can switch types.
    $this
      ->addTamperPlugin('syndication', 'title', 'explode', array(
      'separator' => '$',
      'limit' => '',
    ));
    $id = $this
      ->addTamperPlugin('syndication', 'title', 'convert_case', array(
      'mode' => 0,
    ));
    $this
      ->addTamperPlugin('syndication', 'title', 'implode', array(
      'glue' => '',
    ));

    // Create feed node, running import automatically.
    $nid = $this
      ->createFeedNode();

    // Assert that all titles were uppercased.
    $this
      ->assertUppercaseDevseedFeedContent();

    // Disable plugin.
    $this
      ->disableTamperPlugin($id);

    //$this->deleteTamperPlugin($id);
    $this
      ->drupalPost('node/' . $nid . '/import', array(), 'Import');
    $this
      ->assertText('Updated 10 nodes.');
    $this
      ->assertDevseedFeedContent();
  }

  /**
   * Integration tests for the copy plugin.
   */
  public function testCopyPlugin() {
    $this
      ->removeMappings('syndication', array(
      2 => array(
        'source' => 'description',
        'target' => 'body',
      ),
    ));
    $this
      ->addMappings('syndication', array(
      2 => array(
        'source' => 'Blank source 1',
        'target' => 'body',
      ),
    ));

    // Test copy to.
    // The case should get converted for the title, but not the body.
    $copy = $this
      ->addTamperPlugin('syndication', 'title', 'copy', array(
      'to_from' => 'to',
      'source' => 'Blank source 1',
    ));
    $convert_case = $this
      ->addTamperPlugin('syndication', 'title', 'convert_case', array(
      'mode' => 0,
    ));

    // Create feed node, running import automatically.
    $nid = $this
      ->createFeedNode();
    $this
      ->drupalGet('node/2/edit');
    $this
      ->assertFieldByXPath("//textarea[@name='body[und][0][value]']", 'Open Atrium Translation Workflow: Two Way Translation Updates', 'The textfield widget is populated.');
    $this
      ->assertFieldByName('title', 'OPEN ATRIUM TRANSLATION WORKFLOW: TWO WAY TRANSLATION UPDATES');
    $this
      ->disableTamperPlugin($convert_case);
    $this
      ->addTamperPlugin('syndication', 'Blank source 1', 'convert_case', array(
      'mode' => 0,
    ));
    $this
      ->drupalPost('node/' . $nid . '/import', array(), 'Import');
    $this
      ->drupalGet('node/2/edit');
    $this
      ->assertFieldByXPath("//textarea[@name='body[und][0][value]']", 'OPEN ATRIUM TRANSLATION WORKFLOW: TWO WAY TRANSLATION UPDATES', 'The textfield widget is populated.');
    $this
      ->assertFieldByName('title', 'Open Atrium Translation Workflow: Two Way Translation Updates');
  }

}

Members