diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test index 014a350..596f457 100644 --- a/modules/simpletest/tests/ajax.test +++ b/modules/simpletest/tests/ajax.test @@ -524,7 +524,7 @@ class AJAXElementValidation extends AJAXTestCase { // Post with 'drivertext' as the triggering element. $post_result = $this->drupalPostAJAX('ajax_validation_test', $edit, 'drivertext'); // Look for a validation failure in the resultant JSON. - $this->assertNoText(t('Error message'), t("No error message in resultant JSON")); - $this->assertText('ajax_forms_test_validation_form_callback invoked', t('The correct callback was invoked')); + $this->assertNoText(t('Error message'), "No error message in resultant JSON"); + $this->assertText('ajax_forms_test_validation_form_callback invoked', 'The correct callback was invoked'); } } diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test index 014fc94..49b0d7c 100644 --- a/modules/simpletest/tests/bootstrap.test +++ b/modules/simpletest/tests/bootstrap.test @@ -42,14 +42,14 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase { // Test the normal IP address. $this->assertTrue( ip_address() == $this->remote_ip, - t('Got remote IP address.') + 'Got remote IP address.' ); // Proxy forwarding on but no proxy addresses defined. variable_set('reverse_proxy', 1); $this->assertTrue( ip_address() == $this->remote_ip, - t('Proxy forwarding without trusted proxies got remote IP address.') + 'Proxy forwarding without trusted proxies got remote IP address.' ); // Proxy forwarding on and proxy address not trusted. @@ -58,7 +58,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase { $_SERVER['REMOTE_ADDR'] = $this->untrusted_ip; $this->assertTrue( ip_address() == $this->untrusted_ip, - t('Proxy forwarding with untrusted proxy got remote IP address.') + 'Proxy forwarding with untrusted proxy got remote IP address.' ); // Proxy forwarding on and proxy address trusted. @@ -67,7 +67,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase { drupal_static_reset('ip_address'); $this->assertTrue( ip_address() == $this->forwarded_ip, - t('Proxy forwarding with trusted proxy got forwarded IP address.') + 'Proxy forwarding with trusted proxy got forwarded IP address.' ); // Multi-tier architecture with comma separated values in header. @@ -76,7 +76,7 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase { drupal_static_reset('ip_address'); $this->assertTrue( ip_address() == $this->forwarded_ip, - t('Proxy forwarding with trusted 2-tier proxy got forwarded IP address.') + 'Proxy forwarding with trusted 2-tier proxy got forwarded IP address.' ); // Custom client-IP header. @@ -85,16 +85,16 @@ class BootstrapIPAddressTestCase extends DrupalWebTestCase { drupal_static_reset('ip_address'); $this->assertTrue( ip_address() == $this->cluster_ip, - t('Cluster environment got cluster client IP.') + 'Cluster environment got cluster client IP.' ); // Verifies that drupal_valid_http_host() prevents invalid characters. - $this->assertFalse(drupal_valid_http_host('security/.drupal.org:80'), t('HTTP_HOST with / is invalid')); - $this->assertFalse(drupal_valid_http_host('security\\.drupal.org:80'), t('HTTP_HOST with \\ is invalid')); - $this->assertFalse(drupal_valid_http_host('security<.drupal.org:80'), t('HTTP_HOST with < is invalid')); - $this->assertFalse(drupal_valid_http_host('security..drupal.org:80'), t('HTTP_HOST with .. is invalid')); + $this->assertFalse(drupal_valid_http_host('security/.drupal.org:80'), 'HTTP_HOST with / is invalid'); + $this->assertFalse(drupal_valid_http_host('security\\.drupal.org:80'), 'HTTP_HOST with \\ is invalid'); + $this->assertFalse(drupal_valid_http_host('security<.drupal.org:80'), 'HTTP_HOST with < is invalid'); + $this->assertFalse(drupal_valid_http_host('security..drupal.org:80'), 'HTTP_HOST with .. is invalid'); // IPv6 loopback address - $this->assertTrue(drupal_valid_http_host('[::1]:80'), t('HTTP_HOST containing IPv6 loopback is valid')); + $this->assertTrue(drupal_valid_http_host('[::1]:80'), 'HTTP_HOST containing IPv6 loopback is valid'); } } @@ -122,32 +122,32 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { $this->drupalGet(''); $this->drupalHead(''); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $etag = $this->drupalGetHeader('ETag'); $last_modified = $this->drupalGetHeader('Last-Modified'); $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag)); - $this->assertResponse(304, t('Conditional request returned 304 Not Modified.')); + $this->assertResponse(304, 'Conditional request returned 304 Not Modified.'); $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match: ' . $etag)); - $this->assertResponse(304, t('Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.')); + $this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.'); $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match: ' . $etag)); - $this->assertResponse(304, t('Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.')); + $this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.'); $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified)); - $this->assertResponse(200, t('Conditional request without If-None-Match returned 200 OK.')); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); + $this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.'); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $this->drupalGet('', array(), array('If-Modified-Since: ' . gmdate(DATE_RFC1123, strtotime($last_modified) + 1), 'If-None-Match: ' . $etag)); - $this->assertResponse(200, t('Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.')); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); + $this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.'); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $user = $this->drupalCreateUser(); $this->drupalLogin($user); $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag)); - $this->assertResponse(200, t('Conditional request returned 200 OK for authenticated user.')); - $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), t('Absense of Page was not cached.')); + $this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.'); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Absense of Page was not cached.'); } /** @@ -158,35 +158,35 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { // Fill the cache. $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); - $this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', t('Vary header was sent.')); - $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', t('Cache-Control header was sent.')); - $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); - $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); + $this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', 'Vary header was sent.'); + $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', 'Cache-Control header was sent.'); + $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.'); + $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); // Check cache. $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); - $this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', t('Vary: Cookie header was sent.')); - $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', t('Cache-Control header was sent.')); - $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); - $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); + $this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', 'Vary: Cookie header was sent.'); + $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', 'Cache-Control header was sent.'); + $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.'); + $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); // Check replacing default headers. $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT'))); - $this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', t('Default header was replaced.')); + $this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', 'Default header was replaced.'); $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Vary', 'value' => 'User-Agent'))); - $this->assertEqual($this->drupalGetHeader('Vary'), 'User-Agent,Accept-Encoding', t('Default header was replaced.')); + $this->assertEqual($this->drupalGetHeader('Vary'), 'User-Agent,Accept-Encoding', 'Default header was replaced.'); // Check that authenticated users bypass the cache. $user = $this->drupalCreateUser(); $this->drupalLogin($user); $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); - $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), t('Caching was bypassed.')); - $this->assertTrue(strpos($this->drupalGetHeader('Vary'), 'Cookie') === FALSE, t('Vary: Cookie header was not sent.')); - $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, must-revalidate, post-check=0, pre-check=0', t('Cache-Control header was sent.')); - $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); - $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.'); + $this->assertTrue(strpos($this->drupalGetHeader('Vary'), 'Cookie') === FALSE, 'Vary: Cookie header was not sent.'); + $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, must-revalidate, post-check=0, pre-check=0', 'Cache-Control header was sent.'); + $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.'); + $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); } @@ -202,23 +202,23 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { // Fill the cache and verify that output is compressed. $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); - $this->assertRaw('', t('Page was gzip compressed.')); + $this->assertRaw('', 'Page was gzip compressed.'); // Verify that cached output is compressed. $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); - $this->assertEqual($this->drupalGetHeader('Content-Encoding'), 'gzip', t('A Content-Encoding header was sent.')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); + $this->assertEqual($this->drupalGetHeader('Content-Encoding'), 'gzip', 'A Content-Encoding header was sent.'); $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); - $this->assertRaw('', t('Page was gzip compressed.')); + $this->assertRaw('', 'Page was gzip compressed.'); // Verify that a client without compression support gets an uncompressed page. $this->drupalGet(''); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); - $this->assertFalse($this->drupalGetHeader('Content-Encoding'), t('A Content-Encoding header was not sent.')); - $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), t('Site title matches.')); - $this->assertRaw('', t('Page was not compressed.')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); + $this->assertFalse($this->drupalGetHeader('Content-Encoding'), 'A Content-Encoding header was not sent.'); + $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), 'Site title matches.'); + $this->assertRaw('', 'Page was not compressed.'); } } @@ -243,17 +243,17 @@ class BootstrapVariableTestCase extends DrupalWebTestCase { // Setting and retrieving values. $variable = $this->randomName(); variable_set('simpletest_bootstrap_variable_test', $variable); - $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), t('Setting and retrieving values')); + $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), 'Setting and retrieving values'); // Make sure the variable persists across multiple requests. $this->drupalGet('system-test/variable-get'); - $this->assertText($variable, t('Variable persists across multiple requests')); + $this->assertText($variable, 'Variable persists across multiple requests'); // Deleting variables. $default_value = $this->randomName(); variable_del('simpletest_bootstrap_variable_test'); $variable = variable_get('simpletest_bootstrap_variable_test', $default_value); - $this->assertIdentical($variable, $default_value, t('Deleting variables')); + $this->assertIdentical($variable, $default_value, 'Deleting variables'); } /** @@ -261,10 +261,10 @@ class BootstrapVariableTestCase extends DrupalWebTestCase { */ function testVariableDefaults() { // Tests passing nothing through to the default. - $this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), t('Variables are correctly defaulting to NULL.')); + $this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), 'Variables are correctly defaulting to NULL.'); // Tests passing 5 to the default parameter. - $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), t('The default variable parameter is passed through correctly.')); + $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), 'The default variable parameter is passed through correctly.'); } } @@ -383,17 +383,17 @@ class BootstrapTimerTestCase extends DrupalUnitTestCase { function testTimer() { timer_start('test'); sleep(1); - $this->assertTrue(timer_read('test') >= 1000, t('Timer measured 1 second of sleeping while running.')); + $this->assertTrue(timer_read('test') >= 1000, 'Timer measured 1 second of sleeping while running.'); sleep(1); timer_stop('test'); - $this->assertTrue(timer_read('test') >= 2000, t('Timer measured 2 seconds of sleeping after being stopped.')); + $this->assertTrue(timer_read('test') >= 2000, 'Timer measured 2 seconds of sleeping after being stopped.'); timer_start('test'); sleep(1); - $this->assertTrue(timer_read('test') >= 3000, t('Timer measured 3 seconds of sleeping after being restarted.')); + $this->assertTrue(timer_read('test') >= 3000, 'Timer measured 3 seconds of sleeping after being restarted.'); sleep(1); $timer = timer_stop('test'); - $this->assertTrue(timer_read('test') >= 4000, t('Timer measured 4 seconds of sleeping after being stopped for a second time.')); - $this->assertEqual($timer['count'], 2, t('Timer counted 2 instances of being started.')); + $this->assertTrue(timer_read('test') >= 4000, 'Timer measured 4 seconds of sleeping after being stopped for a second time.'); + $this->assertEqual($timer['count'], 2, 'Timer counted 2 instances of being started.'); } } @@ -417,22 +417,22 @@ class BootstrapResettableStaticTestCase extends DrupalUnitTestCase { function testDrupalStatic() { $name = __CLASS__ . '_' . __METHOD__; $var = &drupal_static($name, 'foo'); - $this->assertEqual($var, 'foo', t('Variable returned by drupal_static() was set to its default.')); + $this->assertEqual($var, 'foo', 'Variable returned by drupal_static() was set to its default.'); // Call the specific reset and the global reset each twice to ensure that // multiple resets can be issued without odd side effects. $var = 'bar'; drupal_static_reset($name); - $this->assertEqual($var, 'foo', t('Variable was reset after first invocation of name-specific reset.')); + $this->assertEqual($var, 'foo', 'Variable was reset after first invocation of name-specific reset.'); $var = 'bar'; drupal_static_reset($name); - $this->assertEqual($var, 'foo', t('Variable was reset after second invocation of name-specific reset.')); + $this->assertEqual($var, 'foo', 'Variable was reset after second invocation of name-specific reset.'); $var = 'bar'; drupal_static_reset(); - $this->assertEqual($var, 'foo', t('Variable was reset after first invocation of global reset.')); + $this->assertEqual($var, 'foo', 'Variable was reset after first invocation of global reset.'); $var = 'bar'; drupal_static_reset(); - $this->assertEqual($var, 'foo', t('Variable was reset after second invocation of global reset.')); + $this->assertEqual($var, 'foo', 'Variable was reset after second invocation of global reset.'); } } @@ -457,7 +457,7 @@ class BootstrapMiscTestCase extends DrupalUnitTestCase { $link_options_1 = array('fragment' => 'x', 'attributes' => array('title' => 'X', 'class' => array('a', 'b')), 'language' => 'en'); $link_options_2 = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('c', 'd')), 'html' => TRUE); $expected = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('a', 'b', 'c', 'd')), 'language' => 'en', 'html' => TRUE); - $this->assertIdentical(drupal_array_merge_deep($link_options_1, $link_options_2), $expected, t('drupal_array_merge_deep() returned a properly merged array.')); + $this->assertIdentical(drupal_array_merge_deep($link_options_1, $link_options_2), $expected, 'drupal_array_merge_deep() returned a properly merged array.'); } } diff --git a/modules/simpletest/tests/cache.test b/modules/simpletest/tests/cache.test index 47f2df3..997f37a 100644 --- a/modules/simpletest/tests/cache.test +++ b/modules/simpletest/tests/cache.test @@ -148,7 +148,7 @@ class CacheSavingCase extends CacheTestCase { cache_set('test_object', $test_object, 'cache'); $cache = cache_get('test_object', 'cache'); - $this->assertTrue(isset($cache->data) && $cache->data == $test_object, t('Object is saved and restored properly.')); + $this->assertTrue(isset($cache->data) && $cache->data == $test_object, 'Object is saved and restored properly.'); } /** @@ -157,7 +157,7 @@ class CacheSavingCase extends CacheTestCase { function checkVariable($var) { cache_set('test_var', $var, 'cache'); $cache = cache_get('test_var', 'cache'); - $this->assertTrue(isset($cache->data) && $cache->data === $var, t('@type is saved and restored properly.', array('@type' => ucfirst(gettype($var))))); + $this->assertTrue(isset($cache->data) && $cache->data === $var, format_string('@type is saved and restored properly.', array('@type' => ucfirst(gettype($var))))); } /** @@ -165,7 +165,7 @@ class CacheSavingCase extends CacheTestCase { */ function testNoEmptyCids() { $this->drupalGet('user/register'); - $this->assertFalse(cache_get(''), t('No cache entry is written with an empty cid.')); + $this->assertFalse(cache_get(''), 'No cache entry is written with an empty cid.'); } } @@ -195,14 +195,14 @@ class CacheGetMultipleUnitTest extends CacheTestCase { $item2 = $this->randomName(10); cache_set('item1', $item1, $this->default_bin); cache_set('item2', $item2, $this->default_bin); - $this->assertTrue($this->checkCacheExists('item1', $item1), t('Item 1 is cached.')); - $this->assertTrue($this->checkCacheExists('item2', $item2), t('Item 2 is cached.')); + $this->assertTrue($this->checkCacheExists('item1', $item1), 'Item 1 is cached.'); + $this->assertTrue($this->checkCacheExists('item2', $item2), 'Item 2 is cached.'); // Fetch both records from the database with cache_get_multiple(). $item_ids = array('item1', 'item2'); $items = cache_get_multiple($item_ids, $this->default_bin); - $this->assertEqual($items['item1']->data, $item1, t('Item was returned from cache successfully.')); - $this->assertEqual($items['item2']->data, $item2, t('Item was returned from cache successfully.')); + $this->assertEqual($items['item1']->data, $item1, 'Item was returned from cache successfully.'); + $this->assertEqual($items['item2']->data, $item2, 'Item was returned from cache successfully.'); // Remove one item from the cache. cache_clear_all('item2', $this->default_bin); @@ -210,9 +210,9 @@ class CacheGetMultipleUnitTest extends CacheTestCase { // Confirm that only one item is returned by cache_get_multiple(). $item_ids = array('item1', 'item2'); $items = cache_get_multiple($item_ids, $this->default_bin); - $this->assertEqual($items['item1']->data, $item1, t('Item was returned from cache successfully.')); - $this->assertFalse(isset($items['item2']), t('Item was not returned from the cache.')); - $this->assertTrue(count($items) == 1, t('Only valid cache entries returned.')); + $this->assertEqual($items['item1']->data, $item1, 'Item was returned from cache successfully.'); + $this->assertFalse(isset($items['item2']), 'Item was not returned from the cache.'); + $this->assertTrue(count($items) == 1, 'Only valid cache entries returned.'); } } @@ -250,11 +250,11 @@ class CacheClearCase extends CacheTestCase { cache_set('test_cid_clear2', $this->default_value, $this->default_bin); $this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value) && $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two caches were created for checking cid "*" with wildcard false.')); + 'Two caches were created for checking cid "*" with wildcard false.'); cache_clear_all('*', $this->default_bin); $this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value) && $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two caches still exists after clearing cid "*" with wildcard false.')); + 'Two caches still exists after clearing cid "*" with wildcard false.'); } /** @@ -265,21 +265,21 @@ class CacheClearCase extends CacheTestCase { cache_set('test_cid_clear2', $this->default_value, $this->default_bin); $this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value) && $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two caches were created for checking cid "*" with wildcard true.')); + 'Two caches were created for checking cid "*" with wildcard true.'); cache_clear_all('*', $this->default_bin, TRUE); $this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value) || $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two caches removed after clearing cid "*" with wildcard true.')); + 'Two caches removed after clearing cid "*" with wildcard true.'); cache_set('test_cid_clear1', $this->default_value, $this->default_bin); cache_set('test_cid_clear2', $this->default_value, $this->default_bin); $this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value) && $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two caches were created for checking cid substring with wildcard true.')); + 'Two caches were created for checking cid substring with wildcard true.'); cache_clear_all('test_', $this->default_bin, TRUE); $this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value) || $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two caches removed after clearing cid substring with wildcard true.')); + 'Two caches removed after clearing cid substring with wildcard true.'); } /** @@ -293,16 +293,16 @@ class CacheClearCase extends CacheTestCase { $this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value) && $this->checkCacheExists('test_cid_clear2', $this->default_value) && $this->checkCacheExists('test_cid_clear3', $this->default_value), - t('Three cache entries were created.')); + 'Three cache entries were created.'); // Clear two entries using an array. cache_clear_all(array('test_cid_clear1', 'test_cid_clear2'), $this->default_bin); $this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value) || $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two cache entries removed after clearing with an array.')); + 'Two cache entries removed after clearing with an array.'); $this->assertTrue($this->checkCacheExists('test_cid_clear3', $this->default_value), - t('Entry was not cleared from the cache')); + 'Entry was not cleared from the cache'); // Set the cache clear threshold to 2 to confirm that the full bin is cleared // when the threshold is exceeded. @@ -311,12 +311,12 @@ class CacheClearCase extends CacheTestCase { cache_set('test_cid_clear2', $this->default_value, $this->default_bin); $this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value) && $this->checkCacheExists('test_cid_clear2', $this->default_value), - t('Two cache entries were created.')); + 'Two cache entries were created.'); cache_clear_all(array('test_cid_clear1', 'test_cid_clear2', 'test_cid_clear3'), $this->default_bin); $this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value) || $this->checkCacheExists('test_cid_clear2', $this->default_value) || $this->checkCacheExists('test_cid_clear3', $this->default_value), - t('All cache entries removed when the array exceeded the cache clear threshold.')); + 'All cache entries removed when the array exceeded the cache clear threshold.'); } /** @@ -336,7 +336,7 @@ class CacheClearCase extends CacheTestCase { foreach ($bins as $id => $bin) { $id = 'test_cid_clear' . $id; - $this->assertFalse($this->checkCacheExists($id, $this->default_value, $bin), t('All cache entries removed from @bin.', array('@bin' => $bin))); + $this->assertFalse($this->checkCacheExists($id, $this->default_value, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin))); } } @@ -400,14 +400,14 @@ class CacheIsEmptyCase extends CacheTestCase { function testIsEmpty() { // Clear the cache bin. cache_clear_all('*', $this->default_bin); - $this->assertTrue(cache_is_empty($this->default_bin), t('The cache bin is empty')); + $this->assertTrue(cache_is_empty($this->default_bin), 'The cache bin is empty'); // Add some data to the cache bin. cache_set($this->default_cid, $this->default_value, $this->default_bin); $this->assertCacheExists(t('Cache was set.'), $this->default_value, $this->default_cid); - $this->assertFalse(cache_is_empty($this->default_bin), t('The cache bin is not empty')); + $this->assertFalse(cache_is_empty($this->default_bin), 'The cache bin is not empty'); // Remove the cached data. cache_clear_all($this->default_cid, $this->default_bin); $this->assertCacheRemoved(t('Cache was removed.'), $this->default_cid); - $this->assertTrue(cache_is_empty($this->default_bin), t('The cache bin is empty')); + $this->assertTrue(cache_is_empty($this->default_bin), 'The cache bin is empty'); } } diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index e8e4033..fdc8312 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -36,13 +36,13 @@ class DrupalAlterTestCase extends DrupalWebTestCase { $array_copy = $array; $array_expected = array('foo' => 'Drupal theme'); drupal_alter('drupal_alter', $array_copy); - $this->assertEqual($array_copy, $array_expected, t('Single array was altered.')); + $this->assertEqual($array_copy, $array_expected, 'Single array was altered.'); $entity_copy = clone $entity; $entity_expected = clone $entity; $entity_expected->foo = 'Drupal theme'; drupal_alter('drupal_alter', $entity_copy); - $this->assertEqual($entity_copy, $entity_expected, t('Single object was altered.')); + $this->assertEqual($entity_copy, $entity_expected, 'Single object was altered.'); // Verify alteration of multiple arguments. $array_copy = $array; @@ -53,9 +53,9 @@ class DrupalAlterTestCase extends DrupalWebTestCase { $array2_copy = $array; $array2_expected = array('foo' => 'Drupal theme'); drupal_alter('drupal_alter', $array_copy, $entity_copy, $array2_copy); - $this->assertEqual($array_copy, $array_expected, t('First argument to drupal_alter() was altered.')); - $this->assertEqual($entity_copy, $entity_expected, t('Second argument to drupal_alter() was altered.')); - $this->assertEqual($array2_copy, $array2_expected, t('Third argument to drupal_alter() was altered.')); + $this->assertEqual($array_copy, $array_expected, 'First argument to drupal_alter() was altered.'); + $this->assertEqual($entity_copy, $entity_expected, 'Second argument to drupal_alter() was altered.'); + $this->assertEqual($array2_copy, $array2_expected, 'Third argument to drupal_alter() was altered.'); // Verify alteration order when passing an array of types to drupal_alter(). // common_test_module_implements_alter() places 'block' implementation after @@ -63,7 +63,7 @@ class DrupalAlterTestCase extends DrupalWebTestCase { $array_copy = $array; $array_expected = array('foo' => 'Drupal block theme'); drupal_alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy); - $this->assertEqual($array_copy, $array_expected, t('hook_TYPE_alter() implementations ran in correct order.')); + $this->assertEqual($array_copy, $array_expected, 'hook_TYPE_alter() implementations ran in correct order.'); } } @@ -90,7 +90,7 @@ class CommonURLUnitTest extends DrupalWebTestCase { $path = ""; $link = l($text, $path); $sanitized_path = check_url(url($path)); - $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, t('XSS attack @path was filtered', array('@path' => $path))); + $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered', array('@path' => $path))); } /* @@ -98,7 +98,7 @@ class CommonURLUnitTest extends DrupalWebTestCase { */ function testLActiveClass() { $link = l($this->randomName(), $_GET['q']); - $this->assertTrue($this->hasClass($link, 'active'), t('Class @class is present on link to the current page', array('@class' => 'active'))); + $this->assertTrue($this->hasClass($link, 'active'), format_string('Class @class is present on link to the current page', array('@class' => 'active'))); } /** @@ -107,8 +107,8 @@ class CommonURLUnitTest extends DrupalWebTestCase { function testLCustomClass() { $class = $this->randomName(); $link = l($this->randomName(), $_GET['q'], array('attributes' => array('class' => array($class)))); - $this->assertTrue($this->hasClass($link, $class), t('Custom class @class is present on link when requested', array('@class' => $class))); - $this->assertTrue($this->hasClass($link, 'active'), t('Class @class is present on link to the current page', array('@class' => 'active'))); + $this->assertTrue($this->hasClass($link, $class), format_string('Custom class @class is present on link when requested', array('@class' => $class))); + $this->assertTrue($this->hasClass($link, 'active'), format_string('Class @class is present on link to the current page', array('@class' => 'active'))); } private function hasClass($link, $class) { @@ -134,42 +134,42 @@ class CommonURLUnitTest extends DrupalWebTestCase { // Default arguments. $result = $_GET; unset($result['q']); - $this->assertEqual(drupal_get_query_parameters(), $result, t("\$_GET['q'] was removed.")); + $this->assertEqual(drupal_get_query_parameters(), $result, "\$_GET['q'] was removed."); // Default exclusion. $result = $original; unset($result['q']); - $this->assertEqual(drupal_get_query_parameters($original), $result, t("'q' was removed.")); + $this->assertEqual(drupal_get_query_parameters($original), $result, "'q' was removed."); // First-level exclusion. $result = $original; unset($result['b']); - $this->assertEqual(drupal_get_query_parameters($original, array('b')), $result, t("'b' was removed.")); + $this->assertEqual(drupal_get_query_parameters($original, array('b')), $result, "'b' was removed."); // Second-level exclusion. $result = $original; unset($result['b']['d']); - $this->assertEqual(drupal_get_query_parameters($original, array('b[d]')), $result, t("'b[d]' was removed.")); + $this->assertEqual(drupal_get_query_parameters($original, array('b[d]')), $result, "'b[d]' was removed."); // Third-level exclusion. $result = $original; unset($result['b']['e']['f']); - $this->assertEqual(drupal_get_query_parameters($original, array('b[e][f]')), $result, t("'b[e][f]' was removed.")); + $this->assertEqual(drupal_get_query_parameters($original, array('b[e][f]')), $result, "'b[e][f]' was removed."); // Multiple exclusions. $result = $original; unset($result['a'], $result['b']['e'], $result['c']); - $this->assertEqual(drupal_get_query_parameters($original, array('a', 'b[e]', 'c')), $result, t("'a', 'b[e]', 'c' were removed.")); + $this->assertEqual(drupal_get_query_parameters($original, array('a', 'b[e]', 'c')), $result, "'a', 'b[e]', 'c' were removed."); } /** * Test drupal_http_build_query(). */ function testDrupalHttpBuildQuery() { - $this->assertEqual(drupal_http_build_query(array('a' => ' &#//+%20@۞')), 'a=%20%26%23//%2B%2520%40%DB%9E', t('Value was properly encoded.')); - $this->assertEqual(drupal_http_build_query(array(' &#//+%20@۞' => 'a')), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', t('Key was properly encoded.')); - $this->assertEqual(drupal_http_build_query(array('a' => '1', 'b' => '2', 'c' => '3')), 'a=1&b=2&c=3', t('Multiple values were properly concatenated.')); - $this->assertEqual(drupal_http_build_query(array('a' => array('b' => '2', 'c' => '3'), 'd' => 'foo')), 'a[b]=2&a[c]=3&d=foo', t('Nested array was properly encoded.')); + $this->assertEqual(drupal_http_build_query(array('a' => ' &#//+%20@۞')), 'a=%20%26%23//%2B%2520%40%DB%9E', 'Value was properly encoded.'); + $this->assertEqual(drupal_http_build_query(array(' &#//+%20@۞' => 'a')), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', 'Key was properly encoded.'); + $this->assertEqual(drupal_http_build_query(array('a' => '1', 'b' => '2', 'c' => '3')), 'a=1&b=2&c=3', 'Multiple values were properly concatenated.'); + $this->assertEqual(drupal_http_build_query(array('a' => array('b' => '2', 'c' => '3'), 'd' => 'foo')), 'a[b]=2&a[c]=3&d=foo', 'Nested array was properly encoded.'); } /** @@ -183,7 +183,7 @@ class CommonURLUnitTest extends DrupalWebTestCase { 'query' => array('foo' => 'bar', 'bar' => 'baz', 'baz' => ''), 'fragment' => 'foo', ); - $this->assertEqual(drupal_parse_url($url), $result, t('Relative URL parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'Relative URL parsed correctly.'); // Relative URL that is known to confuse parse_url(). $url = 'foo/bar:1'; @@ -192,7 +192,7 @@ class CommonURLUnitTest extends DrupalWebTestCase { 'query' => array(), 'fragment' => '', ); - $this->assertEqual(drupal_parse_url($url), $result, t('Relative URL parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'Relative URL parsed correctly.'); // Absolute URL. $url = '/foo/bar?foo=bar&bar=baz&baz#foo'; @@ -201,13 +201,13 @@ class CommonURLUnitTest extends DrupalWebTestCase { 'query' => array('foo' => 'bar', 'bar' => 'baz', 'baz' => ''), 'fragment' => 'foo', ); - $this->assertEqual(drupal_parse_url($url), $result, t('Absolute URL parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'Absolute URL parsed correctly.'); // External URL testing. $url = 'http://drupal.org/foo/bar?foo=bar&bar=baz&baz#foo'; // Test that drupal can recognize an absolute URL. Used to prevent attack vectors. - $this->assertTrue(url_is_external($url), t('Correctly identified an external URL.')); + $this->assertTrue(url_is_external($url), 'Correctly identified an external URL.'); // Test the parsing of absolute URLs. $result = array( @@ -215,7 +215,7 @@ class CommonURLUnitTest extends DrupalWebTestCase { 'query' => array('foo' => 'bar', 'bar' => 'baz', 'baz' => ''), 'fragment' => 'foo', ); - $this->assertEqual(drupal_parse_url($url), $result, t('External URL parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'External URL parsed correctly.'); // Verify proper parsing of URLs when clean URLs are disabled. $result = array( @@ -225,19 +225,19 @@ class CommonURLUnitTest extends DrupalWebTestCase { ); // Non-clean URLs #1: Absolute URL generated by url(). $url = $GLOBALS['base_url'] . '/?q=foo/bar&bar=baz#foo'; - $this->assertEqual(drupal_parse_url($url), $result, t('Absolute URL with clean URLs disabled parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'Absolute URL with clean URLs disabled parsed correctly.'); // Non-clean URLs #2: Relative URL generated by url(). $url = '?q=foo/bar&bar=baz#foo'; - $this->assertEqual(drupal_parse_url($url), $result, t('Relative URL with clean URLs disabled parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'Relative URL with clean URLs disabled parsed correctly.'); // Non-clean URLs #3: URL generated by url() on non-Apache webserver. $url = 'index.php?q=foo/bar&bar=baz#foo'; - $this->assertEqual(drupal_parse_url($url), $result, t('Relative URL on non-Apache webserver with clean URLs disabled parsed correctly.')); + $this->assertEqual(drupal_parse_url($url), $result, 'Relative URL on non-Apache webserver with clean URLs disabled parsed correctly.'); // Test that drupal_parse_url() does not allow spoofing a URL to force a malicious redirect. $parts = drupal_parse_url('forged:http://cwe.mitre.org/data/definitions/601.html'); - $this->assertFalse(valid_url($parts['path'], TRUE), t('drupal_parse_url() correctly parsed a forged URL.')); + $this->assertFalse(valid_url($parts['path'], TRUE), 'drupal_parse_url() correctly parsed a forged URL.'); } /** @@ -325,30 +325,30 @@ class CommonURLUnitTest extends DrupalWebTestCase { // Verify external URL can contain a fragment. $url = $test_url . '#drupal'; $result = url($url); - $this->assertEqual($url, $result, t('External URL with fragment works without a fragment in $options.')); + $this->assertEqual($url, $result, 'External URL with fragment works without a fragment in $options.'); // Verify fragment can be overidden in an external URL. $url = $test_url . '#drupal'; $fragment = $this->randomName(10); $result = url($url, array('fragment' => $fragment)); - $this->assertEqual($test_url . '#' . $fragment, $result, t('External URL fragment is overidden with a custom fragment in $options.')); + $this->assertEqual($test_url . '#' . $fragment, $result, 'External URL fragment is overidden with a custom fragment in $options.'); // Verify external URL can contain a query string. $url = $test_url . '?drupal=awesome'; $result = url($url); - $this->assertEqual($url, $result, t('External URL with query string works without a query string in $options.')); + $this->assertEqual($url, $result, 'External URL with query string works without a query string in $options.'); // Verify external URL can be extended with a query string. $url = $test_url; $query = array($this->randomName(5) => $this->randomName(5)); $result = url($url, array('query' => $query)); - $this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, t('External URL can be extended with a query string in $options.')); + $this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, 'External URL can be extended with a query string in $options.'); // Verify query string can be extended in an external URL. $url = $test_url . '?drupal=awesome'; $query = array($this->randomName(5) => $this->randomName(5)); $result = url($url, array('query' => $query)); - $this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, t('External URL query string can be extended with a custom query string in $options.')); + $this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, 'External URL query string can be extended with a custom query string in $options.'); } } @@ -419,8 +419,8 @@ class CommonXssUnitTest extends DrupalUnitTestCase { $url = 'javascript:http://www.example.com/?x=1&y=2'; $expected_plain = 'http://www.example.com/?x=1&y=2'; $expected_html = 'http://www.example.com/?x=1&y=2'; - $this->assertIdentical(check_url($url), $expected_html, t('check_url() filters a URL and encodes it for HTML.')); - $this->assertIdentical(drupal_strip_dangerous_protocols($url), $expected_plain, t('drupal_strip_dangerous_protocols() filters a URL and returns plain text.')); + $this->assertIdentical(check_url($url), $expected_html, 'check_url() filters a URL and encodes it for HTML.'); + $this->assertIdentical(drupal_strip_dangerous_protocols($url), $expected_plain, 'drupal_strip_dangerous_protocols() filters a URL and returns plain text.'); } } @@ -572,11 +572,11 @@ class DrupalTagsHandlingTestCase extends DrupalUnitTestCase { $original = $this->validTags; foreach ($tags as $tag) { $key = array_search($tag, $original); - $this->assertTrue($key, t('Make sure tag %tag shows up in the final tags array (originally %original)', array('%tag' => $tag, '%original' => $key))); + $this->assertTrue($key, format_string('Make sure tag %tag shows up in the final tags array (originally %original)', array('%tag' => $tag, '%original' => $key))); unset($original[$key]); } foreach ($original as $leftover) { - $this->fail(t('Leftover tag %leftover was left over.', array('%leftover' => $leftover))); + $this->fail(format_string('Leftover tag %leftover was left over.', array('%leftover' => $leftover))); } } } @@ -603,7 +603,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { * Check default stylesheets as empty. */ function testDefault() { - $this->assertEqual(array(), drupal_add_css(), t('Default CSS is empty.')); + $this->assertEqual(array(), drupal_add_css(), 'Default CSS is empty.'); } /** @@ -633,7 +633,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { function testAddFile() { $path = drupal_get_path('module', 'simpletest') . '/simpletest.css'; $css = drupal_add_css($path); - $this->assertEqual($css[$path]['data'], $path, t('Adding a CSS file caches it properly.')); + $this->assertEqual($css[$path]['data'], $path, 'Adding a CSS file caches it properly.'); } /** @@ -642,7 +642,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { function testAddExternal() { $path = 'http://example.com/style.css'; $css = drupal_add_css($path, 'external'); - $this->assertEqual($css[$path]['type'], 'external', t('Adding an external CSS file caches it properly.')); + $this->assertEqual($css[$path]['type'], 'external', 'Adding an external CSS file caches it properly.'); } /** @@ -650,7 +650,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { */ function testReset() { drupal_static_reset('drupal_add_css'); - $this->assertEqual(array(), drupal_add_css(), t('Resetting the CSS empties the cache.')); + $this->assertEqual(array(), drupal_add_css(), 'Resetting the CSS empties the cache.'); } /** @@ -660,7 +660,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { $css = drupal_get_path('module', 'simpletest') . '/simpletest.css'; drupal_add_css($css); $styles = drupal_get_css(); - $this->assertTrue(strpos($styles, $css) > 0, t('Rendered CSS includes the added stylesheet.')); + $this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.'); } /** @@ -672,7 +672,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { $styles = drupal_get_css(); // Stylesheet URL may be the href of a LINK tag or in an @import statement // of a STYLE tag. - $this->assertTrue(strpos($styles, 'href="' . $css) > 0 || strpos($styles, '@import url("' . $css . '")') > 0, t('Rendering an external CSS file.')); + $this->assertTrue(strpos($styles, 'href="' . $css) > 0 || strpos($styles, '@import url("' . $css . '")') > 0, 'Rendering an external CSS file.'); } /** @@ -683,7 +683,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { $css_preprocessed = ''; drupal_add_css($css, array('type' => 'inline')); $styles = drupal_get_css(); - $this->assertEqual(trim($styles), $css_preprocessed, t('Rendering preprocessed inline CSS adds it to the page.')); + $this->assertEqual(trim($styles), $css_preprocessed, 'Rendering preprocessed inline CSS adds it to the page.'); } /** @@ -693,7 +693,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { $css = 'body { padding: 0px; }'; drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE)); $styles = drupal_get_css(); - $this->assertTrue(strpos($styles, $css) > 0, t('Rendering non-preprocessed inline CSS adds it to the page.')); + $this->assertTrue(strpos($styles, $css) > 0, 'Rendering non-preprocessed inline CSS adds it to the page.'); } /** @@ -723,7 +723,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { // Fetch the page. $this->drupalGet('node/' . $node->nid); - $this->assertRaw($expected, t('Inline stylesheets appear in the full page rendering.')); + $this->assertRaw($expected, 'Inline stylesheets appear in the full page rendering.'); } /** @@ -756,7 +756,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { $result = array(); } - $this->assertIdentical($result, $expected, t('The CSS files are in the expected order.')); + $this->assertIdentical($result, $expected, 'The CSS files are in the expected order.'); } /** @@ -771,16 +771,16 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { // The dummy stylesheet should be the only one included. $styles = drupal_get_css(); - $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') !== FALSE, t('The overriding CSS file is output.')); - $this->assert(strpos($styles, $system . '/system.base.css') === FALSE, t('The overridden CSS file is not output.')); + $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') !== FALSE, 'The overriding CSS file is output.'); + $this->assert(strpos($styles, $system . '/system.base.css') === FALSE, 'The overridden CSS file is not output.'); drupal_add_css($simpletest . '/tests/system.base.css'); drupal_add_css($system . '/system.base.css'); // The standard stylesheet should be the only one included. $styles = drupal_get_css(); - $this->assert(strpos($styles, $system . '/system.base.css') !== FALSE, t('The overriding CSS file is output.')); - $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') === FALSE, t('The overridden CSS file is not output.')); + $this->assert(strpos($styles, $system . '/system.base.css') !== FALSE, 'The overriding CSS file is output.'); + $this->assert(strpos($styles, $simpletest . '/tests/system.base.css') === FALSE, 'The overridden CSS file is not output.'); } /** @@ -795,7 +795,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { // Check to see if system.base-rtl.css was also added. $styles = drupal_get_css(); - $this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, t('CSS is alterable as right to left overrides are added.')); + $this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, 'CSS is alterable as right to left overrides are added.'); // Change the language back to left to right. $language->direction = LANGUAGE_LTR; @@ -808,8 +808,8 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase { function testAddCssFileWithQueryString() { $this->drupalGet('common-test/query-string'); $query_string = variable_get('css_js_query_string', '0'); - $this->assertRaw(drupal_get_path('module', 'node') . '/node.css?' . $query_string, t('Query string was appended correctly to css.')); - $this->assertRaw(drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2', t('Query string not escaped on a URI.')); + $this->assertRaw(drupal_get_path('module', 'node') . '/node.css?' . $query_string, 'Query string was appended correctly to css.'); + $this->assertRaw(drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2', 'Query string not escaped on a URI.'); } } @@ -831,14 +831,14 @@ class DrupalHTMLIdentifierTestCase extends DrupalUnitTestCase { function testDrupalCleanCSSIdentifier() { // Verify that no valid ASCII characters are stripped from the identifier. $identifier = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789'; - $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, t('Verify valid ASCII characters pass through.')); + $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, 'Verify valid ASCII characters pass through.'); // Verify that valid UTF-8 characters are not stripped from the identifier. $identifier = '¡¢£¤¥'; - $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, t('Verify valid UTF-8 characters pass through.')); + $this->assertIdentical(drupal_clean_css_identifier($identifier, array()), $identifier, 'Verify valid UTF-8 characters pass through.'); // Verify that invalid characters (including non-breaking space) are stripped from the identifier. - $this->assertIdentical(drupal_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', t('Strip invalid characters.')); + $this->assertIdentical(drupal_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ identifier', array()), 'invalididentifier', 'Strip invalid characters.'); } /** @@ -846,7 +846,7 @@ class DrupalHTMLIdentifierTestCase extends DrupalUnitTestCase { */ function testDrupalHTMLClass() { // Verify Drupal coding standards are enforced. - $this->assertIdentical(drupal_html_class('CLASS NAME_[Ü]'), 'class-name--ü', t('Enforce Drupal coding standards.')); + $this->assertIdentical(drupal_html_class('CLASS NAME_[Ü]'), 'class-name--ü', 'Enforce Drupal coding standards.'); } /** @@ -855,21 +855,21 @@ class DrupalHTMLIdentifierTestCase extends DrupalUnitTestCase { function testDrupalHTMLId() { // Verify that letters, digits, and hyphens are not stripped from the ID. $id = 'abcdefghijklmnopqrstuvwxyz-0123456789'; - $this->assertIdentical(drupal_html_id($id), $id, t('Verify valid characters pass through.')); + $this->assertIdentical(drupal_html_id($id), $id, 'Verify valid characters pass through.'); // Verify that invalid characters are stripped from the ID. - $this->assertIdentical(drupal_html_id('invalid,./:@\\^`{Üidentifier'), 'invalididentifier', t('Strip invalid characters.')); + $this->assertIdentical(drupal_html_id('invalid,./:@\\^`{Üidentifier'), 'invalididentifier', 'Strip invalid characters.'); // Verify Drupal coding standards are enforced. - $this->assertIdentical(drupal_html_id('ID NAME_[1]'), 'id-name-1', t('Enforce Drupal coding standards.')); + $this->assertIdentical(drupal_html_id('ID NAME_[1]'), 'id-name-1', 'Enforce Drupal coding standards.'); // Reset the static cache so we can ensure the unique id count is at zero. drupal_static_reset('drupal_html_id'); // Clean up IDs with invalid starting characters. - $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id', t('Test the uniqueness of IDs #1.')); - $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id--2', t('Test the uniqueness of IDs #2.')); - $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id--3', t('Test the uniqueness of IDs #3.')); + $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id', 'Test the uniqueness of IDs #1.'); + $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id--2', 'Test the uniqueness of IDs #2.'); + $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id--3', 'Test the uniqueness of IDs #3.'); } } @@ -907,20 +907,20 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase { foreach ($testfiles as $file) { $expected = file_get_contents("$path/$file.unoptimized.css"); $unoptimized_output = drupal_load_stylesheet("$path/$file.unoptimized.css", FALSE); - $this->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file has expected contents (@file)', array('@file' => $file))); + $this->assertEqual($unoptimized_output, $expected, format_string('Unoptimized CSS file has expected contents (@file)', array('@file' => $file))); $expected = file_get_contents("$path/$file.optimized.css"); $optimized_output = drupal_load_stylesheet("$path/$file", TRUE); - $this->assertEqual($optimized_output, $expected, t('Optimized CSS file has expected contents (@file)', array('@file' => $file))); + $this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file has expected contents (@file)', array('@file' => $file))); // Repeat the tests by accessing the stylesheets by URL. $expected = file_get_contents("$path/$file.unoptimized.css"); $unoptimized_output_url = drupal_load_stylesheet($GLOBALS['base_url'] . "/$path/$file.unoptimized.css", FALSE); - $this->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file))); + $this->assertEqual($unoptimized_output, $expected, format_string('Unoptimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file))); $expected = file_get_contents("$path/$file.optimized.css"); $optimized_output = drupal_load_stylesheet($GLOBALS['base_url'] . "/$path/$file", TRUE); - $this->assertEqual($optimized_output, $expected, t('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file))); + $this->assertEqual($optimized_output, $expected, format_string('Optimized CSS file (loaded from an URL) has expected contents (@file)', array('@file' => $file))); } } } @@ -946,24 +946,24 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { // Parse URL schema. $missing_scheme = drupal_http_request('example.com/path'); - $this->assertEqual($missing_scheme->code, -1002, t('Returned with "-1002" error code.')); - $this->assertEqual($missing_scheme->error, 'missing schema', t('Returned with "missing schema" error message.')); + $this->assertEqual($missing_scheme->code, -1002, 'Returned with "-1002" error code.'); + $this->assertEqual($missing_scheme->error, 'missing schema', 'Returned with "missing schema" error message.'); $unable_to_parse = drupal_http_request('http:///path'); - $this->assertEqual($unable_to_parse->code, -1001, t('Returned with "-1001" error code.')); - $this->assertEqual($unable_to_parse->error, 'unable to parse URL', t('Returned with "unable to parse URL" error message.')); + $this->assertEqual($unable_to_parse->code, -1001, 'Returned with "-1001" error code.'); + $this->assertEqual($unable_to_parse->error, 'unable to parse URL', 'Returned with "unable to parse URL" error message.'); // Fetch page. $result = drupal_http_request(url('node', array('absolute' => TRUE))); - $this->assertEqual($result->code, 200, t('Fetched page successfully.')); + $this->assertEqual($result->code, 200, 'Fetched page successfully.'); $this->drupalSetContent($result->data); - $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), t('Site title matches.')); + $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), 'Site title matches.'); // Test that code and status message is returned. $result = drupal_http_request(url('pagedoesnotexist', array('absolute' => TRUE))); - $this->assertTrue(!empty($result->protocol), t('Result protocol is returned.')); - $this->assertEqual($result->code, '404', t('Result code is 404')); - $this->assertEqual($result->status_message, 'Not Found', t('Result status message is "Not Found"')); + $this->assertTrue(!empty($result->protocol), 'Result protocol is returned.'); + $this->assertEqual($result->code, '404', 'Result code is 404'); + $this->assertEqual($result->status_message, 'Not Found', 'Result status message is "Not Found"'); // Skip the timeout tests when the testing environment is HTTPS because // stream_set_timeout() does not work for SSL connections. @@ -978,9 +978,9 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { timer_start(__METHOD__); $result = drupal_http_request(url('system-test/sleep/10', array('absolute' => TRUE)), array('timeout' => 2)); $time = timer_read(__METHOD__) / 1000; - $this->assertTrue(1.8 < $time && $time < 5, t('Request timed out (%time seconds).', array('%time' => $time))); - $this->assertTrue($result->error, t('An error message was returned.')); - $this->assertEqual($result->code, HTTP_REQUEST_TIMEOUT, t('Proper error code was returned.')); + $this->assertTrue(1.8 < $time && $time < 5, format_string('Request timed out (%time seconds).', array('%time' => $time))); + $this->assertTrue($result->error, 'An error message was returned.'); + $this->assertEqual($result->code, HTTP_REQUEST_TIMEOUT, 'Proper error code was returned.'); } } @@ -993,47 +993,47 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { $result = drupal_http_request($auth); $this->drupalSetContent($result->data); - $this->assertRaw($username, t('$_SERVER["PHP_AUTH_USER"] is passed correctly.')); - $this->assertRaw($password, t('$_SERVER["PHP_AUTH_PW"] is passed correctly.')); + $this->assertRaw($username, '$_SERVER["PHP_AUTH_USER"] is passed correctly.'); + $this->assertRaw($password, '$_SERVER["PHP_AUTH_PW"] is passed correctly.'); } function testDrupalHTTPRequestRedirect() { $redirect_301 = drupal_http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_301->redirect_code, 301, t('drupal_http_request follows the 301 redirect.')); + $this->assertEqual($redirect_301->redirect_code, 301, 'drupal_http_request follows the 301 redirect.'); $redirect_301 = drupal_http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array('max_redirects' => 0)); - $this->assertFalse(isset($redirect_301->redirect_code), t('drupal_http_request does not follow 301 redirect if max_redirects = 0.')); + $this->assertFalse(isset($redirect_301->redirect_code), 'drupal_http_request does not follow 301 redirect if max_redirects = 0.'); $redirect_invalid = drupal_http_request(url('system-test/redirect-noscheme', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_invalid->code, -1002, t('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error))); - $this->assertEqual($redirect_invalid->error, 'missing schema', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->code, -1002, format_string('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->error, 'missing schema', format_string('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); $redirect_invalid = drupal_http_request(url('system-test/redirect-noparse', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_invalid->code, -1001, t('301 redirect to invalid URL returned with error message code "!error".', array('!error' => $redirect_invalid->error))); - $this->assertEqual($redirect_invalid->error, 'unable to parse URL', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->code, -1001, format_string('301 redirect to invalid URL returned with error message code "!error".', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->error, 'unable to parse URL', format_string('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); $redirect_invalid = drupal_http_request(url('system-test/redirect-invalid-scheme', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_invalid->code, -1003, t('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error))); - $this->assertEqual($redirect_invalid->error, 'invalid schema ftp', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->code, -1003, format_string('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->error, 'invalid schema ftp', format_string('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); $redirect_302 = drupal_http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_302->redirect_code, 302, t('drupal_http_request follows the 302 redirect.')); + $this->assertEqual($redirect_302->redirect_code, 302, 'drupal_http_request follows the 302 redirect.'); $redirect_302 = drupal_http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array('max_redirects' => 0)); - $this->assertFalse(isset($redirect_302->redirect_code), t('drupal_http_request does not follow 302 redirect if $retry = 0.')); + $this->assertFalse(isset($redirect_302->redirect_code), 'drupal_http_request does not follow 302 redirect if $retry = 0.'); $redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_307->redirect_code, 307, t('drupal_http_request follows the 307 redirect.')); + $this->assertEqual($redirect_307->redirect_code, 307, 'drupal_http_request follows the 307 redirect.'); $redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 0)); - $this->assertFalse(isset($redirect_307->redirect_code), t('drupal_http_request does not follow 307 redirect if max_redirects = 0.')); + $this->assertFalse(isset($redirect_307->redirect_code), 'drupal_http_request does not follow 307 redirect if max_redirects = 0.'); $multiple_redirect_final_url = url('system-test/multiple-redirects/0', array('absolute' => TRUE)); $multiple_redirect_1 = drupal_http_request(url('system-test/multiple-redirects/1', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($multiple_redirect_1->redirect_url, $multiple_redirect_final_url, t('redirect_url contains the final redirection location after 1 redirect.')); + $this->assertEqual($multiple_redirect_1->redirect_url, $multiple_redirect_final_url, 'redirect_url contains the final redirection location after 1 redirect.'); $multiple_redirect_3 = drupal_http_request(url('system-test/multiple-redirects/3', array('absolute' => TRUE)), array('max_redirects' => 3)); - $this->assertEqual($multiple_redirect_3->redirect_url, $multiple_redirect_final_url, t('redirect_url contains the final redirection location after 3 redirects.')); + $this->assertEqual($multiple_redirect_3->redirect_url, $multiple_redirect_final_url, 'redirect_url contains the final redirection location after 3 redirects.'); } /** @@ -1088,13 +1088,13 @@ class DrupalSetContentTestCase extends DrupalWebTestCase { // Ensure drupal_get_region_content returns expected results when fetching all regions. $content = drupal_get_region_content(NULL, $delimiter); foreach ($content as $region => $region_content) { - $this->assertEqual($region_content, $values[$region], t('@region region text verified when fetching all regions', array('@region' => $region))); + $this->assertEqual($region_content, $values[$region], format_string('@region region text verified when fetching all regions', array('@region' => $region))); } // Ensure drupal_get_region_content returns expected results when fetching a single region. foreach ($block_regions as $region) { $region_content = drupal_get_region_content($region, $delimiter); - $this->assertEqual($region_content, $values[$region], t('@region region text verified when fetching single region.', array('@region' => $region))); + $this->assertEqual($region_content, $values[$region], format_string('@region region text verified when fetching single region.', array('@region' => $region))); } } } @@ -1122,23 +1122,23 @@ class DrupalGotoTest extends DrupalWebTestCase { $this->drupalGet('common-test/drupal_goto/redirect'); $headers = $this->drupalGetHeaders(TRUE); list(, $status) = explode(' ', $headers[0][':status'], 3); - $this->assertEqual($status, 302, t('Expected response code was sent.')); - $this->assertText('drupal_goto', t('Drupal goto redirect succeeded.')); - $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('absolute' => TRUE)), t('Drupal goto redirected to expected URL.')); + $this->assertEqual($status, 302, 'Expected response code was sent.'); + $this->assertText('drupal_goto', 'Drupal goto redirect succeeded.'); + $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('absolute' => TRUE)), 'Drupal goto redirected to expected URL.'); $this->drupalGet('common-test/drupal_goto/redirect_advanced'); $headers = $this->drupalGetHeaders(TRUE); list(, $status) = explode(' ', $headers[0][':status'], 3); - $this->assertEqual($status, 301, t('Expected response code was sent.')); - $this->assertText('drupal_goto', t('Drupal goto redirect succeeded.')); - $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('query' => array('foo' => '123'), 'absolute' => TRUE)), t('Drupal goto redirected to expected URL.')); + $this->assertEqual($status, 301, 'Expected response code was sent.'); + $this->assertText('drupal_goto', 'Drupal goto redirect succeeded.'); + $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('query' => array('foo' => '123'), 'absolute' => TRUE)), 'Drupal goto redirected to expected URL.'); // Test that drupal_goto() respects ?destination=xxx. Use an complicated URL // to test that the path is encoded and decoded properly. $destination = 'common-test/drupal_goto/destination?foo=%2525&bar=123'; $this->drupalGet('common-test/drupal_goto/redirect', array('query' => array('destination' => $destination))); - $this->assertText('drupal_goto', t('Drupal goto redirect with destination succeeded.')); - $this->assertEqual($this->getUrl(), url('common-test/drupal_goto/destination', array('query' => array('foo' => '%25', 'bar' => '123'), 'absolute' => TRUE)), t('Drupal goto redirected to given query string destination.')); + $this->assertText('drupal_goto', 'Drupal goto redirect with destination succeeded.'); + $this->assertEqual($this->getUrl(), url('common-test/drupal_goto/destination', array('query' => array('foo' => '%25', 'bar' => '123'), 'absolute' => TRUE)), 'Drupal goto redirected to given query string destination.'); } /** @@ -1147,8 +1147,8 @@ class DrupalGotoTest extends DrupalWebTestCase { function testDrupalGotoAlter() { $this->drupalGet('common-test/drupal_goto/redirect_fail'); - $this->assertNoText(t("Drupal goto failed to stop program"), t("Drupal goto stopped program.")); - $this->assertNoText('drupal_goto_fail', t("Drupal goto redirect failed.")); + $this->assertNoText(t("Drupal goto failed to stop program"), "Drupal goto stopped program."); + $this->assertNoText('drupal_goto_fail', "Drupal goto redirect failed."); } /** @@ -1159,12 +1159,12 @@ class DrupalGotoTest extends DrupalWebTestCase { // Verify that a 'destination' query string is used as destination. $this->drupalGet('common-test/destination', array('query' => array('destination' => $query))); - $this->assertText('The destination: ' . $query, t('The given query string destination is determined as destination.')); + $this->assertText('The destination: ' . $query, 'The given query string destination is determined as destination.'); // Verify that the current path is used as destination. $this->drupalGet('common-test/destination', array('query' => array($query => NULL))); $url = 'common-test/destination?' . $query; - $this->assertText('The destination: ' . $url, t('The current path is determined as destination.')); + $this->assertText('The destination: ' . $url, 'The current path is determined as destination.'); } } @@ -1208,7 +1208,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { * Test default JavaScript is empty. */ function testDefault() { - $this->assertEqual(array(), drupal_add_js(), t('Default JavaScript is empty.')); + $this->assertEqual(array(), drupal_add_js(), 'Default JavaScript is empty.'); } /** @@ -1216,12 +1216,12 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testAddFile() { $javascript = drupal_add_js('misc/collapse.js'); - $this->assertTrue(array_key_exists('misc/jquery.js', $javascript), t('jQuery is added when a file is added.')); - $this->assertTrue(array_key_exists('misc/drupal.js', $javascript), t('Drupal.js is added when file is added.')); - $this->assertTrue(array_key_exists('misc/collapse.js', $javascript), t('JavaScript files are correctly added.')); - $this->assertEqual(base_path(), $javascript['settings']['data'][0]['basePath'], t('Base path JavaScript setting is correctly set.')); + $this->assertTrue(array_key_exists('misc/jquery.js', $javascript), 'jQuery is added when a file is added.'); + $this->assertTrue(array_key_exists('misc/drupal.js', $javascript), 'Drupal.js is added when file is added.'); + $this->assertTrue(array_key_exists('misc/collapse.js', $javascript), 'JavaScript files are correctly added.'); + $this->assertEqual(base_path(), $javascript['settings']['data'][0]['basePath'], 'Base path JavaScript setting is correctly set.'); url('', array('prefix' => &$prefix)); - $this->assertEqual(empty($prefix) ? '' : $prefix, $javascript['settings']['data'][1]['pathPrefix'], t('Path prefix JavaScript setting is correctly set.')); + $this->assertEqual(empty($prefix) ? '' : $prefix, $javascript['settings']['data'][1]['pathPrefix'], 'Path prefix JavaScript setting is correctly set.'); } /** @@ -1229,8 +1229,8 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testAddSetting() { $javascript = drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting'); - $this->assertEqual(280342800, $javascript['settings']['data'][2]['dries'], t('JavaScript setting is set correctly.')); - $this->assertEqual('rocks', $javascript['settings']['data'][2]['drupal'], t('The other JavaScript setting is set correctly.')); + $this->assertEqual(280342800, $javascript['settings']['data'][2]['dries'], 'JavaScript setting is set correctly.'); + $this->assertEqual('rocks', $javascript['settings']['data'][2]['drupal'], 'The other JavaScript setting is set correctly.'); } /** @@ -1239,7 +1239,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { function testAddExternal() { $path = 'http://example.com/script.js'; $javascript = drupal_add_js($path, 'external'); - $this->assertTrue(array_key_exists('http://example.com/script.js', $javascript), t('Added an external JavaScript file.')); + $this->assertTrue(array_key_exists('http://example.com/script.js', $javascript), 'Added an external JavaScript file.'); } /** @@ -1258,23 +1258,23 @@ class JavaScriptTestCase extends DrupalWebTestCase { drupal_add_js(array('commonTestArray' => array('key' => 'commonTestNewValue')), 'setting'); $javascript = drupal_get_js('header'); - $this->assertTrue(strpos($javascript, 'basePath') > 0, t('Rendered JavaScript header returns basePath setting.')); - $this->assertTrue(strpos($javascript, 'misc/jquery.js') > 0, t('Rendered JavaScript header includes jQuery.')); - $this->assertTrue(strpos($javascript, 'pathPrefix') > 0, t('Rendered JavaScript header returns pathPrefix setting.')); + $this->assertTrue(strpos($javascript, 'basePath') > 0, 'Rendered JavaScript header returns basePath setting.'); + $this->assertTrue(strpos($javascript, 'misc/jquery.js') > 0, 'Rendered JavaScript header includes jQuery.'); + $this->assertTrue(strpos($javascript, 'pathPrefix') > 0, 'Rendered JavaScript header returns pathPrefix setting.'); // Test whether drupal_add_js can be used to override a previous setting. - $this->assertTrue(strpos($javascript, 'commonTestShouldAppear') > 0, t('Rendered JavaScript header returns custom setting.')); - $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, t('drupal_add_js() correctly overrides a custom setting.')); + $this->assertTrue(strpos($javascript, 'commonTestShouldAppear') > 0, 'Rendered JavaScript header returns custom setting.'); + $this->assertTrue(strpos($javascript, 'commonTestShouldNotAppear') === FALSE, 'drupal_add_js() correctly overrides a custom setting.'); // Test whether drupal_add_js can be used to add numerically indexed values // to an array. $array_values_appear = strpos($javascript, 'commonTestValue0') > 0 && strpos($javascript, 'commonTestValue1') > 0 && strpos($javascript, 'commonTestValue2') > 0; - $this->assertTrue($array_values_appear, t('drupal_add_js() correctly adds settings to the end of an indexed array.')); + $this->assertTrue($array_values_appear, 'drupal_add_js() correctly adds settings to the end of an indexed array.'); // Test whether drupal_add_js can be used to override the entry for an // existing key in an associative array. $associative_array_override = strpos($javascript, 'commonTestNewValue') > 0 && strpos($javascript, 'commonTestOldValue') === FALSE; - $this->assertTrue($associative_array_override, t('drupal_add_js() correctly overrides settings within an associative array.')); + $this->assertTrue($associative_array_override, 'drupal_add_js() correctly overrides settings within an associative array.'); } /** @@ -1283,7 +1283,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { function testReset() { drupal_add_js('misc/collapse.js'); drupal_static_reset('drupal_add_js'); - $this->assertEqual(array(), drupal_add_js(), t('Resetting the JavaScript correctly empties the cache.')); + $this->assertEqual(array(), drupal_add_js(), 'Resetting the JavaScript correctly empties the cache.'); } /** @@ -1292,9 +1292,9 @@ class JavaScriptTestCase extends DrupalWebTestCase { function testAddInline() { $inline = 'jQuery(function () { });'; $javascript = drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer')); - $this->assertTrue(array_key_exists('misc/jquery.js', $javascript), t('jQuery is added when inline scripts are added.')); + $this->assertTrue(array_key_exists('misc/jquery.js', $javascript), 'jQuery is added when inline scripts are added.'); $data = end($javascript); - $this->assertEqual($inline, $data['data'], t('Inline JavaScript is correctly added to the footer.')); + $this->assertEqual($inline, $data['data'], 'Inline JavaScript is correctly added to the footer.'); } /** @@ -1305,7 +1305,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { drupal_add_js($external, 'external'); $javascript = drupal_get_js(); // Local files have a base_path() prefix, external files should not. - $this->assertTrue(strpos($javascript, 'src="' . $external) > 0, t('Rendering an external JavaScript file.')); + $this->assertTrue(strpos($javascript, 'src="' . $external) > 0, 'Rendering an external JavaScript file.'); } /** @@ -1315,7 +1315,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { $inline = 'jQuery(function () { });'; drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer')); $javascript = drupal_get_js('footer'); - $this->assertTrue(strpos($javascript, $inline) > 0, t('Rendered JavaScript footer returns the inline code.')); + $this->assertTrue(strpos($javascript, $inline) > 0, 'Rendered JavaScript footer returns the inline code.'); } /** @@ -1323,7 +1323,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testNoCache() { $javascript = drupal_add_js('misc/collapse.js', array('cache' => FALSE)); - $this->assertFalse($javascript['misc/collapse.js']['preprocess'], t('Setting cache to FALSE sets proprocess to FALSE when adding JavaScript.')); + $this->assertFalse($javascript['misc/collapse.js']['preprocess'], 'Setting cache to FALSE sets proprocess to FALSE when adding JavaScript.'); } /** @@ -1331,7 +1331,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testDifferentGroup() { $javascript = drupal_add_js('misc/collapse.js', array('group' => JS_THEME)); - $this->assertEqual($javascript['misc/collapse.js']['group'], JS_THEME, t('Adding a JavaScript file with a different group caches the given group.')); + $this->assertEqual($javascript['misc/collapse.js']['group'], JS_THEME, 'Adding a JavaScript file with a different group caches the given group.'); } /** @@ -1339,7 +1339,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testDifferentWeight() { $javascript = drupal_add_js('misc/collapse.js', array('weight' => 2)); - $this->assertEqual($javascript['misc/collapse.js']['weight'], 2, t('Adding a JavaScript file with a different weight caches the given weight.')); + $this->assertEqual($javascript['misc/collapse.js']['weight'], 2, 'Adding a JavaScript file with a different weight caches the given weight.'); } /** @@ -1423,7 +1423,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { else { $result = array(); } - $this->assertIdentical($result, $expected, t('JavaScript is added in the expected weight order.')); + $this->assertIdentical($result, $expected, 'JavaScript is added in the expected weight order.'); } /** @@ -1435,7 +1435,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { // weight, we need the other two options to be the same. drupal_add_js('misc/collapse.js', array('group' => JS_LIBRARY, 'every_page' => TRUE, 'weight' => -21)); $javascript = drupal_get_js(); - $this->assertTrue(strpos($javascript, 'misc/collapse.js') < strpos($javascript, 'misc/jquery.js'), t('Rendering a JavaScript file above jQuery.')); + $this->assertTrue(strpos($javascript, 'misc/collapse.js') < strpos($javascript, 'misc/jquery.js'), 'Rendering a JavaScript file above jQuery.'); } /** @@ -1452,7 +1452,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { // tableselect.js. See simpletest_js_alter() to see where this alteration // takes place. $javascript = drupal_get_js(); - $this->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'misc/tableselect.js'), t('Altering JavaScript weight through the alter hook.')); + $this->assertTrue(strpos($javascript, 'simpletest.js') < strpos($javascript, 'misc/tableselect.js'), 'Altering JavaScript weight through the alter hook.'); } /** @@ -1460,11 +1460,11 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testLibraryRender() { $result = drupal_add_library('system', 'farbtastic'); - $this->assertTrue($result !== FALSE, t('Library was added without errors.')); + $this->assertTrue($result !== FALSE, 'Library was added without errors.'); $scripts = drupal_get_js(); $styles = drupal_get_css(); - $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), t('JavaScript of library was added to the page.')); - $this->assertTrue(strpos($styles, 'misc/farbtastic/farbtastic.css'), t('Stylesheet of library was added to the page.')); + $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), 'JavaScript of library was added to the page.'); + $this->assertTrue(strpos($styles, 'misc/farbtastic/farbtastic.css'), 'Stylesheet of library was added to the page.'); } /** @@ -1475,12 +1475,12 @@ class JavaScriptTestCase extends DrupalWebTestCase { function testLibraryAlter() { // Verify that common_test altered the title of Farbtastic. $library = drupal_get_library('system', 'farbtastic'); - $this->assertEqual($library['title'], 'Farbtastic: Altered Library', t('Registered libraries were altered.')); + $this->assertEqual($library['title'], 'Farbtastic: Altered Library', 'Registered libraries were altered.'); // common_test_library_alter() also added a dependency on jQuery Form. drupal_add_library('system', 'farbtastic'); $scripts = drupal_get_js(); - $this->assertTrue(strpos($scripts, 'misc/jquery.form.js'), t('Altered library dependencies are added to the page.')); + $this->assertTrue(strpos($scripts, 'misc/jquery.form.js'), 'Altered library dependencies are added to the page.'); } /** @@ -1490,7 +1490,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testLibraryNameConflicts() { $farbtastic = drupal_get_library('common_test', 'farbtastic'); - $this->assertEqual($farbtastic['title'], 'Custom Farbtastic Library', t('Alternative libraries can be added to the page.')); + $this->assertEqual($farbtastic['title'], 'Custom Farbtastic Library', 'Alternative libraries can be added to the page.'); } /** @@ -1498,13 +1498,13 @@ class JavaScriptTestCase extends DrupalWebTestCase { */ function testLibraryUnknown() { $result = drupal_get_library('unknown', 'unknown'); - $this->assertFalse($result, t('Unknown library returned FALSE.')); + $this->assertFalse($result, 'Unknown library returned FALSE.'); drupal_static_reset('drupal_get_library'); $result = drupal_add_library('unknown', 'unknown'); - $this->assertFalse($result, t('Unknown library returned FALSE.')); + $this->assertFalse($result, 'Unknown library returned FALSE.'); $scripts = drupal_get_js(); - $this->assertTrue(strpos($scripts, 'unknown') === FALSE, t('Unknown library was not added to the page.')); + $this->assertTrue(strpos($scripts, 'unknown') === FALSE, 'Unknown library was not added to the page.'); } /** @@ -1514,7 +1514,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { $element['#attached']['library'][] = array('system', 'farbtastic'); drupal_render($element); $scripts = drupal_get_js(); - $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), t('The attached_library property adds the additional libraries.')); + $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), 'The attached_library property adds the additional libraries.'); } /** @@ -1523,18 +1523,18 @@ class JavaScriptTestCase extends DrupalWebTestCase { function testGetLibrary() { // Retrieve all libraries registered by a module. $libraries = drupal_get_library('common_test'); - $this->assertTrue(isset($libraries['farbtastic']), t('Retrieved all module libraries.')); + $this->assertTrue(isset($libraries['farbtastic']), 'Retrieved all module libraries.'); // Retrieve all libraries for a module not implementing hook_library(). // Note: This test installs Locale module. $libraries = drupal_get_library('locale'); - $this->assertEqual($libraries, array(), t('Retrieving libraries from a module not implementing hook_library() returns an emtpy array.')); + $this->assertEqual($libraries, array(), 'Retrieving libraries from a module not implementing hook_library() returns an emtpy array.'); // Retrieve a specific library by module and name. $farbtastic = drupal_get_library('common_test', 'farbtastic'); - $this->assertEqual($farbtastic['version'], '5.3', t('Retrieved a single library.')); + $this->assertEqual($farbtastic['version'], '5.3', 'Retrieved a single library.'); // Retrieve a non-existing library by module and name. $farbtastic = drupal_get_library('common_test', 'foo'); - $this->assertIdentical($farbtastic, FALSE, t('Retrieving a non-existing library returns FALSE.')); + $this->assertIdentical($farbtastic, FALSE, 'Retrieving a non-existing library returns FALSE.'); } /** @@ -1544,7 +1544,7 @@ class JavaScriptTestCase extends DrupalWebTestCase { function testAddJsFileWithQueryString() { $this->drupalGet('common-test/query-string'); $query_string = variable_get('css_js_query_string', '0'); - $this->assertRaw(drupal_get_path('module', 'node') . '/node.js?' . $query_string, t('Query string was appended correctly to js.')); + $this->assertRaw(drupal_get_path('module', 'node') . '/node.js?' . $query_string, 'Query string was appended correctly to js.'); } } @@ -1584,17 +1584,17 @@ class DrupalRenderTestCase extends DrupalWebTestCase { $output = drupal_render($elements); // The lowest weight element should appear last in $output. - $this->assertTrue(strpos($output, $second) > strpos($output, $first), t('Elements were sorted correctly by weight.')); + $this->assertTrue(strpos($output, $second) > strpos($output, $first), 'Elements were sorted correctly by weight.'); // Confirm that the $elements array has '#sorted' set to TRUE. - $this->assertTrue($elements['#sorted'], t("'#sorted' => TRUE was added to the array")); + $this->assertTrue($elements['#sorted'], "'#sorted' => TRUE was added to the array"); // Pass $elements through element_children() and ensure it remains // sorted in the correct order. drupal_render() will return an empty string // if used on the same array in the same request. $children = element_children($elements); - $this->assertTrue(array_shift($children) == 'first', t('Child found in the correct order.')); - $this->assertTrue(array_shift($children) == 'second', t('Child found in the correct order.')); + $this->assertTrue(array_shift($children) == 'first', 'Child found in the correct order.'); + $this->assertTrue(array_shift($children) == 'second', 'Child found in the correct order.'); // The same array structure again, but with #sorted set to TRUE. @@ -1612,7 +1612,7 @@ class DrupalRenderTestCase extends DrupalWebTestCase { $output = drupal_render($elements); // The elements should appear in output in the same order as the array. - $this->assertTrue(strpos($output, $second) < strpos($output, $first), t('Elements were not sorted.')); + $this->assertTrue(strpos($output, $second) < strpos($output, $first), 'Elements were not sorted.'); } /** @@ -1649,18 +1649,18 @@ class DrupalRenderTestCase extends DrupalWebTestCase { // Render the element and verify the presence of #attached JavaScript. drupal_render($element); $scripts = drupal_get_js(); - $this->assertTrue(strpos($scripts, $parent_js), t('The element #attached JavaScript was included.')); - $this->assertTrue(strpos($scripts, $child_js), t('The child #attached JavaScript was included.')); - $this->assertTrue(strpos($scripts, $subchild_js), t('The subchild #attached JavaScript was included.')); + $this->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included.'); + $this->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included.'); + $this->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included.'); // Load the element from cache and verify the presence of the #attached // JavaScript. drupal_static_reset('drupal_add_js'); - $this->assertTrue(drupal_render_cache_get($element), t('The element was retrieved from cache.')); + $this->assertTrue(drupal_render_cache_get($element), 'The element was retrieved from cache.'); $scripts = drupal_get_js(); - $this->assertTrue(strpos($scripts, $parent_js), t('The element #attached JavaScript was included when loading from cache.')); - $this->assertTrue(strpos($scripts, $child_js), t('The child #attached JavaScript was included when loading from cache.')); - $this->assertTrue(strpos($scripts, $subchild_js), t('The subchild #attached JavaScript was included when loading from cache.')); + $this->assertTrue(strpos($scripts, $parent_js), 'The element #attached JavaScript was included when loading from cache.'); + $this->assertTrue(strpos($scripts, $child_js), 'The child #attached JavaScript was included when loading from cache.'); + $this->assertTrue(strpos($scripts, $subchild_js), 'The subchild #attached JavaScript was included when loading from cache.'); $_SERVER['REQUEST_METHOD'] = $request_method; } @@ -1804,7 +1804,7 @@ class DrupalRenderTestCase extends DrupalWebTestCase { // @see DrupalWebTestCase::xpath() $xpath = $this->buildXPathQuery($xpath, $xpath_args); $element += array('#value' => NULL); - $this->assertFieldByXPath($xpath, $element['#value'], t('#type @type was properly rendered.', array( + $this->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', array( '@type' => var_export($element['#type'], TRUE), ))); } @@ -1828,13 +1828,13 @@ class DrupalRenderTestCase extends DrupalWebTestCase { // process (which will set $element['#printed']). $element = $test_element; drupal_render($element); - $this->assertTrue(isset($element['#printed']), t('No cache hit')); + $this->assertTrue(isset($element['#printed']), 'No cache hit'); // Render the element again and confirm that it is retrieved from the cache // instead (so $element['#printed'] will not be set). $element = $test_element; drupal_render($element); - $this->assertFalse(isset($element['#printed']), t('Cache hit')); + $this->assertFalse(isset($element['#printed']), 'Cache hit'); // Restore the previous request method. $_SERVER['REQUEST_METHOD'] = $request_method; @@ -1883,7 +1883,7 @@ class ValidUrlTestCase extends DrupalUnitTestCase { foreach ($valid_absolute_urls as $url) { $test_url = $scheme . '://' . $url; $valid_url = valid_url($test_url, TRUE); - $this->assertTrue($valid_url, t('@url is a valid url.', array('@url' => $test_url))); + $this->assertTrue($valid_url, format_string('@url is a valid url.', array('@url' => $test_url))); } } } @@ -1903,7 +1903,7 @@ class ValidUrlTestCase extends DrupalUnitTestCase { foreach ($invalid_ablosule_urls as $url) { $test_url = $scheme . '://' . $url; $valid_url = valid_url($test_url, TRUE); - $this->assertFalse($valid_url, t('@url is NOT a valid url.', array('@url' => $test_url))); + $this->assertFalse($valid_url, format_string('@url is NOT a valid url.', array('@url' => $test_url))); } } } @@ -1924,7 +1924,7 @@ class ValidUrlTestCase extends DrupalUnitTestCase { foreach ($valid_relative_urls as $url) { $test_url = $front . $url; $valid_url = valid_url($test_url); - $this->assertTrue($valid_url, t('@url is a valid url.', array('@url' => $test_url))); + $this->assertTrue($valid_url, format_string('@url is a valid url.', array('@url' => $test_url))); } } } @@ -1943,7 +1943,7 @@ class ValidUrlTestCase extends DrupalUnitTestCase { foreach ($invalid_relative_urls as $url) { $test_url = $front . $url; $valid_url = valid_url($test_url); - $this->assertFALSE($valid_url, t('@url is NOT a valid url.', array('@url' => $test_url))); + $this->assertFALSE($valid_url, format_string('@url is NOT a valid url.', array('@url' => $test_url))); } } } @@ -1974,30 +1974,30 @@ class DrupalDataApiTest extends DrupalWebTestCase { $person->name = 'John'; $person->unknown_column = 123; $insert_result = drupal_write_record('test', $person); - $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with drupal_write_record() for a table with a single-field primary key.')); - $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().')); - $this->assertIdentical($person->age, 0, t('Age field set to default value.')); - $this->assertIdentical($person->job, 'Undefined', t('Job field set to default value.')); + $this->assertTrue($insert_result == SAVED_NEW, 'Correct value returned when a record is inserted with drupal_write_record() for a table with a single-field primary key.'); + $this->assertTrue(isset($person->id), 'Primary key is set on record created with drupal_write_record().'); + $this->assertIdentical($person->age, 0, 'Age field set to default value.'); + $this->assertIdentical($person->job, 'Undefined', 'Job field set to default value.'); // Verify that the record was inserted. $result = db_query("SELECT * FROM {test} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'John', t('Name field set.')); - $this->assertIdentical($result->age, '0', t('Age field set to default value.')); - $this->assertIdentical($result->job, 'Undefined', t('Job field set to default value.')); - $this->assertFalse(isset($result->unknown_column), t('Unknown column was ignored.')); + $this->assertIdentical($result->name, 'John', 'Name field set.'); + $this->assertIdentical($result->age, '0', 'Age field set to default value.'); + $this->assertIdentical($result->job, 'Undefined', 'Job field set to default value.'); + $this->assertFalse(isset($result->unknown_column), 'Unknown column was ignored.'); // Update the newly created record. $person->name = 'Peter'; $person->age = 27; $person->job = NULL; $update_result = drupal_write_record('test', $person, array('id')); - $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record updated with drupal_write_record() for table with single-field primary key.')); + $this->assertTrue($update_result == SAVED_UPDATED, 'Correct value returned when a record updated with drupal_write_record() for table with single-field primary key.'); // Verify that the record was updated. $result = db_query("SELECT * FROM {test} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'Peter', t('Name field set.')); - $this->assertIdentical($result->age, '27', t('Age field set.')); - $this->assertIdentical($result->job, '', t('Job field set and cast to string.')); + $this->assertIdentical($result->name, 'Peter', 'Name field set.'); + $this->assertIdentical($result->age, '27', 'Age field set.'); + $this->assertIdentical($result->job, '', 'Job field set and cast to string.'); // Try to insert NULL in columns that does not allow this. $person = new stdClass(); @@ -2005,65 +2005,65 @@ class DrupalDataApiTest extends DrupalWebTestCase { $person->age = NULL; $person->job = NULL; $insert_result = drupal_write_record('test', $person); - $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().')); + $this->assertTrue(isset($person->id), 'Primary key is set on record created with drupal_write_record().'); $result = db_query("SELECT * FROM {test} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'Ringo', t('Name field set.')); - $this->assertIdentical($result->age, '0', t('Age field set.')); - $this->assertIdentical($result->job, '', t('Job field set.')); + $this->assertIdentical($result->name, 'Ringo', 'Name field set.'); + $this->assertIdentical($result->age, '0', 'Age field set.'); + $this->assertIdentical($result->job, '', 'Job field set.'); // Insert a record - the "age" column allows NULL. $person = new stdClass(); $person->name = 'Paul'; $person->age = NULL; $insert_result = drupal_write_record('test_null', $person); - $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().')); + $this->assertTrue(isset($person->id), 'Primary key is set on record created with drupal_write_record().'); $result = db_query("SELECT * FROM {test_null} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'Paul', t('Name field set.')); - $this->assertIdentical($result->age, NULL, t('Age field set.')); + $this->assertIdentical($result->name, 'Paul', 'Name field set.'); + $this->assertIdentical($result->age, NULL, 'Age field set.'); // Insert a record - do not specify the value of a column that allows NULL. $person = new stdClass(); $person->name = 'Meredith'; $insert_result = drupal_write_record('test_null', $person); - $this->assertTrue(isset($person->id), t('Primary key is set on record created with drupal_write_record().')); - $this->assertIdentical($person->age, 0, t('Age field set to default value.')); + $this->assertTrue(isset($person->id), 'Primary key is set on record created with drupal_write_record().'); + $this->assertIdentical($person->age, 0, 'Age field set to default value.'); $result = db_query("SELECT * FROM {test_null} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'Meredith', t('Name field set.')); - $this->assertIdentical($result->age, '0', t('Age field set to default value.')); + $this->assertIdentical($result->name, 'Meredith', 'Name field set.'); + $this->assertIdentical($result->age, '0', 'Age field set to default value.'); // Update the newly created record. $person->name = 'Mary'; $person->age = NULL; $update_result = drupal_write_record('test_null', $person, array('id')); $result = db_query("SELECT * FROM {test_null} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'Mary', t('Name field set.')); - $this->assertIdentical($result->age, NULL, t('Age field set.')); + $this->assertIdentical($result->name, 'Mary', 'Name field set.'); + $this->assertIdentical($result->age, NULL, 'Age field set.'); // Insert a record - the "data" column should be serialized. $person = new stdClass(); $person->name = 'Dave'; $update_result = drupal_write_record('test_serialized', $person); $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical($result->name, 'Dave', t('Name field set.')); - $this->assertIdentical($result->info, NULL, t('Info field set.')); + $this->assertIdentical($result->name, 'Dave', 'Name field set.'); + $this->assertIdentical($result->info, NULL, 'Info field set.'); $person->info = array(); $update_result = drupal_write_record('test_serialized', $person, array('id')); $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical(unserialize($result->info), array(), t('Info field updated.')); + $this->assertIdentical(unserialize($result->info), array(), 'Info field updated.'); // Update the serialized record. $data = array('foo' => 'bar', 1 => 2, 'empty' => '', 'null' => NULL); $person->info = $data; $update_result = drupal_write_record('test_serialized', $person, array('id')); $result = db_query("SELECT * FROM {test_serialized} WHERE id = :id", array(':id' => $person->id))->fetchObject(); - $this->assertIdentical(unserialize($result->info), $data, t('Info field updated.')); + $this->assertIdentical(unserialize($result->info), $data, 'Info field updated.'); // Run an update query where no field values are changed. The database // layer should return zero for number of affected rows, but // db_write_record() should still return SAVED_UPDATED. $update_result = drupal_write_record('test_null', $person, array('id')); - $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a valid update is run without changing any values.')); + $this->assertTrue($update_result == SAVED_UPDATED, 'Correct value returned when a valid update is run without changing any values.'); // Insert an object record for a table with a multi-field primary key. $node_access = new stdClass(); @@ -2071,11 +2071,11 @@ class DrupalDataApiTest extends DrupalWebTestCase { $node_access->gid = mt_rand(); $node_access->realm = $this->randomName(); $insert_result = drupal_write_record('node_access', $node_access); - $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with drupal_write_record() for a table with a multi-field primary key.')); + $this->assertTrue($insert_result == SAVED_NEW, 'Correct value returned when a record is inserted with drupal_write_record() for a table with a multi-field primary key.'); // Update the record. $update_result = drupal_write_record('node_access', $node_access, array('nid', 'gid', 'realm')); - $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record is updated with drupal_write_record() for a table with a multi-field primary key.')); + $this->assertTrue($update_result == SAVED_UPDATED, 'Correct value returned when a record is updated with drupal_write_record() for a table with a multi-field primary key.'); } } @@ -2113,7 +2113,7 @@ class DrupalErrorCollectionUnitTest extends DrupalWebTestCase { function testErrorCollect() { $this->collectedErrors = array(); $this->drupalGet('error-test/generate-warnings-with-report'); - $this->assertEqual(count($this->collectedErrors), 3, t('Three errors were collected')); + $this->assertEqual(count($this->collectedErrors), 3, 'Three errors were collected'); if (count($this->collectedErrors) == 3) { $this->assertError($this->collectedErrors[0], 'Notice', 'error_test_generate_warnings()', 'error_test.module', 'Undefined variable: bananas'); @@ -2162,11 +2162,11 @@ class DrupalErrorCollectionUnitTest extends DrupalWebTestCase { * Assert that a collected error matches what we are expecting. */ function assertError($error, $group, $function, $file, $message = NULL) { - $this->assertEqual($error['group'], $group, t("Group was %group", array('%group' => $group))); - $this->assertEqual($error['caller']['function'], $function, t("Function was %function", array('%function' => $function))); - $this->assertEqual(drupal_basename($error['caller']['file']), $file, t("File was %file", array('%file' => $file))); + $this->assertEqual($error['group'], $group, format_string("Group was %group", array('%group' => $group))); + $this->assertEqual($error['caller']['function'], $function, format_string("Function was %function", array('%function' => $function))); + $this->assertEqual(drupal_basename($error['caller']['file']), $file, format_string("File was %file", array('%file' => $file))); if (isset($message)) { - $this->assertEqual($error['message'], $message, t("Message was %message", array('%message' => $message))); + $this->assertEqual($error['message'], $message, format_string("Message was %message", array('%message' => $message))); } } } @@ -2188,9 +2188,9 @@ class ParseInfoFilesTestCase extends DrupalUnitTestCase { */ function testParseInfoFile() { $info_values = drupal_parse_info_file(drupal_get_path('module', 'simpletest') . '/tests/common_test_info.txt'); - $this->assertEqual($info_values['simple_string'], 'A simple string', t('Simple string value was parsed correctly.'), t('System')); - $this->assertEqual($info_values['simple_constant'], WATCHDOG_INFO, t('Constant value was parsed correctly.'), t('System')); - $this->assertEqual($info_values['double_colon'], 'dummyClassName::', t('Value containing double-colon was parsed correctly.'), t('System')); + $this->assertEqual($info_values['simple_string'], 'A simple string', t('Simple string value was parsed correctly.'), 'System'); + $this->assertEqual($info_values['simple_constant'], WATCHDOG_INFO, t('Constant value was parsed correctly.'), 'System'); + $this->assertEqual($info_values['double_colon'], 'dummyClassName::', t('Value containing double-colon was parsed correctly.'), 'System'); } } @@ -2239,7 +2239,7 @@ class DrupalSystemListingTestCase extends DrupalWebTestCase { foreach ($expected_directories as $module => $directories) { foreach ($directories as $directory) { $filename = "$directory/$module/$module.module"; - $this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), t('@filename exists.', array('@filename' => $filename))); + $this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename))); } } @@ -2249,7 +2249,7 @@ class DrupalSystemListingTestCase extends DrupalWebTestCase { foreach ($expected_directories as $module => $directories) { $expected_directory = array_shift($directories); $expected_filename = "$expected_directory/$module/$module.module"; - $this->assertEqual($files[$module]->uri, $expected_filename, t('Module @module was found at @filename.', array('@module' => $module, '@filename' => $expected_filename))); + $this->assertEqual($files[$module]->uri, $expected_filename, format_string('Module @module was found at @filename.', array('@module' => $module, '@filename' => $expected_filename))); } } } @@ -2296,7 +2296,7 @@ class FormatDateUnitTest extends DrupalWebTestCase { // Add new date format. $admin_date_format = 'j M y'; $edit = array('date_format' => $admin_date_format); - $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, t('Add format')); + $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, 'Add format'); // Add new date type. $edit = array( @@ -2304,11 +2304,11 @@ class FormatDateUnitTest extends DrupalWebTestCase { 'machine_name' => 'example_style', 'date_format' => $admin_date_format, ); - $this->drupalPost('admin/config/regional/date-time/types/add', $edit, t('Add date type')); + $this->drupalPost('admin/config/regional/date-time/types/add', $edit, 'Add date type'); $timestamp = strtotime('2007-03-10T00:00:00+00:00'); - $this->assertIdentical(format_date($timestamp, 'example_style', '', 'America/Los_Angeles'), '9 Mar 07', t('Test format_date() using an admin-defined date type.')); - $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'medium'), t('Test format_date() defaulting to medium when $type not found.')); + $this->assertIdentical(format_date($timestamp, 'example_style', '', 'America/Los_Angeles'), '9 Mar 07', 'Test format_date() using an admin-defined date type.'); + $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'medium'), 'Test format_date() defaulting to medium when $type not found.'); } /** @@ -2318,12 +2318,12 @@ class FormatDateUnitTest extends DrupalWebTestCase { global $user, $language; $timestamp = strtotime('2007-03-26T00:00:00+00:00'); - $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test all parameters.')); - $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'domingo, 25-Mar-07 17:00:00 PDT', t('Test translated format.')); - $this->assertIdentical(format_date($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'l, 25-Mar-07 17:00:00 PDT', t('Test an escaped format string.')); - $this->assertIdentical(format_date($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\domingo, 25-Mar-07 17:00:00 PDT', t('Test format containing backslash character.')); - $this->assertIdentical(format_date($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\l, 25-Mar-07 17:00:00 PDT', t('Test format containing backslash followed by escaped format string.')); - $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', t('Test a different time zone.')); + $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.'); + $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test translated format.'); + $this->assertIdentical(format_date($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'l, 25-Mar-07 17:00:00 PDT', 'Test an escaped format string.'); + $this->assertIdentical(format_date($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\domingo, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash character.'); + $this->assertIdentical(format_date($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\l, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash followed by escaped format string.'); + $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.'); // Create an admin user and add Spanish language. $admin_user = $this->drupalCreateUser(array('administer languages')); @@ -2353,13 +2353,13 @@ class FormatDateUnitTest extends DrupalWebTestCase { // Simulate a Drupal bootstrap with the logged-in user. date_default_timezone_set(drupal_get_user_timezone()); - $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', t('Test a different language.')); - $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', t('Test a different time zone.')); - $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', t('Test custom date format.')); - $this->assertIdentical(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', t('Test long date format.')); - $this->assertIdentical(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', t('Test medium date format.')); - $this->assertIdentical(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', t('Test short date format.')); - $this->assertIdentical(format_date($timestamp), '25. marzo 2007 - 17:00', t('Test default date format.')); + $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.'); + $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.'); + $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test custom date format.'); + $this->assertIdentical(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.'); + $this->assertIdentical(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', 'Test medium date format.'); + $this->assertIdentical(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', 'Test short date format.'); + $this->assertIdentical(format_date($timestamp), '25. marzo 2007 - 17:00', 'Test default date format.'); // Restore the original user and language, and enable session saving. $user = $real_user; @@ -2387,15 +2387,15 @@ class DrupalAttributesUnitTest extends DrupalUnitTestCase { */ function testDrupalAttributes() { // Verify that special characters are HTML encoded. - $this->assertIdentical(drupal_attributes(array('title' => '&"\'<>')), ' title="&"'<>"', t('HTML encode attribute values.')); + $this->assertIdentical(drupal_attributes(array('title' => '&"\'<>')), ' title="&"'<>"', 'HTML encode attribute values.'); // Verify multi-value attributes are concatenated with spaces. $attributes = array('class' => array('first', 'last')); - $this->assertIdentical(drupal_attributes(array('class' => array('first', 'last'))), ' class="first last"', t('Concatenate multi-value attributes.')); + $this->assertIdentical(drupal_attributes(array('class' => array('first', 'last'))), ' class="first last"', 'Concatenate multi-value attributes.'); // Verify empty attribute values are rendered. - $this->assertIdentical(drupal_attributes(array('alt' => '')), ' alt=""', t('Empty attribute value #1.')); - $this->assertIdentical(drupal_attributes(array('alt' => NULL)), ' alt=""', t('Empty attribute value #2.')); + $this->assertIdentical(drupal_attributes(array('alt' => '')), ' alt=""', 'Empty attribute value #1.'); + $this->assertIdentical(drupal_attributes(array('alt' => NULL)), ' alt=""', 'Empty attribute value #2.'); // Verify multiple attributes are rendered. $attributes = array( @@ -2403,10 +2403,10 @@ class DrupalAttributesUnitTest extends DrupalUnitTestCase { 'class' => array('first', 'last'), 'alt' => 'Alternate', ); - $this->assertIdentical(drupal_attributes($attributes), ' id="id-test" class="first last" alt="Alternate"', t('Multiple attributes.')); + $this->assertIdentical(drupal_attributes($attributes), ' id="id-test" class="first last" alt="Alternate"', 'Multiple attributes.'); // Verify empty attributes array is rendered. - $this->assertIdentical(drupal_attributes(array()), '', t('Empty attributes array.')); + $this->assertIdentical(drupal_attributes(array()), '', 'Empty attributes array.'); } } @@ -2439,38 +2439,38 @@ class DrupalJSONTest extends DrupalUnitTestCase { $html_unsafe_escaped = array('\u003C', '\u003E', '\u0027', '\u0026', '\u0022'); // Verify there aren't character encoding problems with the source string. - $this->assertIdentical(strlen($str), 128, t('A string with the full ASCII table has the correct length.')); + $this->assertIdentical(strlen($str), 128, 'A string with the full ASCII table has the correct length.'); foreach ($html_unsafe as $char) { - $this->assertTrue(strpos($str, $char) > 0, t('A string with the full ASCII table includes @s.', array('@s' => $char))); + $this->assertTrue(strpos($str, $char) > 0, format_string('A string with the full ASCII table includes @s.', array('@s' => $char))); } // Verify that JSON encoding produces a string with all of the characters. $json = drupal_json_encode($str); - $this->assertTrue(strlen($json) > strlen($str), t('A JSON encoded string is larger than the source string.')); + $this->assertTrue(strlen($json) > strlen($str), 'A JSON encoded string is larger than the source string.'); // The first and last characters should be ", and no others. - $this->assertTrue($json[0] == '"', t('A JSON encoded string begins with ".')); - $this->assertTrue($json[strlen($json) - 1] == '"', t('A JSON encoded string ends with ".')); - $this->assertTrue(substr_count($json, '"') == 2, t('A JSON encoded string contains exactly two ".')); + $this->assertTrue($json[0] == '"', 'A JSON encoded string begins with ".'); + $this->assertTrue($json[strlen($json) - 1] == '"', 'A JSON encoded string ends with ".'); + $this->assertTrue(substr_count($json, '"') == 2, 'A JSON encoded string contains exactly two ".'); // Verify that encoding/decoding is reversible. $json_decoded = drupal_json_decode($json); - $this->assertIdentical($str, $json_decoded, t('Encoding a string to JSON and decoding back results in the original string.')); + $this->assertIdentical($str, $json_decoded, 'Encoding a string to JSON and decoding back results in the original string.'); // Verify reversibility for structured data. Also verify that necessary // characters are escaped. $source = array(TRUE, FALSE, 0, 1, '0', '1', $str, array('key1' => $str, 'key2' => array('nested' => TRUE))); $json = drupal_json_encode($source); foreach ($html_unsafe as $char) { - $this->assertTrue(strpos($json, $char) === FALSE, t('A JSON encoded string does not contain @s.', array('@s' => $char))); + $this->assertTrue(strpos($json, $char) === FALSE, format_string('A JSON encoded string does not contain @s.', array('@s' => $char))); } // Verify that JSON encoding escapes the HTML unsafe characters foreach ($html_unsafe_escaped as $char) { - $this->assertTrue(strpos($json, $char) > 0, t('A JSON encoded string contains @s.', array('@s' => $char))); + $this->assertTrue(strpos($json, $char) > 0, format_string('A JSON encoded string contains @s.', array('@s' => $char))); } $json_decoded = drupal_json_decode($json); - $this->assertNotIdentical($source, $json, t('An array encoded in JSON is not identical to the source.')); - $this->assertIdentical($source, $json_decoded, t('Encoding structured data to JSON and decoding back results in the original data.')); + $this->assertNotIdentical($source, $json, 'An array encoded in JSON is not identical to the source.'); + $this->assertIdentical($source, $json_decoded, 'Encoding structured data to JSON and decoding back results in the original data.'); } } @@ -2573,7 +2573,7 @@ class DrupalAddFeedTestCase extends DrupalWebTestCase { $this->drupalSetContent(drupal_get_html_head()); foreach ($urls as $description => $feed_info) { - $this->assertPattern($this->urlToRSSLinkPattern($feed_info['output_url'], $feed_info['title']), t('Found correct feed header for %description', array('%description' => $description))); + $this->assertPattern($this->urlToRSSLinkPattern($feed_info['output_url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description))); } } diff --git a/modules/simpletest/tests/schema.test b/modules/simpletest/tests/schema.test index 8945117..4199428 100644 --- a/modules/simpletest/tests/schema.test +++ b/modules/simpletest/tests/schema.test @@ -44,7 +44,7 @@ class SchemaTestCase extends DrupalWebTestCase { db_create_table('test_table', $table_specification); // Assert that the table exists. - $this->assertTrue(db_table_exists('test_table'), t('The table exists.')); + $this->assertTrue(db_table_exists('test_table'), 'The table exists.'); // Assert that the table comment has been set. $this->checkSchemaComment($table_specification['description'], 'test_table'); @@ -53,46 +53,46 @@ class SchemaTestCase extends DrupalWebTestCase { $this->checkSchemaComment($table_specification['fields']['test_field']['description'], 'test_table', 'test_field'); // An insert without a value for the column 'test_table' should fail. - $this->assertFalse($this->tryInsert(), t('Insert without a default failed.')); + $this->assertFalse($this->tryInsert(), 'Insert without a default failed.'); // Add a default value to the column. db_field_set_default('test_table', 'test_field', 0); // The insert should now succeed. - $this->assertTrue($this->tryInsert(), t('Insert with a default succeeded.')); + $this->assertTrue($this->tryInsert(), 'Insert with a default succeeded.'); // Remove the default. db_field_set_no_default('test_table', 'test_field'); // The insert should fail again. - $this->assertFalse($this->tryInsert(), t('Insert without a default failed.')); + $this->assertFalse($this->tryInsert(), 'Insert without a default failed.'); // Test for fake index and test for the boolean result of indexExists(). $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field'); - $this->assertIdentical($index_exists, FALSE, t('Fake index does not exists')); + $this->assertIdentical($index_exists, FALSE, 'Fake index does not exists'); // Add index. db_add_index('test_table', 'test_field', array('test_field')); // Test for created index and test for the boolean result of indexExists(). $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field'); - $this->assertIdentical($index_exists, TRUE, t('Index created.')); + $this->assertIdentical($index_exists, TRUE, 'Index created.'); // Rename the table. db_rename_table('test_table', 'test_table2'); // Index should be renamed. $index_exists = Database::getConnection()->schema()->indexExists('test_table2', 'test_field'); - $this->assertTrue($index_exists, t('Index was renamed.')); + $this->assertTrue($index_exists, 'Index was renamed.'); // We need the default so that we can insert after the rename. db_field_set_default('test_table2', 'test_field', 0); - $this->assertFalse($this->tryInsert(), t('Insert into the old table failed.')); - $this->assertTrue($this->tryInsert('test_table2'), t('Insert into the new table succeeded.')); + $this->assertFalse($this->tryInsert(), 'Insert into the old table failed.'); + $this->assertTrue($this->tryInsert('test_table2'), 'Insert into the new table succeeded.'); // We should have successfully inserted exactly two rows. $count = db_query('SELECT COUNT(*) FROM {test_table2}')->fetchField(); - $this->assertEqual($count, 2, t('Two fields were successfully inserted.')); + $this->assertEqual($count, 2, 'Two fields were successfully inserted.'); // Try to drop the table. db_drop_table('test_table2'); - $this->assertFalse(db_table_exists('test_table2'), t('The dropped table does not exist.')); + $this->assertFalse(db_table_exists('test_table2'), 'The dropped table does not exist.'); // Recreate the table. db_create_table('test_table', $table_specification); @@ -108,14 +108,14 @@ class SchemaTestCase extends DrupalWebTestCase { // Assert that the column comment has been set. $this->checkSchemaComment('Changed column description.', 'test_table', 'test_serial'); - $this->assertTrue($this->tryInsert(), t('Insert with a serial succeeded.')); + $this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.'); $max1 = db_query('SELECT MAX(test_serial) FROM {test_table}')->fetchField(); - $this->assertTrue($this->tryInsert(), t('Insert with a serial succeeded.')); + $this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.'); $max2 = db_query('SELECT MAX(test_serial) FROM {test_table}')->fetchField(); - $this->assertTrue($max2 > $max1, t('The serial is monotone.')); + $this->assertTrue($max2 > $max1, 'The serial is monotone.'); $count = db_query('SELECT COUNT(*) FROM {test_table}')->fetchField(); - $this->assertEqual($count, 2, t('There were two rows.')); + $this->assertEqual($count, 2, 'There were two rows.'); // Use database specific data type and ensure that table is created. $table_specification = array( @@ -134,7 +134,7 @@ class SchemaTestCase extends DrupalWebTestCase { db_create_table('test_timestamp', $table_specification); } catch (Exception $e) {} - $this->assertTrue(db_table_exists('test_timestamp'), t('Table with database specific datatype was created.')); + $this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.'); } function tryInsert($table = 'test_table') { @@ -162,7 +162,7 @@ class SchemaTestCase extends DrupalWebTestCase { function checkSchemaComment($description, $table, $column = NULL) { if (method_exists(Database::getConnection()->schema(), 'getComment')) { $comment = Database::getConnection()->schema()->getComment($table, $column); - $this->assertEqual($comment, $description, t('The comment matches the schema description.')); + $this->assertEqual($comment, $description, 'The comment matches the schema description.'); } } @@ -193,8 +193,8 @@ class SchemaTestCase extends DrupalWebTestCase { // Finally, check each column and try to insert invalid values into them. foreach ($table_spec['fields'] as $column_name => $column_spec) { - $this->assertTrue(db_field_exists($table_name, $column_name), t('Unsigned @type column was created.', array('@type' => $column_spec['type']))); - $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), t('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type']))); + $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', array('@type' => $column_spec['type']))); + $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type']))); } } @@ -312,7 +312,7 @@ class SchemaTestCase extends DrupalWebTestCase { 'primary key' => array('serial_column'), ); db_create_table($table_name, $table_spec); - $this->pass(t('Table %table created.', array('%table' => $table_name))); + $this->pass(format_string('Table %table created.', array('%table' => $table_name))); // Check the characteristics of the field. $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec); @@ -329,7 +329,7 @@ class SchemaTestCase extends DrupalWebTestCase { 'primary key' => array('serial_column'), ); db_create_table($table_name, $table_spec); - $this->pass(t('Table %table created.', array('%table' => $table_name))); + $this->pass(format_string('Table %table created.', array('%table' => $table_name))); // Insert some rows to the table to test the handling of initial values. for ($i = 0; $i < 3; $i++) { @@ -339,7 +339,7 @@ class SchemaTestCase extends DrupalWebTestCase { } db_add_field($table_name, 'test_field', $field_spec); - $this->pass(t('Column %column created.', array('%column' => 'test_field'))); + $this->pass(format_string('Column %column created.', array('%column' => 'test_field'))); // Check the characteristics of the field. $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec); @@ -362,7 +362,7 @@ class SchemaTestCase extends DrupalWebTestCase { ->countQuery() ->execute() ->fetchField(); - $this->assertEqual($count, 0, t('Initial values filled out.')); + $this->assertEqual($count, 0, 'Initial values filled out.'); } // Check that the default value has been registered. @@ -376,7 +376,7 @@ class SchemaTestCase extends DrupalWebTestCase { ->condition('serial_column', $id) ->execute() ->fetchField(); - $this->assertEqual($field_value, $field_spec['default'], t('Default value registered.')); + $this->assertEqual($field_value, $field_spec['default'], 'Default value registered.'); } db_drop_field($table_name, $field_name); diff --git a/modules/simpletest/tests/tablesort.test b/modules/simpletest/tests/tablesort.test index 9c068f8..ffc9535 100644 --- a/modules/simpletest/tests/tablesort.test +++ b/modules/simpletest/tests/tablesort.test @@ -58,7 +58,7 @@ class TableSortTest extends DrupalUnitTestCase { ); $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); - $this->assertEqual($ts, $expected_ts, t('Simple table headers sorted correctly.')); + $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.'); // Test with simple table headers plus $_GET parameters that should _not_ // override the default. @@ -71,7 +71,7 @@ class TableSortTest extends DrupalUnitTestCase { ); $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); - $this->assertEqual($ts, $expected_ts, t('Simple table headers plus non-overriding $_GET parameters sorted correctly.')); + $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.'); // Test with simple table headers plus $_GET parameters that _should_ // override the default. @@ -87,7 +87,7 @@ class TableSortTest extends DrupalUnitTestCase { $expected_ts['query'] = array('alpha' => 'beta'); $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); - $this->assertEqual($ts, $expected_ts, t('Simple table headers plus $_GET parameters sorted correctly.')); + $this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.'); // Test complex table headers. @@ -118,7 +118,7 @@ class TableSortTest extends DrupalUnitTestCase { 'query' => array(), ); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); - $this->assertEqual($ts, $expected_ts, t('Complex table headers sorted correctly.')); + $this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.'); // Test complex table headers plus $_GET parameters that should _not_ // override the default. @@ -137,7 +137,7 @@ class TableSortTest extends DrupalUnitTestCase { 'query' => array(), ); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); - $this->assertEqual($ts, $expected_ts, t('Complex table headers plus non-overriding $_GET parameters sorted correctly.')); + $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.'); unset($_GET['sort'], $_GET['order'], $_GET['alpha']); // Test complex table headers plus $_GET parameters that _should_ @@ -159,7 +159,7 @@ class TableSortTest extends DrupalUnitTestCase { ); $ts = tablesort_init($headers); $this->verbose(strtr('$ts:
!ts
', array('!ts' => check_plain(var_export($ts, TRUE))))); - $this->assertEqual($ts, $expected_ts, t('Complex table headers plus $_GET parameters sorted correctly.')); + $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.'); unset($_GET['sort'], $_GET['order'], $_GET['alpha']); }