public function FeedsTamperUIWebTestCase::testBasic in Feeds Tamper 6        
                          
                  
                        Same name and namespace in other branches
- 8.2 legacy/feeds_tamper_ui/tests/feeds_tamper_ui.test \FeedsTamperUIWebTestCase::testBasic()
- 7 feeds_tamper_ui/tests/feeds_tamper_ui.test \FeedsTamperUIWebTestCase::testBasic()
File
 
   - feeds_tamper_ui/tests/feeds_tamper_ui.test, line 24
- Tests for feeds_tamper_ui.module.
Class
  
  - FeedsTamperUIWebTestCase 
- Test Feeds Tamper UI.
Code
public function testBasic() {
  $importer = $this
    ->randomName();
  $importer_name = $this
    ->randomString();
  $mapping_url = FEEDS_TAMPER_UI_FEEDS_BASE . '/edit/' . $importer . '/mapping';
  $this
    ->createImporterConfiguration($importer_name, $importer);
  $this
    ->drupalGet(FEEDS_TAMPER_UI_BASE . '/list/' . $importer);
  $this
    ->assertText('There are no mappings defined for this importer.');
  $this
    ->addMappings($importer, array(
    0 => array(
      'source' => 'title',
      'target' => 'title',
      'unique' => FALSE,
    ),
    1 => array(
      'source' => 'guid',
      'target' => 'guid',
      'unique' => TRUE,
    ),
    2 => array(
      'source' => 'description',
      'target' => 'body',
      'unique' => FALSE,
    ),
  ));
  
  $this
    ->drupalGet(FEEDS_TAMPER_UI_FEEDS_BASE . '/list');
  $this
    ->assertText('Edit | Export | Clone | Delete | Tamper');
  
  $this
    ->drupalGet($mapping_url);
  $this
    ->assertRaw('<a href="' . url(FEEDS_TAMPER_UI_BASE . '/list/' . $importer) . '">Configure Feeds Tamper</a>');
  
  $this
    ->drupalGet(FEEDS_TAMPER_UI_BASE . '/list/' . $importer);
  $this
    ->assertRaw('Configure plugins to modify Feeds data before it gets saved. Each <a href="' . url(FEEDS_TAMPER_UI_FEEDS_BASE . '/edit/' . $importer . '/mapping') . '">mapping</a> can be manipulated individually.');
  
  $settings = array(
    'settings[mode]' => 0,
  );
  $id = $this
    ->addTamperPlugin($importer, 'title', 'convert_case', $settings);
  
  $nid = $this
    ->createFeedNode($importer);
  
  $this
    ->drupalGet('node');
  $this
    ->assertUppercaseDevseedFeedContent();
  $this
    ->toggleTamperPlugin($importer, 'title', $id);
  $this
    ->toggleTamperPlugin($importer, 'title', $id, TRUE);
  $this
    ->setTamperPluginWeight($importer, 'title', $id, 2);
  $this
    ->deleteTamperPlugin($id);
  $settings = array(
    'settings[mode]' => 0,
  );
  $case = $this
    ->addTamperPlugin($importer, 'title', 'convert_case', $settings);
  $settings = array(
    'settings[side]' => 'trim',
  );
  $trim = $this
    ->addTamperPlugin($importer, 'title', 'trim', $settings);
  $this
    ->toggleTamperPlugin($importer, 'title', $case);
  $this
    ->toggleTamperPlugin($importer, 'title', $case, TRUE);
  $this
    ->setTamperPluginWeight($importer, 'title', $case, 2);
  $this
    ->deleteTamperPlugin($case);
  $this
    ->deleteTamperPlugin($trim);
  
  $this->feeds_user = $this
    ->drupalCreateUser(array(
    'administer feeds',
  ));
  $this
    ->drupalLogin($this->feeds_user);
  
  $this
    ->drupalGet(FEEDS_TAMPER_UI_FEEDS_BASE . '/list');
  $this
    ->assertText('Edit | Export | Clone | Delete');
  $this
    ->assertNoText('Tamper');
  
  $this
    ->drupalGet($mapping_url);
  $this
    ->assertNoText('Configure Feeds Tamper');
  
  $this
    ->checkPermissions(array(), TRUE);
  $this->feeds_user = $this
    ->drupalCreateUser(array(
    'administer feeds',
    'tamper ' . $importer,
  ));
  $this
    ->drupalLogin($this->feeds_user);
  
  $this
    ->drupalGet(FEEDS_TAMPER_UI_FEEDS_BASE . '/list');
  $this
    ->assertText('Edit | Export | Clone | Delete | Tamper');
  
  $this
    ->drupalGet($mapping_url);
  $this
    ->assertText('Configure Feeds Tamper');
  $this
    ->drupalLogin($this->admin_user);
  
  $settings = array(
    'remove_flags[0]' => TRUE,
  );
  $this
    ->drupalPost($mapping_url, $settings, 'Save');
  $this
    ->addMappings($importer, array(
    array(
      'source' => 'Blank source 1',
      'target' => 'title',
    ),
  ));
  
  $this
    ->assertFieldByXPath('id("edit-source")/option[text() = "Blank source"]/@value', 'Blank source 2');
  
  $this
    ->drupalPost('node/' . $nid . '/delete-items', array(), 'Delete');
  
  $id = $this
    ->addTamperPlugin($importer, 'Blank source 1', 'hash');
  
  $this
    ->drupalPost('node/' . $nid . '/import', array(), 'Import');
  $this
    ->assertHashedDevseedFeedContent();
  
  $this
    ->drupalPost('node/' . $nid . '/delete-items', array(), 'Delete');
  node_delete($nid);
  $this
    ->drupalPost(FEEDS_TAMPER_UI_FEEDS_BASE . '/delete/' . $importer, array(), 'Delete');
  
  $this
    ->_testCSV();
}