Commit bfba7b73 authored by jhodgdon's avatar jhodgdon

Issue #1797200 by Lars Toomre, xjm: Remove t() from more test assertions in Node module

parent 02d348a0
......@@ -80,7 +80,7 @@ function testNodeAccessRecords() {
$grants = node_test_node_grants($op, $web_user);
$altered_grants = $grants;
drupal_alter('node_grants', $altered_grants, $web_user, $op);
$this->assertNotEqual($grants, $altered_grants, t('Altered the %op grant for a user.', array('%op' => $op)));
$this->assertNotEqual($grants, $altered_grants, format_string('Altered the %op grant for a user.', array('%op' => $op)));
}
// Check that core does not grant access to an unpublished node when an
......
......@@ -42,15 +42,15 @@ function testHookNodeLoad() {
// reflect the expected values.
$nodes = entity_load_multiple_by_properties('node', array('status' => NODE_PUBLISHED));
$loaded_node = end($nodes);
$this->assertEqual($loaded_node->node_test_loaded_nids, array($node1->nid, $node2->nid), t('hook_node_load() received the correct list of node IDs the first time it was called.'));
$this->assertEqual($loaded_node->node_test_loaded_types, array('article'), t('hook_node_load() received the correct list of node types the first time it was called.'));
$this->assertEqual($loaded_node->node_test_loaded_nids, array($node1->nid, $node2->nid), 'hook_node_load() received the correct list of node IDs the first time it was called.');
$this->assertEqual($loaded_node->node_test_loaded_types, array('article'), 'hook_node_load() received the correct list of node types the first time it was called.');
// Now, as part of the same page request, load a set of nodes that contain
// both articles and pages, and make sure the parameters passed to
// node_test_node_load() are correctly updated.
$nodes = entity_load_multiple_by_properties('node', array('status' => NODE_NOT_PUBLISHED));
$loaded_node = end($nodes);
$this->assertEqual($loaded_node->node_test_loaded_nids, array($node3->nid, $node4->nid), t('hook_node_load() received the correct list of node IDs the second time it was called.'));
$this->assertEqual($loaded_node->node_test_loaded_types, array('article', 'page'), t('hook_node_load() received the correct list of node types the second time it was called.'));
$this->assertEqual($loaded_node->node_test_loaded_nids, array($node3->nid, $node4->nid), 'hook_node_load() received the correct list of node IDs the second time it was called.');
$this->assertEqual($loaded_node->node_test_loaded_types, array('article', 'page'), 'hook_node_load() received the correct list of node types the second time it was called.');
}
}
......@@ -47,12 +47,12 @@ function testNodeMultipleLoad() {
$this->assertEqual($node3->label(), $nodes[$node3->nid]->label(), 'Node was loaded.');
$this->assertEqual($node4->label(), $nodes[$node4->nid]->label(), 'Node was loaded.');
$count = count($nodes);
$this->assertTrue($count == 2, t('@count nodes loaded.', array('@count' => $count)));
$this->assertTrue($count == 2, format_string('@count nodes loaded.', array('@count' => $count)));
// Load nodes by nid. Nodes 1, 2 and 4 will be loaded.
$nodes = node_load_multiple(array(1, 2, 4));
$count = count($nodes);
$this->assertTrue(count($nodes) == 3, t('@count nodes loaded', array('@count' => $count)));
$this->assertTrue(count($nodes) == 3, format_string('@count nodes loaded', array('@count' => $count)));
$this->assertTrue(isset($nodes[$node1->nid]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node2->nid]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node4->nid]), 'Node is correctly keyed in the array');
......
......@@ -58,7 +58,7 @@ function testNodeRSSContent() {
// Check that content added in view modes other than 'rss' doesn't
// appear in RSS feed.
$non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->nid));
$this->assertNoText($non_rss_content, t('Node content not designed for RSS doesn\'t appear in RSS feed.'));
$this->assertNoText($non_rss_content, 'Node content not designed for RSS does not appear in RSS feed.');
// Check that extra RSS elements and namespaces are added to RSS feed.
$test_element = array(
......@@ -72,7 +72,7 @@ function testNodeRSSContent() {
// Check that content added in 'rss' view mode doesn't appear when
// viewing node.
$this->drupalGet("node/$node->nid");
$this->assertNoText($rss_only_content, t('Node content designed for RSS doesn\'t appear when viewing node.'));
$this->assertNoText($rss_only_content, 'Node content designed for RSS does not appear when viewing node.');
// Check that the node feed page does not try to interpret additional path
// components as arguments for node_feed() and returns default content.
......
......@@ -84,7 +84,7 @@ function testRevisions() {
$this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/revert", array(), t('Revert'));
$this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.',
array('@type' => 'Basic page', '%title' => $nodes[1]->label(),
'%revision-date' => format_date($nodes[1]->revision_timestamp))), t('Revision reverted.'));
'%revision-date' => format_date($nodes[1]->revision_timestamp))), 'Revision reverted.');
$reverted_node = node_load($node->nid);
$this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.');
......@@ -96,7 +96,7 @@ function testRevisions() {
$this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/delete", array(), t('Delete'));
$this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
array('%revision-date' => format_date($nodes[1]->revision_timestamp),
'@type' => 'Basic page', '%title' => $nodes[1]->label())), t('Revision deleted.'));
'@type' => 'Basic page', '%title' => $nodes[1]->label())), 'Revision deleted.');
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->nid, ':vid' => $nodes[1]->vid))->fetchField() == 0, 'Revision not found.');
// Set the revision timestamp to an older date to make sure that the
......
......@@ -59,7 +59,7 @@ function testImport() {
$node = node_submit(entity_create('node', $node));
// Verify that node_submit did not overwrite the user ID.
$this->assertEqual($node->uid, $this->web_user->uid, t('Function node_submit() preserves user ID'));
$this->assertEqual($node->uid, $this->web_user->uid, 'Function node_submit() preserves user ID');
$node->save();
// Test the import.
......@@ -115,7 +115,7 @@ function testTimestamps() {
entity_create('node', $edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertEqual($node->created, 280299600, 'Creating a node uses user-set "created" timestamp.');
$this->assertNotEqual($node->changed, 979534800, t('Creating a node doesn\'t use user-set "changed" timestamp.'));
$this->assertNotEqual($node->changed, 979534800, 'Creating a node does not use user-set "changed" timestamp.');
// Update the timestamps.
$node->created = 979534800;
......@@ -124,7 +124,7 @@ function testTimestamps() {
$node->save();
$node = $this->drupalGetNodeByTitle($edit['title'], TRUE);
$this->assertEqual($node->created, 979534800, 'Updating a node uses user-set "created" timestamp.');
$this->assertNotEqual($node->changed, 280299600, t('Updating a node doesn\'t use user-set "changed" timestamp.'));
$this->assertNotEqual($node->changed, 280299600, 'Updating a node does not use user-set "changed" timestamp.');
}
/**
......
......@@ -67,7 +67,7 @@ function testNodeTokenReplacement() {
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized node token %token replaced.', array('%token' => $input)));
$this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
......@@ -79,7 +79,7 @@ function testNodeTokenReplacement() {
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('node' => $node), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
$this->assertEqual($output, $expected, t('Unsanitized node token %token replaced.', array('%token' => $input)));
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input)));
}
}
}
......@@ -138,33 +138,33 @@ function testNodeTypeStatus() {
node_types_rebuild();
$types = node_type_get_types();
foreach (array('book', 'poll', 'article', 'page') as $type) {
$this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), format_string('%type type is enabled.', array('%type' => $type)));
}
// Disable poll module and the respective type should be marked as disabled.
module_disable(array('poll'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
$this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type disabled."));
$this->assertTrue(!empty($types['poll']->disabled), "Poll module's node type disabled.");
// Disable book module and the respective type should still be active, since
// it is not provided by hook_node_info().
module_disable(array('book'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
$this->assertTrue(isset($types['book']) && empty($types['book']->disabled), t("Book module's node type still active."));
$this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type still disabled."));
$this->assertTrue(isset($types['article']) && empty($types['article']->disabled), t("Article node type still active."));
$this->assertTrue(isset($types['page']) && empty($types['page']->disabled), t("Basic page node type still active."));
$this->assertTrue(isset($types['book']) && empty($types['book']->disabled), "Book module's node type still active.");
$this->assertTrue(!empty($types['poll']->disabled), "Poll module's node type still disabled.");
$this->assertTrue(isset($types['article']) && empty($types['article']->disabled), 'Article node type still active.');
$this->assertTrue(isset($types['page']) && empty($types['page']->disabled), 'Basic page node type still active.');
// Re-enable the modules and verify that the types are active again.
module_enable(array('book', 'poll'), FALSE);
node_types_rebuild();
$types = node_type_get_types();
foreach (array('book', 'poll', 'article', 'page') as $type) {
$this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type)));
$this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), format_string('%type type is enabled.', array('%type' => $type)));
}
}
......@@ -187,10 +187,7 @@ function testNodeTypeDeletion() {
// Attempt to delete the content type, which should not be allowed.
$this->drupalGet('admin/structure/types/manage/' . $type->name . '/delete');
$this->assertRaw(
t(
'%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.',
array('%type' => $type->name)
),
t('%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', array('%type' => $type->name)),
'The content type will not be deleted until all nodes of that type are removed.'
);
$this->assertNoText(t('This action cannot be undone.'), 'The node type deletion confirmation form is not available.');
......@@ -200,10 +197,7 @@ function testNodeTypeDeletion() {
// Attempt to delete the content type, which should now be allowed.
$this->drupalGet('admin/structure/types/manage/' . $type->name . '/delete');
$this->assertRaw(
t(
'Are you sure you want to delete the content type %type?',
array('%type' => $type->name)
),
t('Are you sure you want to delete the content type %type?', array('%type' => $type->name)),
'The content type is available for deletion.'
);
$this->assertText(t('This action cannot be undone.'), 'The node type deletion confirmation form is available.');
......
......@@ -36,7 +36,7 @@ function testSummaryLength() {
$this->drupalGet("node");
// The node teaser when it has 600 characters in length
$expected = 'What is a Drupalism?';
$this->assertRaw($expected, t('Check that the summary is 600 characters in length'), 'Node');
$this->assertRaw($expected, 'Check that the summary is 600 characters in length', 'Node');
// Change the teaser length for "Basic page" content type.
$instance = field_info_instance('node', 'body', $node->type);
......@@ -45,6 +45,6 @@ function testSummaryLength() {
// Attempt to access the front page again and check if the summary is now only 200 characters in length.
$this->drupalGet("node");
$this->assertNoRaw($expected, t('Check that the summary is not longer than 200 characters'), 'Node');
$this->assertNoRaw($expected, 'Check that the summary is not longer than 200 characters', 'Node');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment