[177a560] | 1 | <?php |
---|
| 2 | module_load_include('test', 'feeds', 'tests/feeds_mapper'); |
---|
| 3 | |
---|
| 4 | /** |
---|
| 5 | * @file |
---|
| 6 | * Test case for simple CCK field mapper mappers/email.inc. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /** |
---|
| 10 | * Class for testing Feeds <em>email</em> mapper. |
---|
| 11 | */ |
---|
| 12 | class FeedsMapperEmailTestCase extends FeedsMapperTestCase { |
---|
| 13 | public static function getInfo() { |
---|
| 14 | return array( |
---|
| 15 | 'name' => 'Mapper: Email', |
---|
| 16 | 'description' => 'Test Feeds Mapper support for Email CCK fields.', |
---|
| 17 | 'group' => 'Feeds', |
---|
| 18 | 'dependencies' => array('content', 'email'), |
---|
| 19 | ); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | function setUp() { |
---|
| 23 | parent::setUp(array('content', 'email')); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * Basic test loading a doulbe entry CSV file. |
---|
| 28 | */ |
---|
| 29 | function test() { |
---|
| 30 | |
---|
| 31 | // Create content type. |
---|
| 32 | $typename = $this->createContentType(array(), array( |
---|
| 33 | 'email' => 'email', |
---|
| 34 | )); |
---|
| 35 | |
---|
| 36 | // Create and configure importer. |
---|
| 37 | $this->createImporterConfiguration('Email CSV', 'csv'); |
---|
| 38 | $this->setSettings('csv', NULL, array('content_type' => '', 'import_period' => FEEDS_SCHEDULE_NEVER)); |
---|
| 39 | $this->setPlugin('csv', 'FeedsFileFetcher'); |
---|
| 40 | $this->setPlugin('csv', 'FeedsCSVParser'); |
---|
| 41 | $this->setSettings('csv', 'FeedsNodeProcessor', array('content_type' => $typename)); |
---|
| 42 | $this->addMappings('csv', array( |
---|
| 43 | array( |
---|
| 44 | 'source' => 'title', |
---|
| 45 | 'target' => 'title', |
---|
| 46 | ), |
---|
| 47 | array( |
---|
| 48 | 'source' => 'created', |
---|
| 49 | 'target' => 'created', |
---|
| 50 | ), |
---|
| 51 | array( |
---|
| 52 | 'source' => 'body', |
---|
| 53 | 'target' => 'body', |
---|
| 54 | ), |
---|
| 55 | array( |
---|
| 56 | 'source' => 'email', |
---|
| 57 | 'target' => 'field_email', |
---|
| 58 | ), |
---|
| 59 | )); |
---|
| 60 | |
---|
| 61 | // Import CSV file. |
---|
| 62 | $this->importFile('csv', $this->absolutePath() .'/tests/feeds/email.csv'); |
---|
| 63 | $this->assertText('Created 2 '. $typename .' nodes.'); |
---|
| 64 | |
---|
| 65 | // Check the two imported files. |
---|
| 66 | $this->drupalGet('node/1/edit'); |
---|
| 67 | $this->assertCCKFieldValue('email', 'user1@example.org'); |
---|
| 68 | |
---|
| 69 | $this->drupalGet('node/2/edit'); |
---|
| 70 | $this->assertCCKFieldValue('email', 'user2@example.org'); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * Override parent::getFormFieldsNames(). |
---|
| 75 | */ |
---|
| 76 | protected function getFormFieldsNames($field_name, $index) { |
---|
| 77 | return array("field_{$field_name}[{$index}][email]"); |
---|
| 78 | } |
---|
| 79 | } |
---|