From debf5484789d2745e071846a1d88e1f3e592859d Mon Sep 17 00:00:00 2001 From: Lars Toomre Date: Thu, 27 Sep 2012 21:13:10 -0400 Subject: [PATCH] Remove t() from assert messages in tests of system module G-L sub-systems. --- .../Drupal/system/Tests/Graph/GraphUnitTest.php | 12 ++-- .../Drupal/system/Tests/Image/ToolkitGdTest.php | 8 ++-- .../lib/Drupal/system/Tests/Image/ToolkitTest.php | 52 ++++++++++---------- .../Drupal/system/Tests/Image/ToolkitTestBase.php | 8 ++-- .../system/Tests/Lock/LockFunctionalTest.php | 38 +++++++------- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/core/modules/system/lib/Drupal/system/Tests/Graph/GraphUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Graph/GraphUnitTest.php index e1fa8da..a68535c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Graph/GraphUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Graph/GraphUnitTest.php @@ -72,7 +72,7 @@ class GraphUnitTest extends UnitTestBase { $this->assertReversePaths($graph, $expected_reverse_paths); // Assert that DFS didn't created "missing" vertexes automatically. - $this->assertFALSE(isset($graph[6]), t('Vertex 6 has not been created')); + $this->assertFALSE(isset($graph[6]), 'Vertex 6 has not been created'); $expected_components = array( array(1, 2, 3, 4, 5, 7), @@ -119,7 +119,7 @@ class GraphUnitTest extends UnitTestBase { // Build an array with keys = $paths and values = TRUE. $expected = array_fill_keys($paths, TRUE); $result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : array(); - $this->assertEqual($expected, $result, t('Expected paths for vertex @vertex: @expected-paths, got @paths', array('@vertex' => $vertex, '@expected-paths' => $this->displayArray($expected, TRUE), '@paths' => $this->displayArray($result, TRUE)))); + $this->assertEqual($expected, $result, format_string('Expected paths for vertex @vertex: @expected-paths, got @paths', array('@vertex' => $vertex, '@expected-paths' => $this->displayArray($expected, TRUE), '@paths' => $this->displayArray($result, TRUE)))); } } @@ -137,7 +137,7 @@ class GraphUnitTest extends UnitTestBase { // Build an array with keys = $paths and values = TRUE. $expected = array_fill_keys($paths, TRUE); $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : array(); - $this->assertEqual($expected, $result, t('Expected reverse paths for vertex @vertex: @expected-paths, got @paths', array('@vertex' => $vertex, '@expected-paths' => $this->displayArray($expected, TRUE), '@paths' => $this->displayArray($result, TRUE)))); + $this->assertEqual($expected, $result, format_string('Expected reverse paths for vertex @vertex: @expected-paths, got @paths', array('@vertex' => $vertex, '@expected-paths' => $this->displayArray($expected, TRUE), '@paths' => $this->displayArray($result, TRUE)))); } } @@ -157,9 +157,9 @@ class GraphUnitTest extends UnitTestBase { $result_components[] = $graph[$vertex]['component']; unset($unassigned_vertices[$vertex]); } - $this->assertEqual(1, count(array_unique($result_components)), t('Expected one unique component for vertices @vertices, got @components', array('@vertices' => $this->displayArray($component), '@components' => $this->displayArray($result_components)))); + $this->assertEqual(1, count(array_unique($result_components)), format_string('Expected one unique component for vertices @vertices, got @components', array('@vertices' => $this->displayArray($component), '@components' => $this->displayArray($result_components)))); } - $this->assertEqual(array(), $unassigned_vertices, t('Vertices not assigned to a component: @vertices', array('@vertices' => $this->displayArray($unassigned_vertices, TRUE)))); + $this->assertEqual(array(), $unassigned_vertices, format_string('Vertices not assigned to a component: @vertices', array('@vertices' => $this->displayArray($unassigned_vertices, TRUE)))); } /** @@ -174,7 +174,7 @@ class GraphUnitTest extends UnitTestBase { foreach ($expected_orders as $order) { $previous_vertex = array_shift($order); foreach ($order as $vertex) { - $this->assertTrue($graph[$previous_vertex]['weight'] < $graph[$vertex]['weight'], t('Weights of @previous-vertex and @vertex are correct relative to each other', array('@previous-vertex' => $previous_vertex, '@vertex' => $vertex))); + $this->assertTrue($graph[$previous_vertex]['weight'] < $graph[$vertex]['weight'], format_string('Weights of @previous-vertex and @vertex are correct relative to each other', array('@previous-vertex' => $previous_vertex, '@vertex' => $vertex))); } } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php index 611126d..22f6c13 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php @@ -212,7 +212,7 @@ class ToolkitGdTest extends WebTestBase { // All images should be converted to truecolor when loaded. $image_truecolor = imageistruecolor($image->resource); - $this->assertTrue($image_truecolor, t('Image %file after load is a truecolor image.', array('%file' => $file))); + $this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file))); if ($image->info['extension'] == 'gif') { if ($op == 'desaturate') { @@ -248,8 +248,8 @@ class ToolkitGdTest extends WebTestBase { file_prepare_directory($directory, FILE_CREATE_DIRECTORY); image_save($image, $directory . '/' . $op . '.' . $image->info['extension']); - $this->assertTrue($correct_dimensions_real, t('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op))); - $this->assertTrue($correct_dimensions_object, t('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op))); + $this->assertTrue($correct_dimensions_real, format_string('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op))); + $this->assertTrue($correct_dimensions_object, format_string('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op))); // JPEG colors will always be messed up due to compression. if ($image->info['extension'] != 'jpg') { @@ -276,7 +276,7 @@ class ToolkitGdTest extends WebTestBase { } $color = $this->getPixelColor($image, $x, $y); $correct_colors = $this->colorsAreEqual($color, $corner); - $this->assertTrue($correct_colors, t('Image %file object after %action action has the correct color placement at corner %corner.', array('%file' => $file, '%action' => $op, '%corner' => $key))); + $this->assertTrue($correct_colors, format_string('Image %file object after %action action has the correct color placement at corner %corner.', array('%file' => $file, '%action' => $op, '%corner' => $key))); } } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTest.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTest.php index 091fc5a..3e5aadd 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTest.php @@ -25,8 +25,8 @@ class ToolkitTest extends ToolkitTestBase { */ function testGetAvailableToolkits() { $toolkits = image_get_available_toolkits(); - $this->assertTrue(isset($toolkits['test']), t('The working toolkit was returned.')); - $this->assertFalse(isset($toolkits['broken']), t('The toolkit marked unavailable was not returned')); + $this->assertTrue(isset($toolkits['test']), 'The working toolkit was returned.'); + $this->assertFalse(isset($toolkits['broken']), 'The toolkit marked unavailable was not returned'); $this->assertToolkitOperationsCalled(array()); } @@ -35,8 +35,8 @@ class ToolkitTest extends ToolkitTestBase { */ function testLoad() { $image = image_load($this->file, $this->toolkit); - $this->assertTrue(is_object($image), t('Returned an object.')); - $this->assertEqual($this->toolkit, $image->toolkit, t('Image had toolkit set.')); + $this->assertTrue(is_object($image), 'Returned an object.'); + $this->assertEqual($this->toolkit, $image->toolkit, 'Image had toolkit set.'); $this->assertToolkitOperationsCalled(array('load', 'get_info')); } @@ -44,7 +44,7 @@ class ToolkitTest extends ToolkitTestBase { * Test the image_save() function. */ function testSave() { - $this->assertFalse(image_save($this->image), t('Function returned the expected value.')); + $this->assertFalse(image_save($this->image), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('save')); } @@ -52,13 +52,13 @@ class ToolkitTest extends ToolkitTestBase { * Test the image_resize() function. */ function testResize() { - $this->assertTrue(image_resize($this->image, 1, 2), t('Function returned the expected value.')); + $this->assertTrue(image_resize($this->image, 1, 2), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('resize')); // Check the parameters. $calls = image_test_get_all_calls(); - $this->assertEqual($calls['resize'][0][1], 1, t('Width was passed correctly')); - $this->assertEqual($calls['resize'][0][2], 2, t('Height was passed correctly')); + $this->assertEqual($calls['resize'][0][1], 1, 'Width was passed correctly'); + $this->assertEqual($calls['resize'][0][2], 2, 'Height was passed correctly'); } /** @@ -66,68 +66,68 @@ class ToolkitTest extends ToolkitTestBase { */ function testScale() { // TODO: need to test upscaling - $this->assertTrue(image_scale($this->image, 10, 10), t('Function returned the expected value.')); + $this->assertTrue(image_scale($this->image, 10, 10), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('resize')); // Check the parameters. $calls = image_test_get_all_calls(); - $this->assertEqual($calls['resize'][0][1], 10, t('Width was passed correctly')); - $this->assertEqual($calls['resize'][0][2], 5, t('Height was based off aspect ratio and passed correctly')); + $this->assertEqual($calls['resize'][0][1], 10, 'Width was passed correctly'); + $this->assertEqual($calls['resize'][0][2], 5, 'Height was based off aspect ratio and passed correctly'); } /** * Test the image_scale_and_crop() function. */ function testScaleAndCrop() { - $this->assertTrue(image_scale_and_crop($this->image, 5, 10), t('Function returned the expected value.')); + $this->assertTrue(image_scale_and_crop($this->image, 5, 10), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('resize', 'crop')); // Check the parameters. $calls = image_test_get_all_calls(); - $this->assertEqual($calls['crop'][0][1], 7.5, t('X was computed and passed correctly')); - $this->assertEqual($calls['crop'][0][2], 0, t('Y was computed and passed correctly')); - $this->assertEqual($calls['crop'][0][3], 5, t('Width was computed and passed correctly')); - $this->assertEqual($calls['crop'][0][4], 10, t('Height was computed and passed correctly')); + $this->assertEqual($calls['crop'][0][1], 7.5, 'X was computed and passed correctly'); + $this->assertEqual($calls['crop'][0][2], 0, 'Y was computed and passed correctly'); + $this->assertEqual($calls['crop'][0][3], 5, 'Width was computed and passed correctly'); + $this->assertEqual($calls['crop'][0][4], 10, 'Height was computed and passed correctly'); } /** * Test the image_rotate() function. */ function testRotate() { - $this->assertTrue(image_rotate($this->image, 90, 1), t('Function returned the expected value.')); + $this->assertTrue(image_rotate($this->image, 90, 1), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('rotate')); // Check the parameters. $calls = image_test_get_all_calls(); - $this->assertEqual($calls['rotate'][0][1], 90, t('Degrees were passed correctly')); - $this->assertEqual($calls['rotate'][0][2], 1, t('Background color was passed correctly')); + $this->assertEqual($calls['rotate'][0][1], 90, 'Degrees were passed correctly'); + $this->assertEqual($calls['rotate'][0][2], 1, 'Background color was passed correctly'); } /** * Test the image_crop() function. */ function testCrop() { - $this->assertTrue(image_crop($this->image, 1, 2, 3, 4), t('Function returned the expected value.')); + $this->assertTrue(image_crop($this->image, 1, 2, 3, 4), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('crop')); // Check the parameters. $calls = image_test_get_all_calls(); - $this->assertEqual($calls['crop'][0][1], 1, t('X was passed correctly')); - $this->assertEqual($calls['crop'][0][2], 2, t('Y was passed correctly')); - $this->assertEqual($calls['crop'][0][3], 3, t('Width was passed correctly')); - $this->assertEqual($calls['crop'][0][4], 4, t('Height was passed correctly')); + $this->assertEqual($calls['crop'][0][1], 1, 'X was passed correctly'); + $this->assertEqual($calls['crop'][0][2], 2, 'Y was passed correctly'); + $this->assertEqual($calls['crop'][0][3], 3, 'Width was passed correctly'); + $this->assertEqual($calls['crop'][0][4], 4, 'Height was passed correctly'); } /** * Test the image_desaturate() function. */ function testDesaturate() { - $this->assertTrue(image_desaturate($this->image), t('Function returned the expected value.')); + $this->assertTrue(image_desaturate($this->image), 'Function returned the expected value.'); $this->assertToolkitOperationsCalled(array('desaturate')); // Check the parameters. $calls = image_test_get_all_calls(); - $this->assertEqual(count($calls['desaturate'][0]), 1, t('Only the image was passed.')); + $this->assertEqual(count($calls['desaturate'][0]), 1, 'Only the image was passed.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php index ac47080..51409d5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php @@ -62,19 +62,19 @@ abstract class ToolkitTestBase extends WebTestBase { // Determine if there were any expected that were not called. $uncalled = array_diff($expected, $actual); if (count($uncalled)) { - $this->assertTrue(FALSE, t('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); + $this->assertTrue(FALSE, format_string('Expected operations %expected to be called but %uncalled was not called.', array('%expected' => implode(', ', $expected), '%uncalled' => implode(', ', $uncalled)))); } else { - $this->assertTrue(TRUE, t('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected)))); + $this->assertTrue(TRUE, format_string('All the expected operations were called: %expected', array('%expected' => implode(', ', $expected)))); } // Determine if there were any unexpected calls. $unexpected = array_diff($actual, $expected); if (count($unexpected)) { - $this->assertTrue(FALSE, t('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected)))); + $this->assertTrue(FALSE, format_string('Unexpected operations were called: %unexpected.', array('%unexpected' => implode(', ', $unexpected)))); } else { - $this->assertTrue(TRUE, t('No unexpected operations were called.')); + $this->assertTrue(TRUE, 'No unexpected operations were called.'); } } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php index 5dcef68..322b3d2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Lock/LockFunctionalTest.php @@ -36,22 +36,22 @@ class LockFunctionalTest extends WebTestBase { $backend = lock(); $success = $backend->acquire('lock_a'); - $this->assertTrue($success, "Could acquire first lock"); + $this->assertTrue($success, 'Could acquire first lock.'); // This function is not part of the backend, but the default database // backend implement it, we can here use it safely. $is_free = $backend->lockMayBeAvailable('lock_a'); - $this->assertFalse($is_free, "First lock is unavailable"); + $this->assertFalse($is_free, 'First lock is unavailable.'); $backend->release('lock_a'); $is_free = $backend->lockMayBeAvailable('lock_a'); - $this->assertTrue($is_free, "First lock has been released"); + $this->assertTrue($is_free, 'First lock has been released.'); $success = $backend->acquire('lock_b'); - $this->assertTrue($success, "Could acquire second lock"); + $this->assertTrue($success, 'Could acquire second lock.'); $success = $backend->acquire('lock_b'); - $this->assertTrue($success, "Could acquire second lock a second time within the same request"); + $this->assertTrue($success, 'Could acquire second lock a second time within the same request.'); $backend->release('lock_b'); } @@ -63,18 +63,18 @@ class LockFunctionalTest extends WebTestBase { $backend = lock(); $success = $backend->acquire('lock_a'); - $this->assertTrue($success, "Could acquire first lock"); + $this->assertTrue($success, 'Could acquire first lock.'); $success = $backend->acquire('lock_b'); - $this->assertTrue($success, "Could acquire second lock"); + $this->assertTrue($success, 'Could acquire second lock.'); $backend->releaseAll(); $is_free = $backend->lockMayBeAvailable('lock_a'); - $this->assertTrue($is_free, "First lock has been released"); + $this->assertTrue($is_free, 'First lock has been released.'); $is_free = $backend->lockMayBeAvailable('lock_b'); - $this->assertTrue($is_free, "Second lock has been released"); + $this->assertTrue($is_free, 'Second lock has been released.'); } /** @@ -83,34 +83,34 @@ class LockFunctionalTest extends WebTestBase { public function testLockAcquire() { $lock_acquired = 'TRUE: Lock successfully acquired in system_test_lock_acquire()'; $lock_not_acquired = 'FALSE: Lock not acquired in system_test_lock_acquire()'; - $this->assertTrue(lock()->acquire('system_test_lock_acquire'), t('Lock acquired by this request.'), t('Lock')); - $this->assertTrue(lock()->acquire('system_test_lock_acquire'), t('Lock extended by this request.'), t('Lock')); + $this->assertTrue(lock()->acquire('system_test_lock_acquire'), t('Lock acquired by this request.'), 'Lock'); + $this->assertTrue(lock()->acquire('system_test_lock_acquire'), t('Lock extended by this request.'), 'Lock'); lock()->release('system_test_lock_acquire'); // Cause another request to acquire the lock. $this->drupalGet('system-test/lock-acquire'); - $this->assertText($lock_acquired, t('Lock acquired by the other request.'), t('Lock')); + $this->assertText($lock_acquired, t('Lock acquired by the other request.'), 'Lock'); // The other request has finished, thus it should have released its lock. - $this->assertTrue(lock()->acquire('system_test_lock_acquire'), t('Lock acquired by this request.'), t('Lock')); + $this->assertTrue(lock()->acquire('system_test_lock_acquire'), t('Lock acquired by this request.'), 'Lock'); // This request holds the lock, so the other request cannot acquire it. $this->drupalGet('system-test/lock-acquire'); - $this->assertText($lock_not_acquired, t('Lock not acquired by the other request.'), t('Lock')); + $this->assertText($lock_not_acquired, t('Lock not acquired by the other request.'), 'Lock'); lock()->release('system_test_lock_acquire'); // Try a very short timeout and lock breaking. - $this->assertTrue(lock()->acquire('system_test_lock_acquire', 0.5), t('Lock acquired by this request.'), t('Lock')); + $this->assertTrue(lock()->acquire('system_test_lock_acquire', 0.5), t('Lock acquired by this request.'), 'Lock'); sleep(1); // The other request should break our lock. $this->drupalGet('system-test/lock-acquire'); - $this->assertText($lock_acquired, t('Lock acquired by the other request, breaking our lock.'), t('Lock')); + $this->assertText($lock_acquired, t('Lock acquired by the other request, breaking our lock.'), 'Lock'); // We cannot renew it, since the other thread took it. - $this->assertFalse(lock()->acquire('system_test_lock_acquire'), t('Lock cannot be extended by this request.'), t('Lock')); + $this->assertFalse(lock()->acquire('system_test_lock_acquire'), t('Lock cannot be extended by this request.'), 'Lock'); // Check the shut-down function. $lock_acquired_exit = 'TRUE: Lock successfully acquired in system_test_lock_exit()'; $lock_not_acquired_exit = 'FALSE: Lock not acquired in system_test_lock_exit()'; $this->drupalGet('system-test/lock-exit'); - $this->assertText($lock_acquired_exit, t('Lock acquired by the other request before exit.'), t('Lock')); - $this->assertTrue(lock()->acquire('system_test_lock_exit'), t('Lock acquired by this request after the other request exits.'), t('Lock')); + $this->assertText($lock_acquired_exit, t('Lock acquired by the other request before exit.'), 'Lock'); + $this->assertTrue(lock()->acquire('system_test_lock_exit'), t('Lock acquired by this request after the other request exits.'), 'Lock'); } } -- 1.7.6.msysgit.0