Issue #2395385 by DamienMcKenna: simpletest fatal error when creating a non language neutral node and not specifying a node body
parent
ebd9325ec7
commit
a95cb56beb
|
@ -2237,6 +2237,37 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
|
||||||
|
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that nodes may be created with different languages.
|
||||||
|
*/
|
||||||
|
function testNodeCreationWithLanguage() {
|
||||||
|
// Create an admin user and log them in.
|
||||||
|
$perms = array(
|
||||||
|
// Standard node permissions.
|
||||||
|
'create page content',
|
||||||
|
'administer content types',
|
||||||
|
'administer nodes',
|
||||||
|
'bypass node access',
|
||||||
|
// Locale.
|
||||||
|
'administer languages',
|
||||||
|
);
|
||||||
|
$web_user = $this->drupalCreateUser($perms);
|
||||||
|
$this->drupalLogin($web_user);
|
||||||
|
|
||||||
|
// Create some test nodes using different langcodes.
|
||||||
|
foreach (array(LANGUAGE_NONE, 'en', 'fr') as $langcode) {
|
||||||
|
$node_args = array(
|
||||||
|
'type' => 'page',
|
||||||
|
'promote' => 1,
|
||||||
|
'language' => $langcode,
|
||||||
|
);
|
||||||
|
$node = $this->drupalCreateNode($node_args);
|
||||||
|
$node_reloaded = node_load($node->nid, NULL, TRUE);
|
||||||
|
$this->assertEqual($node_reloaded->language, $langcode, format_string('The language code of the node was successfully set to @langcode.', array('@langcode' => $langcode)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -942,7 +942,6 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||||
protected function drupalCreateNode($settings = array()) {
|
protected function drupalCreateNode($settings = array()) {
|
||||||
// Populate defaults array.
|
// Populate defaults array.
|
||||||
$settings += array(
|
$settings += array(
|
||||||
'body' => array(LANGUAGE_NONE => array(array())),
|
|
||||||
'title' => $this->randomName(8),
|
'title' => $this->randomName(8),
|
||||||
'comment' => 2,
|
'comment' => 2,
|
||||||
'changed' => REQUEST_TIME,
|
'changed' => REQUEST_TIME,
|
||||||
|
@ -957,6 +956,12 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||||
'language' => LANGUAGE_NONE,
|
'language' => LANGUAGE_NONE,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add the body after the language is defined so that it may be set
|
||||||
|
// properly.
|
||||||
|
$settings += array(
|
||||||
|
'body' => array($settings['language'] => array(array())),
|
||||||
|
);
|
||||||
|
|
||||||
// Use the original node's created time for existing nodes.
|
// Use the original node's created time for existing nodes.
|
||||||
if (isset($settings['created']) && !isset($settings['date'])) {
|
if (isset($settings['created']) && !isset($settings['date'])) {
|
||||||
$settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
|
$settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
|
||||||
|
|
Loading…
Reference in New Issue