1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
41cc1b08
|
Assos Assos
|
* Contains FeedsMapperDateMultipleTestCase.
|
6 |
85ad3d82
|
Assos Assos
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
41cc1b08
|
Assos Assos
|
* Test case for CCK date multi-field mapper mappers/date.inc.
|
10 |
85ad3d82
|
Assos Assos
|
*
|
11 |
|
|
* @todo: Add test method iCal
|
12 |
|
|
* @todo: Add test method for end date
|
13 |
|
|
*/
|
14 |
|
|
class FeedsMapperDateMultipleTestCase extends FeedsMapperTestCase {
|
15 |
41cc1b08
|
Assos Assos
|
|
16 |
85ad3d82
|
Assos Assos
|
public static function getInfo() {
|
17 |
|
|
return array(
|
18 |
|
|
'name' => 'Mapper: Date, multi value fields',
|
19 |
|
|
'description' => 'Test Feeds Mapper support for CCK multi valiue Date fields.',
|
20 |
|
|
'group' => 'Feeds',
|
21 |
|
|
'dependencies' => array('date', 'feeds_xpathparser'),
|
22 |
|
|
);
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
public function setUp() {
|
26 |
|
|
parent::setUp(array('date_api', 'date', 'feeds_xpathparser'));
|
27 |
|
|
variable_set('date_default_timezone', 'UTC');
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* Testing import by loading a 4 item XML file.
|
32 |
|
|
*/
|
33 |
|
|
public function test() {
|
34 |
|
|
$this->drupalGet('admin/config/regional/settings');
|
35 |
|
|
|
36 |
|
|
// Create content type.
|
37 |
|
|
$typename = $this->createContentType(array(), array(
|
38 |
|
|
'date' => 'date',
|
39 |
|
|
));
|
40 |
|
|
// Make the field hold unlimited values
|
41 |
|
|
$edit = array(
|
42 |
|
|
'field[cardinality]' => -1,
|
43 |
|
|
);
|
44 |
|
|
$this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_date', $edit, 'Save settings');
|
45 |
|
|
$this->assertText('Saved date_date_label configuration');
|
46 |
|
|
|
47 |
|
|
// Create and configure importer.
|
48 |
|
|
$this->createImporterConfiguration('Multi dates', 'multidates');
|
49 |
|
|
$this->setSettings('multidates', NULL, array(
|
50 |
|
|
'content_type' => '',
|
51 |
|
|
'import_period' => FEEDS_SCHEDULE_NEVER,
|
52 |
|
|
));
|
53 |
|
|
$this->setPlugin('multidates', 'FeedsFileFetcher');
|
54 |
|
|
$this->setPlugin('multidates', 'FeedsXPathParserXML');
|
55 |
|
|
|
56 |
|
|
$this->setSettings('multidates', 'FeedsNodeProcessor', array(
|
57 |
|
|
'bundle' => $typename,
|
58 |
|
|
));
|
59 |
|
|
$this->addMappings('multidates', array(
|
60 |
|
|
0 => array(
|
61 |
|
|
'source' => 'xpathparser:0',
|
62 |
|
|
'target' => 'title',
|
63 |
|
|
),
|
64 |
|
|
1 => array(
|
65 |
|
|
'source' => 'xpathparser:1',
|
66 |
|
|
'target' => 'guid',
|
67 |
|
|
),
|
68 |
|
|
2 => array(
|
69 |
|
|
'source' => 'xpathparser:2',
|
70 |
|
|
'target' => 'field_date:start',
|
71 |
|
|
),
|
72 |
|
|
));
|
73 |
|
|
|
74 |
|
|
$edit = array(
|
75 |
|
|
'xpath[context]' => '//item',
|
76 |
|
|
'xpath[sources][xpathparser:0]' => 'title',
|
77 |
|
|
'xpath[sources][xpathparser:1]' => 'guid',
|
78 |
|
|
'xpath[sources][xpathparser:2]' => 'date',
|
79 |
|
|
'xpath[allow_override]' => FALSE,
|
80 |
|
|
);
|
81 |
|
|
$this->setSettings('multidates', 'FeedsXPathParserXML', $edit);
|
82 |
|
|
|
83 |
|
|
$edit = array(
|
84 |
|
|
'allowed_extensions' => 'xml',
|
85 |
|
|
'directory' => 'public://feeds',
|
86 |
|
|
);
|
87 |
|
|
$this->setSettings('multidates', 'FeedsFileFetcher', $edit);
|
88 |
|
|
|
89 |
|
|
// Import XML file.
|
90 |
|
|
$this->importFile('multidates', $this->absolutePath() . '/tests/feeds/multi-date.xml');
|
91 |
|
|
$this->assertText('Created 4 nodes');
|
92 |
|
|
|
93 |
|
|
// Check the imported nodes.
|
94 |
|
|
$values = array(
|
95 |
|
|
1 => array(
|
96 |
|
|
'01/06/2010 - 15:00',
|
97 |
|
|
'01/07/2010 - 15:15',
|
98 |
|
|
),
|
99 |
|
|
2 => array(
|
100 |
|
|
'01/06/2010 - 15:00',
|
101 |
|
|
'01/07/2010 - 15:00',
|
102 |
|
|
'01/08/2010 - 15:00',
|
103 |
|
|
'01/09/2010 - 15:00',
|
104 |
|
|
),
|
105 |
|
|
3 => array(
|
106 |
|
|
'', // Bogus date was filtered out.
|
107 |
|
|
),
|
108 |
|
|
4 => array(
|
109 |
|
|
'01/06/2010 - 14:00',
|
110 |
|
|
)
|
111 |
|
|
);
|
112 |
|
|
foreach ($values as $v => $key) {
|
113 |
|
|
$this->drupalGet("node/$v/edit");
|
114 |
|
|
foreach ($key as $delta => $value) {
|
115 |
|
|
$this->assertFieldById('edit-field-date-und-' . $delta . '-value-date', $value);
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
41cc1b08
|
Assos Assos
|
|
120 |
85ad3d82
|
Assos Assos
|
} |