123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- /**
- * @file
- * Test case for CCK date field mapper mappers/date.inc.
- */
- /**
- * Class for testing Feeds <em>content</em> mapper.
- *
- * @todo: Add test method iCal
- * @todo: Add test method for end date
- */
- class FeedsMapperDateTestCase extends FeedsMapperTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Mapper: Date',
- 'description' => 'Test Feeds Mapper support for CCK Date fields.',
- 'group' => 'Feeds',
- 'dependencies' => array('date'),
- );
- }
- public function setUp() {
- parent::setUp(array('date_api', 'date'));
- variable_set('date_default_timezone', 'UTC');
- }
- /**
- * Basic test loading a single entry CSV file.
- */
- public function test() {
- $this->drupalGet('admin/config/regional/settings');
- // Create content type.
- $typename = $this->createContentType(array(), array(
- 'date' => 'date',
- 'datestamp' => 'datestamp',
- //'datetime' => 'datetime', // REMOVED because the field is broken ATM.
- ));
- // Create and configure importer.
- $this->createImporterConfiguration('Date RSS', 'daterss');
- $this->setSettings('daterss', NULL, array('content_type' => '', 'import_period' => FEEDS_SCHEDULE_NEVER));
- $this->setPlugin('daterss', 'FeedsFileFetcher');
- $this->setPlugin('daterss', 'FeedsSyndicationParser');
- $this->setSettings('daterss', 'FeedsNodeProcessor', array('content_type' => $typename));
- $this->addMappings('daterss', array(
- 0 => array(
- 'source' => 'title',
- 'target' => 'title',
- ),
- 1 => array(
- 'source' => 'description',
- 'target' => 'body',
- ),
- 2 => array(
- 'source' => 'timestamp',
- 'target' => 'field_date:start',
- ),
- 3 => array(
- 'source' => 'timestamp',
- 'target' => 'field_datestamp:start',
- ),
- ));
- $edit = array(
- 'allowed_extensions' => 'rss2',
- );
- $this->drupalPost('admin/structure/feeds/daterss/settings/FeedsFileFetcher', $edit, 'Save');
- // Import CSV file.
- $this->importFile('daterss', $this->absolutePath() . '/tests/feeds/googlenewstz.rss2');
- $this->assertText('Created 6 nodes');
- // Check the imported nodes.
- $values = array(
- '01/06/2010 - 19:26',
- '01/06/2010 - 10:21',
- '01/06/2010 - 13:42',
- '01/06/2010 - 06:05',
- '01/06/2010 - 11:26',
- '01/07/2010 - 00:26',
- );
- for ($i = 1; $i <= 6; $i++) {
- $this->drupalGet("node/$i/edit");
- $this->assertNodeFieldValue('date', $values[$i-1]);
- $this->assertNodeFieldValue('datestamp', $values[$i-1]);
- }
- }
- protected function getFormFieldsNames($field_name, $index) {
- if (in_array($field_name, array('date', 'datetime', 'datestamp'))) {
- return array("field_{$field_name}[und][{$index}][value][date]");
- }
- else {
- return parent::getFormFieldsNames($field_name, $index);
- }
- }
- }
|