Newer
Older
Alex Barth
committed
<?php
// $Id$
/**
* @file
* Test case for simple CCK field mapper mappers/content.inc.
*/
require_once(drupal_get_path('module', 'feeds') . '/tests/feeds_mapper_test.inc');
/**
* Class for testing Feeds <em>content</em> mapper.
*/
class FeedsMapperContentTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => t('Mapper: Content'),
'description' => t('Test Feeds Mapper support for CCK fields. <strong>Requires CCK module</strong>.'),
Alex Barth
committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
'group' => t('Feeds'),
);
}
/**
* Set up the test.
*/
function setUp() {
// Call parent setup with required modules.
parent::setUp('feeds', 'feeds_ui', 'ctools', 'content', 'number', 'text');
// Create user and login.
$this->drupalLogin($this->drupalCreateUser(
array(
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration'
)
));
}
/**
* Basic test loading a doulbe entry CSV file.
*/
function test() {
// Create content type.
$typename = $this->createContentType(NULL, array(
'alpha' => 'text',
'beta' => 'number_integer',
'gamma' => 'number_decimal',
));
// Create and configure importer.
$this->createFeedConfiguration('Content CSV', 'csv');
$this->setSettings('csv', NULL, array('content_type' => '','import_period' => FEEDS_SCHEDULE_NEVER,));
$this->setPlugin('csv', 'FeedsFileFetcher');
$this->setPlugin('csv', 'FeedsCSVParser');
$this->setSettings('csv', 'FeedsNodeProcessor', array('content_type' => $typename));
$this->addMappings('csv', array(
array(
'source' => 'title',
'target' => 'title',
),
array(
'source' => 'created',
'target' => 'created',
),
array(
'source' => 'body',
'target' => 'body',
),
array(
'source' => 'alpha',
'target' => 'field_alpha',
),
array(
'source' => 'beta',
'target' => 'field_beta',
),
array(
'source' => 'gamma',
'target' => 'field_gamma',
),
));
// Import CSV file.
$this->importFile('csv', $this->absolutePath() .'/tests/feeds/content.csv');
$this->assertText('Created 2 '. $typename .' nodes.');
// Check the two imported files.
$this->drupalGet('node/1/edit');
$this->assertCCKFieldValue('alpha', 'Lorem');
$this->assertCCKFieldValue('beta', '42');
$this->assertCCKFieldValue('gamma', '4.20');
$this->drupalGet('node/2/edit');
$this->assertCCKFieldValue('alpha', 'Ut wisi');
$this->assertCCKFieldValue('beta', '32');
$this->assertCCKFieldValue('gamma', '1.20');
}
}