drupal core updated to 7.28

This commit is contained in:
Bachir Soussi Chiadmi
2014-07-07 18:53:44 +02:00
parent 10de06dd70
commit c3011cef61
263 changed files with 3331 additions and 8894 deletions

View File

@@ -571,6 +571,8 @@ class NodeCreationTestCase extends DrupalWebTestCase {
);
try {
// An exception is generated by node_test_exception_node_insert() if the
// title is 'testing_transaction_exception'.
node_save((object) $edit);
$this->fail(t('Expected exception has not been thrown.'));
}
@@ -1363,6 +1365,22 @@ class NodeSaveTestCase extends DrupalWebTestCase {
$node = node_load($node->nid);
$this->assertEqual($node->title, 'updated_presave', 'Static cache has been cleared.');
}
/**
* Tests saving a node on node insert.
*
* This test ensures that a node has been fully saved when hook_node_insert()
* is invoked, so that the node can be saved again in a hook implementation
* without errors.
*
* @see node_test_node_insert()
*/
function testNodeSaveOnInsert() {
// node_test_node_insert() triggers a save on insert if the title equals
// 'new'.
$node = $this->drupalCreateNode(array('title' => 'new'));
$this->assertEqual($node->title, 'Node ' . $node->nid, 'Node saved on node insert.');
}
}
/**
@@ -2426,6 +2444,35 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input)));
}
// Repeat for a node without a summary.
$settings['body'] = array(LANGUAGE_NONE => array(array('value' => $this->randomName(32), 'summary' => '')));
$node = $this->drupalCreateNode($settings);
// Load node (without summary) so that the body and summary fields are
// structured properly.
$node = node_load($node->nid);
$instance = field_info_instance('node', 'body', $node->type);
// Generate and test sanitized token - use full body as expected value.
$tests = array();
$tests['[node:summary]'] = _text_sanitize($instance, $langcode, $node->body[$langcode][0], 'value');
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.');
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('language' => $language));
$this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced for node without a summary.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
$tests['[node:summary]'] = $node->body[$langcode][0]['value'];
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input)));
}
}
}
@@ -2755,3 +2802,78 @@ class NodeEntityViewModeAlterTest extends NodeWebTestCase {
$this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.');
}
}
/**
* Tests the cache invalidation of node operations.
*/
class NodePageCacheTest extends NodeWebTestCase {
/**
* An admin user with administrative permissions for nodes.
*/
protected $admin_user;
public static function getInfo() {
return array(
'name' => 'Node page cache test',
'description' => 'Test cache invalidation of node operations.',
'group' => 'Node',
);
}
function setUp() {
parent::setUp();
variable_set('cache', 1);
variable_set('page_cache_maximum_age', 300);
$this->admin_user = $this->drupalCreateUser(array(
'bypass node access',
'access content overview',
'administer nodes',
));
}
/**
* Tests deleting nodes clears page cache.
*/
public function testNodeDelete() {
$node_path = 'node/' . $this->drupalCreateNode()->nid;
// Populate page cache.
$this->drupalGet($node_path);
// Login and delete the node.
$this->drupalLogin($this->admin_user);
$this->drupalPost($node_path . '/delete', array(), t('Delete'));
// Logout and check the node is not available.
$this->drupalLogout();
$this->drupalGet($node_path);
$this->assertResponse(404);
// Create two new nodes.
$nodes[0] = $this->drupalCreateNode();
$nodes[1] = $this->drupalCreateNode();
$node_path = 'node/' . $nodes[0]->nid;
// Populate page cache.
$this->drupalGet($node_path);
// Login and delete the nodes.
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/content');
$edit = array(
'operation' => 'delete',
'nodes[' . $nodes[0]->nid . ']' => TRUE,
'nodes[' . $nodes[1]->nid . ']' => TRUE,
);
$this->drupalPost(NULL, $edit, t('Update'));
$this->drupalPost(NULL, array(), t('Delete'));
// Logout and check the node is not available.
$this->drupalLogout();
$this->drupalGet($node_path);
$this->assertResponse(404);
}
}