8e2950995ed57be9667764d4aed5db5dd8cb1377
6 * Test case for CCK date field mapper mappers/date.inc.
9 require_once(drupal_get_path('module', 'feeds') .
'/tests/feeds_mapper_test.inc');
12 * Class for testing Feeds <em>content</em> mapper.
14 * @todo: Add test method iCal
15 * @todo: Add test method for end date
17 class FeedsMapperDateTestCase
extends FeedsMapperTestCase
{
19 public static
function getInfo() {
21 'name' => t('Mapper: Date'),
22 'description' => t('Test Feeds Mapper support for CCK Date fields. <strong>Requires CCK and Date module</strong>.'),
23 'group' => t('Feeds'),
30 public
function setUp() {
31 // Call parent setup with the required module.
32 parent
::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'content', 'date_api', 'date');
34 // Create user and login.
35 $this->drupalLogin($this->drupalCreateUser(
37 'administer content types',
40 'administer site configuration',
46 * Basic test loading a single entry CSV file.
48 public
function test() {
49 // Create content type.
50 $typename = $this->createContentType(NULL
, array(
52 'datestamp' => 'datestamp',
53 'datetime' => 'datetime',
56 // Create and configure importer.
57 $this->createImporterConfiguration('Date RSS', 'daterss');
58 $this->setSettings('daterss', NULL
, array('content_type' => '', 'import_period' => FEEDS_SCHEDULE_NEVER
,));
59 $this->setPlugin('daterss', 'FeedsFileFetcher');
60 $this->setPlugin('daterss', 'FeedsSyndicationParser');
61 $this->setSettings('daterss', 'FeedsNodeProcessor', array('content_type' => $typename));
62 $this->addMappings('daterss', array(
68 'source' => 'description',
72 'source' => 'timestamp',
73 'target' => 'field_date:start',
76 'source' => 'timestamp',
77 'target' => 'field_datestamp:start',
82 $this->importFile('daterss', $this->absolutePath() .
'/tests/feeds/googlenewstz.rss2');
83 $this->assertText('Created 6 '.
$typename .
' nodes.');
85 // Check the imported nodes.
94 for ($i = 1; $i <= 6; $i++) {
95 $this->drupalGet("node/$i/edit");
96 $this->assertCCKFieldValue('date', $values[$i-1]);
97 $this->assertCCKFieldValue('datestamp', $values[$i-1]);
101 protected
function getFormFieldsNames($field_name, $index) {
102 if (in_array($field_name, array('date', 'datetime', 'datestamp'))) {
103 return array("field_{$field_name}[{$index}][value][date]");
106 return parent
::getFormFieldsNames($field_name, $index);