From 356a126206540c2cadaf17c998801c63d0149775 Mon Sep 17 00:00:00 2001 From: Lars Toomre Date: Thu, 4 Oct 2012 02:27:24 -0400 Subject: [PATCH] Further clean-up of t() removal from test asserts. --- .../Drupal/node/Tests/NodeAccessRecordsTest.php | 2 +- .../lib/Drupal/node/Tests/NodeLoadHooksTest.php | 8 +++--- .../lib/Drupal/node/Tests/NodeLoadMultipleTest.php | 4 +- .../lib/Drupal/node/Tests/NodeRSSContentTest.php | 4 +- .../node/lib/Drupal/node/Tests/NodeSaveTest.php | 6 ++-- .../lib/Drupal/node/Tests/NodeTokenReplaceTest.php | 4 +- .../node/lib/Drupal/node/Tests/NodeTypeTest.php | 28 ++++++++------------ .../lib/Drupal/node/Tests/SummaryLengthTest.php | 4 +- 8 files changed, 27 insertions(+), 33 deletions(-) diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php index 07a00cf..3bbce9c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php @@ -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 diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php index 5ca7ed6..51dad74 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php @@ -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.'); } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeLoadMultipleTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeLoadMultipleTest.php index 815ab1b..25cb01d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeLoadMultipleTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeLoadMultipleTest.php @@ -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'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php index e82ebcd..8ca8f05 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php @@ -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. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php index f269bf3..00cc53a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php @@ -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.'); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index 0b5f81d..b8d8194 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -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))); } } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php index 3032789..f4e758a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeTest.php @@ -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.'); diff --git a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php index ffdca5b..73fb431 100644 --- a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php @@ -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'); } } -- 1.7.6.msysgit.0