123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- * @file
- * Contains FeedsMapperDateMultipleTestCase.
- */
- /**
- * Test case for CCK date multi-field mapper mappers/date.inc.
- *
- * @todo: Add test method iCal
- * @todo: Add test method for end date
- */
- class FeedsMapperDateMultipleTestCase extends FeedsMapperTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Mapper: Date, multi value fields',
- 'description' => 'Test Feeds Mapper support for CCK multi valiue Date fields.',
- 'group' => 'Feeds',
- 'dependencies' => array('date', 'feeds_xpathparser'),
- );
- }
- public function setUp() {
- parent::setUp(array('date_api', 'date', 'feeds_xpathparser'));
- variable_set('date_default_timezone', 'UTC');
- }
- /**
- * Testing import by loading a 4 item XML file.
- */
- public function test() {
- $this->drupalGet('admin/config/regional/settings');
- // Create content type.
- $typename = $this->createContentType(array(), array(
- 'date' => 'date',
- ));
- // Make the field hold unlimited values
- $edit = array(
- 'field[cardinality]' => -1,
- );
- $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_date', $edit, 'Save settings');
- $this->assertText('Saved date_date_label configuration');
- // Create and configure importer.
- $this->createImporterConfiguration('Multi dates', 'multidates');
- $this->setSettings('multidates', NULL, array(
- 'content_type' => '',
- 'import_period' => FEEDS_SCHEDULE_NEVER,
- ));
- $this->setPlugin('multidates', 'FeedsFileFetcher');
- $this->setPlugin('multidates', 'FeedsXPathParserXML');
- $this->setSettings('multidates', 'FeedsNodeProcessor', array(
- 'bundle' => $typename,
- ));
- $this->addMappings('multidates', array(
- 0 => array(
- 'source' => 'xpathparser:0',
- 'target' => 'title',
- ),
- 1 => array(
- 'source' => 'xpathparser:1',
- 'target' => 'guid',
- ),
- 2 => array(
- 'source' => 'xpathparser:2',
- 'target' => 'field_date:start',
- ),
- ));
- $edit = array(
- 'xpath[context]' => '//item',
- 'xpath[sources][xpathparser:0]' => 'title',
- 'xpath[sources][xpathparser:1]' => 'guid',
- 'xpath[sources][xpathparser:2]' => 'date',
- 'xpath[allow_override]' => FALSE,
- );
- $this->setSettings('multidates', 'FeedsXPathParserXML', $edit);
- $edit = array(
- 'allowed_extensions' => 'xml',
- 'directory' => 'public://feeds',
- );
- $this->setSettings('multidates', 'FeedsFileFetcher', $edit);
- // Import XML file.
- $this->importFile('multidates', $this->absolutePath() . '/tests/feeds/multi-date.xml');
- $this->assertText('Created 4 nodes');
- // Check the imported nodes.
- $values = array(
- 1 => array(
- '01/06/2010 - 15:00',
- '01/07/2010 - 15:15',
- ),
- 2 => array(
- '01/06/2010 - 15:00',
- '01/07/2010 - 15:00',
- '01/08/2010 - 15:00',
- '01/09/2010 - 15:00',
- ),
- 3 => array(
- '', // Bogus date was filtered out.
- ),
- 4 => array(
- '01/06/2010 - 14:00',
- )
- );
- foreach ($values as $v => $key) {
- $this->drupalGet("node/$v/edit");
- foreach ($key as $delta => $value) {
- $this->assertFieldById('edit-field-date-und-' . $delta . '-value-date', $value);
- }
- }
- }
- }
|