feeds_mapper_hooks.test 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. * Contains FeedsMapperHookTestCase.
  5. */
  6. /**
  7. * Test case for the various callbacks implemented for mappers.
  8. */
  9. class FeedsMapperHookTestCase extends FeedsMapperTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Mapper: Hooks and callbacks',
  13. 'description' => 'Test case for the various callbacks implemented for mappers.',
  14. 'group' => 'Feeds',
  15. );
  16. }
  17. /**
  18. * Basic test loading a double entry CSV file.
  19. */
  20. public function test() {
  21. // Create and configure importer.
  22. $this->createImporterConfiguration();
  23. $this->addMappings('syndication', array(
  24. 0 => array(
  25. 'source' => 'title',
  26. 'target' => 'title',
  27. ),
  28. 1 => array(
  29. 'source' => 'description',
  30. 'target' => 'test_target',
  31. ),
  32. ));
  33. // Checks that alter hooks are invoked.
  34. $this->assertText(t('The target description was altered.'));
  35. // Inherently tests preprocess callbacks.
  36. // @see feeds_tests_mapper_set_target()
  37. $nid = $this->createFeedNode();
  38. $this->drupalGet('node/2/edit');
  39. $body_value = $this->xpath('//*[@name = "body[und][0][value]"]');
  40. $value = unserialize((string) $body_value[0]);
  41. $this->assertTrue(!empty($value));
  42. // Tests old-style target keys.
  43. $this->addMappings('syndication', array(
  44. 2 => array(
  45. 'source' => 'url',
  46. 'target' => 'test_target_compat',
  47. ),
  48. ));
  49. // Click gear to get form.
  50. $this->drupalPostAJAX(NULL, array(), 'mapping_settings_edit_2');
  51. // Set some settings.
  52. $edit = array(
  53. 'config[2][settings][checkbox]' => 1,
  54. 'config[2][settings][textfield]' => 'Some text',
  55. 'config[2][settings][textarea]' => 'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff',
  56. 'config[2][settings][radios]' => 'option1',
  57. 'config[2][settings][select]' => 'option4',
  58. );
  59. $this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_2');
  60. $this->assertText(t('* Changes made to target configuration are stored temporarily. Click Save to make your changes permanent.'));
  61. }
  62. }