View source
<?php
require_once drupal_get_path('module', 'feeds') . '/tests/feeds_mapper_test.inc';
class FeedsMapperLocaleTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => t('Mapper: Locale'),
'description' => t('Test Feeds Mapper support for Locale (Language).'),
'group' => t('Feeds'),
);
}
function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'locale');
$this
->drupalLogin($this
->drupalCreateUser(array(
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration',
'administer languages',
)));
$edit = array(
'langcode' => 'zh-hans',
);
$this
->drupalPost('admin/settings/language/add', $edit, t('Add language'));
$this
->assertText('The language Chinese, Simplified has been created and can now be used.');
$edit = array(
'language_content_type' => TRUE,
);
foreach (array(
'article',
'page',
) as $type) {
$this
->drupalPost("admin/content/node-type/{$type}", $edit, t('Save content type'));
}
$this
->createImporterConfiguration('Syndication', 'syndication');
$this
->addMappings('syndication', array(
array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
array(
'source' => 'description',
'target' => 'body',
'unique' => FALSE,
),
array(
'source' => 'timestamp',
'target' => 'created',
'unique' => FALSE,
),
array(
'source' => 'url',
'target' => 'url',
'unique' => TRUE,
),
array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
));
}
function testInheritLanguage() {
$this
->addMappings('syndication', array(
array(
'source' => 'parent:language',
'target' => 'language',
),
));
$edit = array(
'import_on_create' => FALSE,
);
$this
->drupalPost('admin/structure/feeds/edit/syndication/settings', $edit, 'Save');
$this
->assertText('Do not import on create');
$nid = $this
->createFeedNode();
$edit = array(
'language' => 'zh-hans',
);
$this
->drupalPost("node/{$nid}/edit", $edit, t('Save'));
$this
->drupalPost('node/' . $nid . '/import', array(), 'Import');
$count = db_query("SELECT COUNT(*) FROM {node} WHERE language = 'zh-hans'")
->fetchField();
$this
->assertEqual(11, $count, 'Found correct number of nodes.');
}
}