diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index 160f8ba6a96f9c5a94cf5268d040add13c0dc08a..eb0343afb93b6dee500b8e4dd3b435cccf357f8d 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -26,10 +26,10 @@ class AggregatorTestCase extends DrupalWebTestCase { function createFeed($feed_url = NULL) { $edit = $this->getFeedEditArray($feed_url); $this->drupalPost('admin/config/services/aggregator/add/feed', $edit, t('Save')); - $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), t('The feed !name has been added.', array('!name' => $edit['title']))); + $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), 'The feed ' . $edit['title'] . ' has been added.'); $feed = db_query("SELECT * FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title'], ':url' => $edit['url']))->fetch(); - $this->assertTrue(!empty($feed), t('The feed found in database.')); + $this->assertTrue(!empty($feed), 'The feed found in database.'); return $feed; } @@ -41,7 +41,7 @@ class AggregatorTestCase extends DrupalWebTestCase { */ function deleteFeed($feed) { $this->drupalPost('admin/config/services/aggregator/edit/feed/' . $feed->fid, array(), t('Delete')); - $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->title)), t('Feed deleted successfully.')); + $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->title)), 'Feed deleted successfully.'); } /** @@ -91,7 +91,7 @@ class AggregatorTestCase extends DrupalWebTestCase { function updateFeedItems(&$feed, $expected_count) { // First, let's ensure we can get to the rss xml. $this->drupalGet($feed->url); - $this->assertResponse(200, t('!url is reachable.', array('!url' => $feed->url))); + $this->assertResponse(200, $feed->url . ' is reachable.'); // Refresh the feed (simulated link click). $this->drupalGet('admin/config/services/aggregator/update/' . $feed->fid); @@ -104,7 +104,7 @@ class AggregatorTestCase extends DrupalWebTestCase { $feed->items[] = $item->iid; } $feed->item_count = count($feed->items); - $this->assertEqual($expected_count, $feed->item_count, t('Total items in feed equal to the total items in database (!val1 != !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count))); + $this->assertEqual($expected_count, $feed->item_count, 'Total items in feed equal to the total items in database (' . $expected_count . ' != ' . $feed->item_count . ')'); } /** @@ -115,7 +115,7 @@ class AggregatorTestCase extends DrupalWebTestCase { */ function removeFeedItems($feed) { $this->drupalPost('admin/config/services/aggregator/remove/' . $feed->fid, array(), t('Remove items')); - $this->assertRaw(t('The news items from %title have been removed.', array('%title' => $feed->title)), t('Feed items removed.')); + $this->assertRaw(t('The news items from %title have been removed.', array('%title' => $feed->title)), 'Feed items removed.'); } /** @@ -295,15 +295,15 @@ class AddFeedTestCase extends AggregatorTestCase { $feed = $this->createFeed(); // Check feed data. - $this->assertEqual($this->getUrl(), url('admin/config/services/aggregator/add/feed', array('absolute' => TRUE)), t('Directed to correct url.')); - $this->assertTrue($this->uniqueFeed($feed->title, $feed->url), t('The feed is unique.')); + $this->assertEqual($this->getUrl(), url('admin/config/services/aggregator/add/feed', array('absolute' => TRUE)), 'Directed to correct url.'); + $this->assertTrue($this->uniqueFeed($feed->title, $feed->url), 'The feed is unique.'); // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->fid); - $this->assertResponse(200, t('Feed source exists.')); - $this->assertText($feed->title, t('Page title')); + $this->assertResponse(200, 'Feed source exists.'); + $this->assertText($feed->title, 'Page title'); $this->drupalGet('aggregator/sources/' . $feed->fid . '/categorize'); - $this->assertResponse(200, t('Feed categorization page exists.')); + $this->assertResponse(200, 'Feed categorization page exists.'); // Delete feed. $this->deleteFeed($feed); @@ -327,11 +327,11 @@ class CategorizeFeedTestCase extends AggregatorTestCase { // Create 2 categories. $category_1 = array('title' => $this->randomName(10), 'description' => ''); $this->drupalPost('admin/config/services/aggregator/add/category', $category_1, t('Save')); - $this->assertRaw(t('The category %title has been added.', array('%title' => $category_1['title'])), t('The category %title has been added.', array('%title' => $category_1['title']))); + $this->assertRaw(t('The category %title has been added.', array('%title' => $category_1['title'])), 'The category ' . $category_1['title'] . ' has been added.'); $category_2 = array('title' => $this->randomName(10), 'description' => ''); $this->drupalPost('admin/config/services/aggregator/add/category', $category_2, t('Save')); - $this->assertRaw(t('The category %title has been added.', array('%title' => $category_2['title'])), t('The category %title has been added.', array('%title' => $category_2['title']))); + $this->assertRaw(t('The category %title has been added.', array('%title' => $category_2['title'])), 'The category ' . $category_2['title'] . ' has been added.'); // Get categories from database. $categories = $this->getCategories(); @@ -349,7 +349,7 @@ class CategorizeFeedTestCase extends AggregatorTestCase { // Assert the feed has two categories. $this->getFeedCategories($db_feed); - $this->assertEqual(count($db_feed->categories), 2, t('Feed has 2 categories')); + $this->assertEqual(count($db_feed->categories), 2, 'Feed has 2 categories'); } } @@ -377,16 +377,16 @@ class UpdateFeedTestCase extends AggregatorTestCase { $edit[$same_field] = $feed->{$same_field}; } $this->drupalPost('admin/config/services/aggregator/edit/feed/' . $feed->fid, $edit, t('Save')); - $this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title'])), t('The feed %name has been updated.', array('%name' => $edit['title']))); + $this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title'])), 'The feed ' . $edit['title'] . ' has been updated.'); // Check feed data. $this->assertEqual($this->getUrl(), url('admin/config/services/aggregator/', array('absolute' => TRUE))); - $this->assertTrue($this->uniqueFeed($edit['title'], $edit['url']), t('The feed is unique.')); + $this->assertTrue($this->uniqueFeed($edit['title'], $edit['url']), 'The feed is unique.'); // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->fid); - $this->assertResponse(200, t('Feed source exists.')); - $this->assertText($edit['title'], t('Page title')); + $this->assertResponse(200, 'Feed source exists.'); + $this->assertText($edit['title'], 'Page title'); // Delete feed. $feed->title = $edit['title']; // Set correct title so deleteFeed() will work. @@ -415,11 +415,11 @@ class RemoveFeedTestCase extends AggregatorTestCase { // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->fid); - $this->assertResponse(404, t('Deleted feed source does not exists.')); + $this->assertResponse(404, 'Deleted feed source does not exists.'); // Check database for feed. $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed->title, ':url' => $feed->url))->fetchField(); - $this->assertFalse($result, t('Feed not found in database')); + $this->assertFalse($result, 'Feed not found in database'); } } @@ -455,10 +455,10 @@ class UpdateFeedItemTestCase extends AggregatorTestCase { ); $this->drupalGet($edit['url']); - $this->assertResponse(array(200), t('URL !url is accessible', array('!url' => $edit['url']))); + $this->assertResponse(array(200), 'URL ' . $edit['url'] . ' is accessible'); $this->drupalPost('admin/config/services/aggregator/add/feed', $edit, t('Save')); - $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), t('The feed !name has been added.', array('!name' => $edit['title']))); + $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), 'The feed ' . $edit['title'] . ' has been added.'); $feed = db_query("SELECT * FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url']))->fetchObject(); $this->drupalGet('admin/config/services/aggregator/update/' . $feed->fid); @@ -480,7 +480,7 @@ class UpdateFeedItemTestCase extends AggregatorTestCase { $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(); - $this->assertTrue($before === $after, t('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after))); + $this->assertTrue($before === $after, 'Publish timestamp of feed item was not updated (' . $before . ' === ' . $after . ')'); } } @@ -541,14 +541,14 @@ class CategorizeFeedItemTestCase extends AggregatorTestCase { // Simulate form submission on "admin/config/services/aggregator/add/category". $edit = array('title' => $this->randomName(10), 'description' => ''); $this->drupalPost('admin/config/services/aggregator/add/category', $edit, t('Save')); - $this->assertRaw(t('The category %title has been added.', array('%title' => $edit['title'])), t('The category %title has been added.', array('%title' => $edit['title']))); + $this->assertRaw(t('The category %title has been added.', array('%title' => $edit['title'])), 'The category ' . $edit['title'] . ' has been added.'); $category = db_query("SELECT * FROM {aggregator_category} WHERE title = :title", array(':title' => $edit['title']))->fetch(); - $this->assertTrue(!empty($category), t('The category found in database.')); + $this->assertTrue(!empty($category), 'The category found in database.'); $link_path = 'aggregator/categories/' . $category->cid; $menu_link = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $link_path))->fetch(); - $this->assertTrue(!empty($menu_link), t('The menu link associated with the category found in database.')); + $this->assertTrue(!empty($menu_link), 'The menu link associated with the category found in database.'); $feed = $this->createFeed(); db_insert('aggregator_category_feed') @@ -559,7 +559,7 @@ class CategorizeFeedItemTestCase extends AggregatorTestCase { ->execute(); $this->updateFeedItems($feed, $this->getDefaultFeedItemCount()); $this->getFeedCategories($feed); - $this->assertTrue(!empty($feed->categories), t('The category found in the feed.')); + $this->assertTrue(!empty($feed->categories), 'The category found in the feed.'); // For each category of a feed, ensure feed items have that category, too. if (!empty($feed->categories) && !empty($feed->items)) { @@ -570,7 +570,7 @@ class CategorizeFeedItemTestCase extends AggregatorTestCase { ->execute() ->fetchField(); - $this->assertEqual($feed->item_count, $categorized_count, t('Total items in feed equal to the total categorized feed items in database')); + $this->assertEqual($feed->item_count, $categorized_count, 'Total items in feed equal to the total categorized feed items in database'); } } @@ -603,11 +603,11 @@ class ImportOPMLTestCase extends AggregatorTestCase { ->execute(); $this->drupalGet('admin/config/services/aggregator/add/opml'); - $this->assertText('A single OPML document may contain a collection of many feeds.', t('Looking for help text.')); - $this->assertFieldByName('files[upload]', '', t('Looking for file upload field.')); - $this->assertFieldByName('remote', '', t('Looking for remote URL field.')); - $this->assertFieldByName('refresh', '', t('Looking for refresh field.')); - $this->assertFieldByName("category[$cid]", $cid, t('Looking for category field.')); + $this->assertText('A single OPML document may contain a collection of many feeds.', 'Looking for help text.'); + $this->assertFieldByName('files[upload]', '', 'Looking for file upload field.'); + $this->assertFieldByName('remote', '', 'Looking for remote URL field.'); + $this->assertFieldByName('refresh', '', 'Looking for refresh field.'); + $this->assertFieldByName("category[$cid]", $cid, 'Looking for category field.'); } /** @@ -618,7 +618,7 @@ class ImportOPMLTestCase extends AggregatorTestCase { $edit = array(); $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); - $this->assertRaw(t('You must either upload a file or enter a URL.'), t('Error if no fields are filled.')); + $this->assertRaw(t('You must either upload a file or enter a URL.'), 'Error if no fields are filled.'); $path = $this->getEmptyOpml(); $edit = array( @@ -626,14 +626,14 @@ class ImportOPMLTestCase extends AggregatorTestCase { 'remote' => file_create_url($path), ); $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); - $this->assertRaw(t('You must either upload a file or enter a URL.'), t('Error if both fields are filled.')); + $this->assertRaw(t('You must either upload a file or enter a URL.'), 'Error if both fields are filled.'); $edit = array('remote' => 'invalidUrl://empty'); $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); - $this->assertText(t('This URL is not valid.'), t('Error if the URL is invalid.')); + $this->assertText(t('This URL is not valid.'), 'Error if the URL is invalid.'); $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); - $this->assertEqual($before, $after, t('No feeds were added during the three last form submissions.')); + $this->assertEqual($before, $after, 'No feeds were added during the three last form submissions.'); } /** @@ -644,14 +644,14 @@ class ImportOPMLTestCase extends AggregatorTestCase { $form['files[upload]'] = $this->getInvalidOpml(); $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import')); - $this->assertText(t('No new feed has been added.'), t('Attempting to upload invalid XML.')); + $this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.'); $edit = array('remote' => file_create_url($this->getEmptyOpml())); $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); - $this->assertText(t('No new feed has been added.'), t('Attempting to load empty OPML from remote URL.')); + $this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.'); $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); - $this->assertEqual($before, $after, t('No feeds were added during the two last form submissions.')); + $this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.'); db_delete('aggregator_feed')->execute(); db_delete('aggregator_category')->execute(); @@ -675,11 +675,11 @@ class ImportOPMLTestCase extends AggregatorTestCase { 'category[1]' => $category, ); $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import')); - $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url'])), t('Verifying that a duplicate URL was identified')); - $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title'])), t('Verifying that a duplicate title was identified')); + $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url'])), 'Verifying that a duplicate URL was identified'); + $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title'])), 'Verifying that a duplicate title was identified'); $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); - $this->assertEqual($after, 2, t('Verifying that two distinct feeds were added.')); + $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.'); $feeds_from_db = db_query("SELECT f.title, f.url, f.refresh, cf.cid FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} cf ON f.fid = cf.fid"); $refresh = $category = TRUE; @@ -690,10 +690,10 @@ class ImportOPMLTestCase extends AggregatorTestCase { $refresh = $refresh && $feed->refresh == 900; } - $this->assertEqual($title[$feeds[0]['url']], $feeds[0]['title'], t('First feed was added correctly.')); - $this->assertEqual($url[$feeds[1]['title']], $feeds[1]['url'], t('Second feed was added correctly.')); - $this->assertTrue($refresh, t('Refresh times are correct.')); - $this->assertTrue($category, t('Categories are correct.')); + $this->assertEqual($title[$feeds[0]['url']], $feeds[0]['title'], 'First feed was added correctly.'); + $this->assertEqual($url[$feeds[1]['title']], $feeds[1]['url'], 'Second feed was added correctly.'); + $this->assertTrue($refresh, 'Refresh times are correct.'); + $this->assertTrue($category, 'Categories are correct.'); } function testOPMLImport() { @@ -793,20 +793,20 @@ class AggregatorRenderingTestCase extends AggregatorTestCase { $this->assertFieldByName($block['module'] . '_' . $block['delta'] . '[region]', '', 'Aggregator feed block is available for positioning.'); // Position it. $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), t('Block successfully moved to %region_name region.', array( '%region_name' => $region))); + $this->assertText(t('The block settings have been updated.'), 'Block successfully moved to ' . $region . ' region.'); // Confirm that the block is now being displayed on pages. $this->drupalGet('node'); - $this->assertText(t($block['title']), t('Feed block is displayed on the page.')); + $this->assertText(t($block['title']), 'Feed block is displayed on the page.'); // Find the expected read_more link. $href = 'aggregator/sources/' . $feed->fid; $links = $this->xpath('//a[@href = :href]', array(':href' => url($href))); - $this->assert(isset($links[0]), t('Link to href %href found.', array('%href' => $href))); + $this->assert(isset($links[0]), 'Link to href ' . $href . ' found.'); // Visit that page. $this->drupalGet($href); $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->title)); - $this->assertFalse(empty($correct_titles), t('Aggregator feed page is available and has the correct title.')); + $this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.'); } } @@ -837,7 +837,7 @@ class FeedParserTestCase extends AggregatorTestCase { $feed = $this->createFeed($this->getRSS091Sample()); aggregator_refresh($feed); $this->drupalGet('aggregator/sources/' . $feed->fid); - $this->assertResponse(200, t('Feed %name exists.', array('%name' => $feed->title))); + $this->assertResponse(200, 'Feed ' . $feed->title . ' exists.'); $this->assertText('First example feed item title'); $this->assertLinkByHref('http://example.com/example-turns-one'); $this->assertText('First example feed item description.'); @@ -850,7 +850,7 @@ class FeedParserTestCase extends AggregatorTestCase { $feed = $this->createFeed($this->getAtomSample()); aggregator_refresh($feed); $this->drupalGet('aggregator/sources/' . $feed->fid); - $this->assertResponse(200, t('Feed %name exists.', array('%name' => $feed->title))); + $this->assertResponse(200, 'Feed ' . $feed->title . ' exists.'); $this->assertText('Atom-Powered Robots Run Amok'); $this->assertLinkByHref('http://example.org/2003/12/13/atom03'); $this->assertText('Some text.'); diff --git a/modules/block/block.test b/modules/block/block.test index 86584df7e813a271cb709e18e725031f7895677b..7cb70aaf1709e867abe8cd96e71c3c4787c8e8c2 100644 --- a/modules/block/block.test +++ b/modules/block/block.test @@ -46,9 +46,9 @@ class BlockTestCase extends DrupalWebTestCase { function testCustomBlock() { // Confirm that the add block link appears on block overview pages. $this->drupalGet('admin/structure/block'); - $this->assertRaw(l('Add block', 'admin/structure/block/add'), t('Add block link is present on block overview page for default theme.')); + $this->assertRaw(l('Add block', 'admin/structure/block/add'), 'Add block link is present on block overview page for default theme.'); $this->drupalGet('admin/structure/block/list/seven'); - $this->assertRaw(l('Add block', 'admin/structure/block/list/seven/add'), t('Add block link is present on block overview page for non-default theme.')); + $this->assertRaw(l('Add block', 'admin/structure/block/list/seven/add'), 'Add block link is present on block overview page for non-default theme.'); // Confirm that hidden regions are not shown as options for block placement // when adding a new block. @@ -59,7 +59,7 @@ class BlockTestCase extends DrupalWebTestCase { if ($theme->status) { foreach ($theme->info['regions_hidden'] as $hidden_region) { $elements = $this->xpath('//select[@id=:id]//option[@value=:value]', array(':id' => 'edit-regions-' . $key, ':value' => $hidden_region)); - $this->assertFalse(isset($elements[0]), t('The hidden region @region is not available for @theme.', array('@region' => $hidden_region, '@theme' => $key))); + $this->assertFalse(isset($elements[0]), 'The hidden region ' . $hidden_region . ' is not available for ' . $key . '.'); } } } @@ -72,11 +72,11 @@ class BlockTestCase extends DrupalWebTestCase { $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block')); // Confirm that the custom block has been created, and then query the created bid. - $this->assertText(t('The block has been created.'), t('Custom block successfully created.')); + $this->assertText(t('The block has been created.'), 'Custom block successfully created.'); $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField(); // Check to see if the custom block was created by checking that it's in the database.. - $this->assertNotNull($bid, t('Custom block found in database')); + $this->assertNotNull($bid, 'Custom block found in database'); // Check if the block can be moved to all availble regions. $custom_block['module'] = 'block'; @@ -87,8 +87,8 @@ class BlockTestCase extends DrupalWebTestCase { // Verify presence of configure and delete links for custom block. $this->drupalGet('admin/structure/block'); - $this->assertRaw(l(t('configure'), 'admin/structure/block/manage/block/' . $bid . '/configure'), t('Custom block configure link found.')); - $this->assertRaw(l(t('delete'), 'admin/structure/block/manage/block/' . $bid . '/delete'), t('Custom block delete link found.')); + $this->assertRaw(l(t('configure'), 'admin/structure/block/manage/block/' . $bid . '/configure'), 'Custom block configure link found.'); + $this->assertRaw(l(t('delete'), 'admin/structure/block/manage/block/' . $bid . '/delete'), 'Custom block delete link found.'); // Set visibility only for authenticated users, to verify delete functionality. $edit = array(); @@ -98,10 +98,10 @@ class BlockTestCase extends DrupalWebTestCase { // Delete the created custom block & verify that it's been deleted and no longer appearing on the page. $this->clickLink(t('delete')); $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/delete', array(), t('Delete')); - $this->assertRaw(t('The block %title has been removed.', array('%title' => $custom_block['info'])), t('Custom block successfully deleted.')); - $this->assertNoText(t($custom_block['title']), t('Custom block no longer appears on page.')); + $this->assertRaw(t('The block %title has been removed.', array('%title' => $custom_block['info'])), 'Custom block successfully deleted.'); + $this->assertNoText(t($custom_block['title']), 'Custom block no longer appears on page.'); $count = db_query("SELECT 1 FROM {block_role} WHERE module = :module AND delta = :delta", array(':module' => $custom_block['module'], ':delta' => $custom_block['delta']))->fetchField(); - $this->assertFalse($count, t('Table block_role being cleaned.')); + $this->assertFalse($count, 'Table block_role being cleaned.'); } /** @@ -125,20 +125,20 @@ class BlockTestCase extends DrupalWebTestCase { // Confirm that the custom block is being displayed using configured text format. $this->drupalGet('node'); - $this->assertRaw('

Full HTML

', t('Custom block successfully being displayed using Full HTML.')); + $this->assertRaw('

Full HTML

', 'Custom block successfully being displayed using Full HTML.'); // Confirm that a user without access to Full HTML can not see the body field, // but can still submit the form without errors. $block_admin = $this->drupalCreateUser(array('administer blocks')); $this->drupalLogin($block_admin); $this->drupalGet('admin/structure/block/manage/block/' . $bid . '/configure'); - $this->assertFieldByXPath("//textarea[@name='body[value]' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), t('Body field contains denied message')); + $this->assertFieldByXPath("//textarea[@name='body[value]' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Body field contains denied message'); $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', array(), t('Save block')); $this->assertNoText(t('Ensure that each block description is unique.')); // Confirm that the custom block is still being displayed using configured text format. $this->drupalGet('node'); - $this->assertRaw('

Full HTML

', t('Custom block successfully being displayed using Full HTML.')); + $this->assertRaw('

Full HTML

', 'Custom block successfully being displayed using Full HTML.'); } /** @@ -173,18 +173,18 @@ class BlockTestCase extends DrupalWebTestCase { $this->moveBlockToRegion($block, $this->regions[1]); $this->drupalGet(''); - $this->assertText($title, t('Block was displayed on the front page.')); + $this->assertText($title, 'Block was displayed on the front page.'); $this->drupalGet('user'); - $this->assertNoText($title, t('Block was not displayed according to block visibility rules.')); + $this->assertNoText($title, 'Block was not displayed according to block visibility rules.'); $this->drupalGet('USER/' . $this->admin_user->uid); - $this->assertNoText($title, t('Block was not displayed according to block visibility rules regardless of path case.')); + $this->assertNoText($title, 'Block was not displayed according to block visibility rules regardless of path case.'); // Confirm that the block is not displayed to anonymous users. $this->drupalLogout(); $this->drupalGet(''); - $this->assertNoText($title, t('Block was not displayed to anonymous users.')); + $this->assertNoText($title, 'Block was not displayed to anonymous users.'); } /** @@ -199,14 +199,14 @@ class BlockTestCase extends DrupalWebTestCase { // Set block title to confirm that interface works and override any custom titles. $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => $block['title']), t('Save block')); - $this->assertText(t('The block configuration has been saved.'), t('Block title set.')); + $this->assertText(t('The block configuration has been saved.'), 'Block title set.'); $bid = db_query("SELECT bid FROM {block} WHERE module = :module AND delta = :delta", array( ':module' => $block['module'], ':delta' => $block['delta'], ))->fetchField(); // Check to see if the block was created by checking that it's in the database. - $this->assertNotNull($bid, t('Block found in database')); + $this->assertNotNull($bid, 'Block found in database'); // Check if the block can be moved to all availble regions. foreach ($this->regions as $region) { @@ -219,21 +219,21 @@ class BlockTestCase extends DrupalWebTestCase { $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); // Confirm that the block was moved to the proper region. - $this->assertText(t('The block settings have been updated.'), t('Block successfully move to disabled region.')); - $this->assertNoText(t($block['title']), t('Block no longer appears on page.')); + $this->assertText(t('The block settings have been updated.'), 'Block successfully move to disabled region.'); + $this->assertNoText(t($block['title']), 'Block no longer appears on page.'); // Confirm that the regions xpath is not availble $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-block-' . $bid)); - $this->assertNoFieldByXPath($xpath, FALSE, t('Custom block found in no regions.')); + $this->assertNoFieldByXPath($xpath, FALSE, 'Custom block found in no regions.'); // For convenience of developers, put the navigation block back. $edit = array(); $edit[$block['module'] . '_' . $block['delta'] . '[region]'] = $this->regions[1]; $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), t('Block successfully move to first sidebar region.')); + $this->assertText(t('The block settings have been updated.'), 'Block successfully move to first sidebar region.'); $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => 'Navigation'), t('Save block')); - $this->assertText(t('The block configuration has been saved.'), t('Block title set.')); + $this->assertText(t('The block configuration has been saved.'), 'Block title set.'); } function moveBlockToRegion($block, $region) { @@ -243,18 +243,18 @@ class BlockTestCase extends DrupalWebTestCase { $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); // Confirm that the block was moved to the proper region. - $this->assertText(t('The block settings have been updated.'), t('Block successfully moved to %region_name region.', array( '%region_name' => $region))); + $this->assertText(t('The block settings have been updated.'), 'Block successfully moved to ' . $region . ' region.'); // Confirm that the block is being displayed. $this->drupalGet('node'); - $this->assertText(t($block['title']), t('Block successfully being displayed on the page.')); + $this->assertText(t($block['title']), 'Block successfully being displayed on the page.'); // Confirm that the custom block was found at the proper region. $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( ':region-class' => 'region region-' . str_replace('_', '-', $region), ':block-id' => 'block-' . $block['module'] . '-' . $block['delta'], )); - $this->assertFieldByXPath($xpath, FALSE, t('Custom block found in %region_name region.', array('%region_name' => $region))); + $this->assertFieldByXPath($xpath, FALSE, 'Custom block found in ' . $region . ' region.'); } /** @@ -262,14 +262,14 @@ class BlockTestCase extends DrupalWebTestCase { */ function testBlockRehash() { module_enable(array('block_test')); - $this->assertTrue(module_exists('block_test'), t('Test block module enabled.')); + $this->assertTrue(module_exists('block_test'), 'Test block module enabled.'); // Our new block should be inserted in the database when we visit the // block management page. $this->drupalGet('admin/structure/block'); // Our test block's caching should default to DRUPAL_CACHE_PER_ROLE. $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField(); - $this->assertEqual($current_caching, DRUPAL_CACHE_PER_ROLE, t('Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.')); + $this->assertEqual($current_caching, DRUPAL_CACHE_PER_ROLE, 'Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.'); // Disable caching for this block. variable_set('block_test_caching', DRUPAL_NO_CACHE); @@ -277,7 +277,7 @@ class BlockTestCase extends DrupalWebTestCase { drupal_flush_all_caches(); // Verify that the database is updated with the new caching mode. $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField(); - $this->assertEqual($current_caching, DRUPAL_NO_CACHE, t("Test block's database entry updated to DRUPAL_NO_CACHE.")); + $this->assertEqual($current_caching, DRUPAL_NO_CACHE, "Test block's database entry updated to DRUPAL_NO_CACHE."); } } @@ -328,7 +328,7 @@ class NewDefaultThemeBlocks extends DrupalWebTestCase { $themes['admin'] = $admin_theme; } $count = db_query_range('SELECT 1 FROM {block} WHERE theme NOT IN (:themes)', 0, 1, array(':themes' => $themes))->fetchField(); - $this->assertFalse($count, t('Only the default theme and the admin theme have blocks.')); + $this->assertFalse($count, 'Only the default theme and the admin theme have blocks.'); // Populate list of all blocks for matching against new theme. $blocks = array(); @@ -346,7 +346,7 @@ class NewDefaultThemeBlocks extends DrupalWebTestCase { $result = db_query('SELECT * FROM {block} WHERE theme = :theme', array(':theme' => 'stark')); foreach ($result as $block) { unset($block->theme, $block->bid); - $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block %name matched', array('%name' => $block->module . '-' . $block->delta))); + $this->assertEqual($blocks[$block->module][$block->delta], $block, 'Block ' . $block->module . '-' . $block->delta . ' matched'); } } } @@ -373,13 +373,13 @@ class BlockAdminThemeTestCase extends DrupalWebTestCase { // Ensure that access to block admin page is denied when theme is disabled. $this->drupalGet('admin/structure/block/list/stark'); - $this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed')); + $this->assertResponse(403, 'The block admin page for a disabled theme can not be accessed'); // Enable admin theme and confirm that tab is accessible. $edit['admin_theme'] = 'stark'; $this->drupalPost('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/list/stark'); - $this->assertResponse(200, t('The block admin page for the admin theme can be accessed')); + $this->assertResponse(200, 'The block admin page for the admin theme can be accessed'); } } @@ -433,20 +433,20 @@ class BlockCacheTestCase extends DrupalWebTestCase { variable_set('block_test_content', $current_content); $this->drupalLogin($this->normal_user); $this->drupalGet(''); - $this->assertText($current_content, t('Block content displays.')); + $this->assertText($current_content, 'Block content displays.'); // Change the content, but the cached copy should still be served. $old_content = $current_content; $current_content = $this->randomName(); variable_set('block_test_content', $current_content); $this->drupalGet(''); - $this->assertText($old_content, t('Block is served from the cache.')); + $this->assertText($old_content, 'Block is served from the cache.'); // Clear the cache and verify that the stale data is no longer there. cache_clear_all(); $this->drupalGet(''); - $this->assertNoText($old_content, t('Block cache clear removes stale cache data.')); - $this->assertText($current_content, t('Fresh block content is displayed after clearing the cache.')); + $this->assertNoText($old_content, 'Block cache clear removes stale cache data.'); + $this->assertText($current_content, 'Fresh block content is displayed after clearing the cache.'); // Test whether the cached data is served for the correct users. $old_content = $current_content; @@ -454,19 +454,19 @@ class BlockCacheTestCase extends DrupalWebTestCase { variable_set('block_test_content', $current_content); $this->drupalLogout(); $this->drupalGet(''); - $this->assertNoText($old_content, t('Anonymous user does not see content cached per-role for normal user.')); + $this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.'); $this->drupalLogin($this->normal_user_alt); $this->drupalGet(''); - $this->assertText($old_content, t('User with the same roles sees per-role cached content.')); + $this->assertText($old_content, 'User with the same roles sees per-role cached content.'); $this->drupalLogin($this->admin_user); $this->drupalGet(''); - $this->assertNoText($old_content, t('Admin user does not see content cached per-role for normal user.')); + $this->assertNoText($old_content, 'Admin user does not see content cached per-role for normal user.'); $this->drupalLogin($this->normal_user); $this->drupalGet(''); - $this->assertText($old_content, t('Block is served from the per-role cache.')); + $this->assertText($old_content, 'Block is served from the per-role cache.'); } /** @@ -478,7 +478,7 @@ class BlockCacheTestCase extends DrupalWebTestCase { variable_set('block_test_content', $current_content); $this->drupalGet(''); - $this->assertText($current_content, t('Block content displays.')); + $this->assertText($current_content, 'Block content displays.'); $old_content = $current_content; $current_content = $this->randomName(); @@ -486,7 +486,7 @@ class BlockCacheTestCase extends DrupalWebTestCase { $this->drupalLogout(); $this->drupalGet('user'); - $this->assertText($old_content, t('Block content served from global cache.')); + $this->assertText($old_content, 'Block content served from global cache.'); } /** @@ -499,13 +499,13 @@ class BlockCacheTestCase extends DrupalWebTestCase { // If DRUPAL_NO_CACHE has no effect, the next request would be cached. $this->drupalGet(''); - $this->assertText($current_content, t('Block content displays.')); + $this->assertText($current_content, 'Block content displays.'); // A cached copy should not be served. $current_content = $this->randomName(); variable_set('block_test_content', $current_content); $this->drupalGet(''); - $this->assertText($current_content, t('DRUPAL_NO_CACHE prevents blocks from being cached.')); + $this->assertText($current_content, 'DRUPAL_NO_CACHE prevents blocks from being cached.'); } /** @@ -518,22 +518,22 @@ class BlockCacheTestCase extends DrupalWebTestCase { $this->drupalLogin($this->normal_user); $this->drupalGet(''); - $this->assertText($current_content, t('Block content displays.')); + $this->assertText($current_content, 'Block content displays.'); $old_content = $current_content; $current_content = $this->randomName(); variable_set('block_test_content', $current_content); $this->drupalGet(''); - $this->assertText($old_content, t('Block is served from per-user cache.')); + $this->assertText($old_content, 'Block is served from per-user cache.'); $this->drupalLogin($this->normal_user_alt); $this->drupalGet(''); - $this->assertText($current_content, t('Per-user block cache is not served for other users.')); + $this->assertText($current_content, 'Per-user block cache is not served for other users.'); $this->drupalLogin($this->normal_user); $this->drupalGet(''); - $this->assertText($old_content, t('Per-user block cache is persistent.')); + $this->assertText($old_content, 'Per-user block cache is persistent.'); } /** @@ -545,16 +545,16 @@ class BlockCacheTestCase extends DrupalWebTestCase { variable_set('block_test_content', $current_content); $this->drupalGet('node'); - $this->assertText($current_content, t('Block content displays on the node page.')); + $this->assertText($current_content, 'Block content displays on the node page.'); $old_content = $current_content; $current_content = $this->randomName(); variable_set('block_test_content', $current_content); $this->drupalGet('user'); - $this->assertNoText($old_content, t('Block content cached for the node page does not show up for the user page.')); + $this->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.'); $this->drupalGet('node'); - $this->assertText($old_content, t('Block content cached for the node page.')); + $this->assertText($old_content, 'Block content cached for the node page.'); } /** @@ -568,7 +568,7 @@ class BlockCacheTestCase extends DrupalWebTestCase { $current_mode = db_query("SELECT cache FROM {block} WHERE module = 'block_test'")->fetchField(); if ($current_mode != $cache_mode) { - $this->fail(t('Unable to set cache mode to %mode. Current mode: %current_mode', array('%mode' => $cache_mode, '%current_mode' => $current_mode))); + $this->fail('Unable to set cache mode to ' . $cache_mode . '. Current mode: ' . $current_mode); } } } @@ -607,6 +607,6 @@ class BlockHTMLIdTestCase extends DrupalWebTestCase { */ function testHTMLId() { $this->drupalGet(''); - $this->assertRaw('block-block-test-test-html-id', t('HTML id for test block is valid.')); + $this->assertRaw('block-block-test-test-html-id', 'HTML id for test block is valid.'); } } diff --git a/modules/blog/blog.test b/modules/blog/blog.test index 500a9d74f1d8feea7a87efb9c0bfb3a38391585a..be0e89fdc250475c1a2a99a99bc44388cb820499 100644 --- a/modules/blog/blog.test +++ b/modules/blog/blog.test @@ -38,8 +38,8 @@ class BlogTestCase extends DrupalWebTestCase { $this->drupalGet('blog/' . $this->big_user->uid); $this->assertResponse(200); - $this->assertTitle(t("@name's blog", array('@name' => format_username($this->big_user))) . ' | Drupal', t('Blog title was displayed')); - $this->assertText(t('You are not allowed to post a new blog entry.'), t('No new entries can be posted without the right permission')); + $this->assertTitle(t("@name's blog", array('@name' => format_username($this->big_user))) . ' | Drupal', 'Blog title was displayed'); + $this->assertText(t('You are not allowed to post a new blog entry.'), 'No new entries can be posted without the right permission'); } /** @@ -50,8 +50,8 @@ class BlogTestCase extends DrupalWebTestCase { $this->drupalGet('blog/' . $this->own_user->uid); $this->assertResponse(200); - $this->assertTitle(t("@name's blog", array('@name' => format_username($this->own_user))) . ' | Drupal', t('Blog title was displayed')); - $this->assertText(t('@author has not created any blog entries.', array('@author' => format_username($this->own_user))), t('Users blog displayed with no entries')); + $this->assertTitle(t("@name's blog", array('@name' => format_username($this->own_user))) . ' | Drupal', 'Blog title was displayed'); + $this->assertText(t('@author has not created any blog entries.', array('@author' => format_username($this->own_user))), 'Users blog displayed with no entries'); } /** @@ -69,7 +69,7 @@ class BlogTestCase extends DrupalWebTestCase { $edit = array(); $edit['blog_block_count'] = 5; $this->drupalPost('admin/structure/block/manage/blog/recent/configure', $edit, t('Save block')); - $this->assertEqual(variable_get('blog_block_count', 10), 5, t('Number of recent blog posts changed.')); + $this->assertEqual(variable_get('blog_block_count', 10), 5, 'Number of recent blog posts changed.'); // Do basic tests for each user. $this->doBasicTests($this->any_user, TRUE); @@ -128,31 +128,31 @@ class BlogTestCase extends DrupalWebTestCase { $this->drupalGet('admin/help/blog'); $this->assertResponse($response2); if ($response2 == 200) { - $this->assertTitle(t('Blog | Drupal'), t('Blog help node was displayed')); - $this->assertText(t('Blog'), t('Blog help node was displayed')); + $this->assertTitle(t('Blog | Drupal'), 'Blog help node was displayed'); + $this->assertText(t('Blog'), 'Blog help node was displayed'); } // Verify the blog block was displayed. $this->drupalGet(''); $this->assertResponse(200); - $this->assertText(t('Recent blog posts'), t('Blog block was displayed')); + $this->assertText(t('Recent blog posts'), 'Blog block was displayed'); // View blog node. $this->drupalGet('node/' . $node->nid); $this->assertResponse(200); - $this->assertTitle($node->title . ' | Drupal', t('Blog node was displayed')); + $this->assertTitle($node->title . ' | Drupal', 'Blog node was displayed'); $breadcrumb = array( l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => format_username($node_user))), 'blog/' . $node_user->uid), ); - $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), t('Breadcrumbs were displayed')); + $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed'); // View blog edit node. $this->drupalGet('node/' . $node->nid . '/edit'); $this->assertResponse($response); if ($response == 200) { - $this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', t('Blog edit node was displayed')); + $this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', 'Blog edit node was displayed'); } if ($response == 200) { @@ -162,12 +162,12 @@ class BlogTestCase extends DrupalWebTestCase { $edit["title"] = 'node/' . $node->nid; $edit["body[$langcode][0][value]"] = $this->randomName(256); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); - $this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), t('Blog node was edited')); + $this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), 'Blog node was edited'); // Delete blog node. $this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete')); $this->assertResponse($response); - $this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), t('Blog node was deleted')); + $this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), 'Blog node was deleted'); } } @@ -181,29 +181,29 @@ class BlogTestCase extends DrupalWebTestCase { // Confirm blog entries link exists on the user page. $this->drupalGet('user/' . $user->uid); $this->assertResponse(200); - $this->assertText(t('View recent blog entries'), t('View recent blog entries link was displayed')); + $this->assertText(t('View recent blog entries'), 'View recent blog entries link was displayed'); // Confirm the recent blog entries link goes to the user's blog page. $this->clickLink('View recent blog entries'); - $this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), t('View recent blog entries link target was correct')); + $this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), 'View recent blog entries link target was correct'); // Confirm a blog page was displayed. $this->drupalGet('blog'); $this->assertResponse(200); - $this->assertTitle('Blogs | Drupal', t('Blog page was displayed')); - $this->assertText(t('Home'), t('Breadcrumbs were displayed')); + $this->assertTitle('Blogs | Drupal', 'Blog page was displayed'); + $this->assertText(t('Home'), 'Breadcrumbs were displayed'); $this->assertLink(t('Create new blog entry')); // Confirm a blog page was displayed per user. $this->drupalGet('blog/' . $user->uid); - $this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), t('User blog node was displayed')); + $this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), 'User blog node was displayed'); // Confirm a blog feed was displayed. $this->drupalGet('blog/feed'); - $this->assertTitle(t('Drupal blogs'), t('Blog feed was displayed')); + $this->assertTitle(t('Drupal blogs'), 'Blog feed was displayed'); // Confirm a blog feed was displayed per user. $this->drupalGet('blog/' . $user->uid . '/feed'); - $this->assertTitle(t("@name's blog", array('@name' => format_username($user))), t('User blog feed was displayed')); + $this->assertTitle(t("@name's blog", array('@name' => format_username($user))), 'User blog feed was displayed'); } } diff --git a/modules/book/book.test b/modules/book/book.test index a544617d4ee74a5ad7e7a80fdf2f9d44a26da6f0..685a6fce4faad5524f95d8385d44cb4c272bd248 100644 --- a/modules/book/book.test +++ b/modules/book/book.test @@ -5,10 +5,10 @@ class BookTestCase extends DrupalWebTestCase { protected $book; // $book_author is a user with permission to author a book. protected $book_author; - // $web_user is a user with permission to view a book + // $web_user is a user with permission to view a book // and access the printer-friendly version. protected $web_user; - + public static function getInfo() { return array( 'name' => 'Book functionality', @@ -19,12 +19,12 @@ class BookTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('book'); - + // Create users. $this->book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books')); $this->web_user = $this->drupalCreateUser(array('access printer-friendly version')); } - + /** * Create a new book with a page hierarchy. */ @@ -52,7 +52,7 @@ class BookTestCase extends DrupalWebTestCase { $nodes[] = $this->createBookNode($book->nid); // Node 4. $this->drupalLogout(); - + return $nodes; } @@ -63,7 +63,7 @@ class BookTestCase extends DrupalWebTestCase { // Create new book. $nodes = $this->createBook(); $book = $this->book; - + $this->drupalLogin($this->web_user); // Check that book pages display along with the correct outlines and @@ -119,23 +119,23 @@ class BookTestCase extends DrupalWebTestCase { // Check outline structure. if ($nodes !== NULL) { - $this->assertPattern($this->generateOutlinePattern($nodes), t('Node ' . $number . ' outline confirmed.')); + $this->assertPattern($this->generateOutlinePattern($nodes), 'Node ' . $number . ' outline confirmed.'); } else { - $this->pass(t('Node ' . $number . ' doesn\'t have outline.')); + $this->pass('Node ' . $number . ' doesn\'t have outline.'); } // Check previous, up, and next links. if ($previous) { - $this->assertRaw(l('‹ ' . $previous->title, 'node/' . $previous->nid, array('attributes' => array('class' => array('page-previous'), 'title' => t('Go to previous page')))), t('Previous page link found.')); + $this->assertRaw(l('‹ ' . $previous->title, 'node/' . $previous->nid, array('attributes' => array('class' => array('page-previous'), 'title' => t('Go to previous page')))), 'Previous page link found.'); } if ($up) { - $this->assertRaw(l('up', 'node/' . $up->nid, array('attributes' => array('class' => array('page-up'), 'title' => t('Go to parent page')))), t('Up page link found.')); + $this->assertRaw(l('up', 'node/' . $up->nid, array('attributes' => array('class' => array('page-up'), 'title' => t('Go to parent page')))), 'Up page link found.'); } if ($next) { - $this->assertRaw(l($next->title . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => array('page-next'), 'title' => t('Go to next page')))), t('Next page link found.')); + $this->assertRaw(l($next->title . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => array('page-next'), 'title' => t('Go to next page')))), 'Next page link found.'); } // Compute the expected breadcrumb. @@ -153,12 +153,12 @@ class BookTestCase extends DrupalWebTestCase { } // Compare expected and got breadcrumbs. - $this->assertIdentical($expected_breadcrumb, $got_breadcrumb, t('The breadcrumb is correctly displayed on the page.')); + $this->assertIdentical($expected_breadcrumb, $got_breadcrumb, 'The breadcrumb is correctly displayed on the page.'); // Check printer friendly version. $this->drupalGet('book/export/html/' . $node->nid); - $this->assertText($node->title, t('Printer friendly title found.')); - $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Printer friendly body found.')); + $this->assertText($node->title, 'Printer friendly title found.'); + $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), 'Printer friendly body found.'); $number++; } @@ -206,44 +206,44 @@ class BookTestCase extends DrupalWebTestCase { // Check to make sure the book node was created. $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertNotNull(($node === FALSE ? NULL : $node), t('Book node found in database.')); + $this->assertNotNull(($node === FALSE ? NULL : $node), 'Book node found in database.'); $number++; return $node; } - + /** * Tests book export ("printer-friendly version") functionality. */ function testBookExport() { // Create a book. $nodes = $this->createBook(); - + // Login as web user and view printer-friendly version. $this->drupalLogin($this->web_user); $this->drupalGet('node/' . $this->book->nid); $this->clickLink(t('Printer-friendly version')); - + // Make sure each part of the book is there. foreach ($nodes as $node) { - $this->assertText($node->title, t('Node title found in printer friendly version.')); - $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Node body found in printer friendly version.')); + $this->assertText($node->title, 'Node title found in printer friendly version.'); + $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), 'Node body found in printer friendly version.'); } - + // Make sure we can't export an unsupported format. $this->drupalGet('book/export/foobar/' . $this->book->nid); - $this->assertResponse('404', t('Unsupported export format returned "not found".')); - + $this->assertResponse('404', 'Unsupported export format returned "not found".'); + // Make sure an anonymous user cannot view printer-friendly version. $this->drupalLogout(); - + // Load the book and verify there is no printer-friendly version link. $this->drupalGet('node/' . $this->book->nid); - $this->assertNoLink(t('Printer-friendly version'), t('Anonymous user is not shown link to printer-friendly version.')); - + $this->assertNoLink(t('Printer-friendly version'), 'Anonymous user is not shown link to printer-friendly version.'); + // Try getting the URL directly, and verify it fails. $this->drupalGet('book/export/html/' . $this->book->nid); - $this->assertResponse('403', t('Anonymous user properly forbidden.')); + $this->assertResponse('403', 'Anonymous user properly forbidden.'); } } @@ -267,12 +267,12 @@ class BookBlockTestCase extends DrupalWebTestCase { function testBookNavigationBlock() { // Set block title to confirm that the interface is availble. $this->drupalPost('admin/structure/block/manage/book/navigation/configure', array('title' => $this->randomName(8)), t('Save block')); - $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.')); + $this->assertText(t('The block configuration has been saved.'), 'Block configuration set.'); // Set the block to a region to confirm block is availble. $edit = array(); $edit['book_navigation[region]'] = 'footer'; $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.')); + $this->assertText(t('The block settings have been updated.'), 'Block successfully move to footer region.'); } } diff --git a/modules/comment/comment.test b/modules/comment/comment.test index 54a39bf0135c33f51fdb9092e4140bbe0edee855..55882c2342a0298d3efa37846a4e6ede82ccaa7a 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -44,7 +44,7 @@ class CommentHelperCase extends DrupalWebTestCase { $edit['subject'] = $subject; } else { - $this->assertNoFieldByName('subject', '', t('Subject field not found.')); + $this->assertNoFieldByName('subject', '', 'Subject field not found.'); } if ($contact !== NULL && is_array($contact)) { @@ -53,19 +53,19 @@ class CommentHelperCase extends DrupalWebTestCase { switch ($preview_mode) { case DRUPAL_REQUIRED: // Preview required so no save button should be found. - $this->assertNoFieldByName('op', t('Save'), t('Save button not found.')); + $this->assertNoFieldByName('op', t('Save'), 'Save button not found.'); $this->drupalPost(NULL, $edit, t('Preview')); // Don't break here so that we can test post-preview field presence and // function below. case DRUPAL_OPTIONAL: - $this->assertFieldByName('op', t('Preview'), t('Preview button found.')); - $this->assertFieldByName('op', t('Save'), t('Save button found.')); + $this->assertFieldByName('op', t('Preview'), 'Preview button found.'); + $this->assertFieldByName('op', t('Save'), 'Save button found.'); $this->drupalPost(NULL, $edit, t('Save')); break; case DRUPAL_DISABLED: - $this->assertNoFieldByName('op', t('Preview'), t('Preview button not found.')); - $this->assertFieldByName('op', t('Save'), t('Save button found.')); + $this->assertNoFieldByName('op', t('Preview'), 'Preview button not found.'); + $this->assertFieldByName('op', t('Save'), 'Save button found.'); $this->drupalPost(NULL, $edit, t('Save')); break; } @@ -79,7 +79,7 @@ class CommentHelperCase extends DrupalWebTestCase { $this->assertText($subject, 'Comment subject posted.'); } $this->assertText($comment, 'Comment body posted.'); - $this->assertTrue((!empty($match) && !empty($match[1])), t('Comment id found.')); + $this->assertTrue((!empty($match) && !empty($match[1])), 'Comment id found.'); } if (isset($match[1])) { @@ -103,7 +103,7 @@ class CommentHelperCase extends DrupalWebTestCase { $regex .= $comment->comment . '(.*?)'; // Match comment. $regex .= '/s'; - return (boolean)preg_match($regex, $this->drupalGetContent()); + return (boolean) preg_match($regex, $this->drupalGetContent()); } else { return FALSE; @@ -118,7 +118,7 @@ class CommentHelperCase extends DrupalWebTestCase { */ function deleteComment($comment) { $this->drupalPost('comment/' . $comment->id . '/delete', array(), t('Delete')); - $this->assertText(t('The comment and all its replies have been deleted.'), t('Comment deleted.')); + $this->assertText(t('The comment and all its replies have been deleted.'), 'Comment deleted.'); } /** @@ -196,7 +196,7 @@ class CommentHelperCase extends DrupalWebTestCase { */ function setCommentSettings($name, $value, $message) { variable_set($name . '_article', $value); - $this->assertTrue(TRUE, t($message)); // Display status message. + $this->assertTrue(TRUE, $message); // Display status message. } /** @@ -226,10 +226,10 @@ class CommentHelperCase extends DrupalWebTestCase { if ($operation == 'delete') { $this->drupalPost(NULL, array(), t('Delete comments')); - $this->assertRaw(t('Deleted @count comments.', array('@count' => 1)), t('Operation "' . $operation . '" was performed on comment.')); + $this->assertRaw(t('Deleted @count comments.', array('@count' => 1)), 'Operation "' . $operation . '" was performed on comment.'); } else { - $this->assertText(t('The update has been performed.'), t('Operation "' . $operation . '" was performed on comment.')); + $this->assertText(t('The update has been performed.'), 'Operation "' . $operation . '" was performed on comment.'); } } @@ -276,7 +276,7 @@ class CommentInterfaceTest extends CommentHelperCase { $comment_text = $this->randomName(); $comment = $this->postComment($this->node, $comment_text); $comment_loaded = comment_load($comment->id); - $this->assertTrue($this->commentExists($comment), t('Comment found.')); + $this->assertTrue($this->commentExists($comment), 'Comment found.'); // Set comments to have subject and preview to required. $this->drupalLogout(); @@ -291,12 +291,12 @@ class CommentInterfaceTest extends CommentHelperCase { $comment_text = $this->randomName(); $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); $comment_loaded = comment_load($comment->id); - $this->assertTrue($this->commentExists($comment), t('Comment found.')); + $this->assertTrue($this->commentExists($comment), 'Comment found.'); // Check comment display. $this->drupalGet('node/' . $this->node->nid . '/' . $comment->id); - $this->assertText($subject_text, t('Individual comment subject found.')); - $this->assertText($comment_text, t('Individual comment body found.')); + $this->assertText($subject_text, 'Individual comment subject found.'); + $this->assertText($comment_text, 'Individual comment body found.'); // Set comments to have subject and preview to optional. $this->drupalLogout(); @@ -309,60 +309,60 @@ class CommentInterfaceTest extends CommentHelperCase { // subject though field enabled. $this->drupalLogin($this->web_user); $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id); - $this->assertText($subject_text, t('Individual comment-reply subject found.')); - $this->assertText($comment_text, t('Individual comment-reply body found.')); + $this->assertText($subject_text, 'Individual comment-reply subject found.'); + $this->assertText($comment_text, 'Individual comment-reply body found.'); $reply = $this->postComment(NULL, $this->randomName(), '', TRUE); $reply_loaded = comment_load($reply->id); - $this->assertTrue($this->commentExists($reply, TRUE), t('Reply found.')); - $this->assertEqual($comment->id, $reply_loaded->pid, t('Pid of a reply to a comment is set correctly.')); - $this->assertEqual(rtrim($comment_loaded->thread, '/') . '.00/', $reply_loaded->thread, t('Thread of reply grows correctly.')); + $this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.'); + $this->assertEqual($comment->id, $reply_loaded->pid, 'Pid of a reply to a comment is set correctly.'); + $this->assertEqual(rtrim($comment_loaded->thread, '/') . '.00/', $reply_loaded->thread, 'Thread of reply grows correctly.'); // Second reply to comment #3 creating comment #4. $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id); - $this->assertText($subject_text, t('Individual comment-reply subject found.')); - $this->assertText($comment_text, t('Individual comment-reply body found.')); + $this->assertText($subject_text, 'Individual comment-reply subject found.'); + $this->assertText($comment_text, 'Individual comment-reply body found.'); $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); $reply_loaded = comment_load($reply->id); - $this->assertTrue($this->commentExists($reply, TRUE), t('Second reply found.')); - $this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, t('Thread of second reply grows correctly.')); + $this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.'); + $this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, 'Thread of second reply grows correctly.'); // Edit reply. $this->drupalGet('comment/' . $reply->id . '/edit'); $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); - $this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.')); + $this->assertTrue($this->commentExists($reply, TRUE), 'Modified reply found.'); // Correct link count $this->drupalGet('node'); - $this->assertRaw('4 comments', t('Link to the 4 comments exist.')); + $this->assertRaw('4 comments', 'Link to the 4 comments exist.'); // Confirm a new comment is posted to the correct page. $this->setCommentsPerPage(2); $comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE); - $this->assertTrue($this->commentExists($comment_new_page), t('Page one exists. %s')); + $this->assertTrue($this->commentExists($comment_new_page), 'Page one exists. %s'); $this->drupalGet('node/' . $this->node->nid, array('query' => array('page' => 1))); - $this->assertTrue($this->commentExists($reply, TRUE), t('Page two exists. %s')); + $this->assertTrue($this->commentExists($reply, TRUE), 'Page two exists. %s'); $this->setCommentsPerPage(50); // Attempt to post to node with comments disabled. $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_HIDDEN)); - $this->assertTrue($this->node, t('Article node created.')); + $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/' . $this->node->nid); - $this->assertText('This discussion is closed', t('Posting to node with comments disabled')); - $this->assertNoField('edit-comment', t('Comment body field found.')); + $this->assertText('This discussion is closed', 'Posting to node with comments disabled'); + $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with read-only comments. $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_CLOSED)); - $this->assertTrue($this->node, t('Article node created.')); + $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/' . $this->node->nid); - $this->assertText('This discussion is closed', t('Posting to node with comments read-only')); - $this->assertNoField('edit-comment', t('Comment body field found.')); + $this->assertText('This discussion is closed', 'Posting to node with comments read-only'); + $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with comments enabled (check field names etc). $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_OPEN)); - $this->assertTrue($this->node, t('Article node created.')); + $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/' . $this->node->nid); - $this->assertNoText('This discussion is closed', t('Posting to node with comments enabled')); - $this->assertField('edit-comment-body-' . $langcode . '-0-value', t('Comment body field found.')); + $this->assertNoText('This discussion is closed', 'Posting to node with comments enabled'); + $this->assertField('edit-comment-body-' . $langcode . '-0-value', 'Comment body field found.'); // Delete comment and make sure that reply is also removed. $this->drupalLogout(); @@ -371,8 +371,8 @@ class CommentInterfaceTest extends CommentHelperCase { $this->deleteComment($comment_new_page); $this->drupalGet('node/' . $this->node->nid); - $this->assertFalse($this->commentExists($comment), t('Comment not found.')); - $this->assertFalse($this->commentExists($reply, TRUE), t('Reply not found.')); + $this->assertFalse($this->commentExists($comment), 'Comment not found.'); + $this->assertFalse($this->commentExists($reply, TRUE), 'Reply not found.'); // Enabled comment form on node page. $this->drupalLogin($this->admin_user); @@ -383,7 +383,7 @@ class CommentInterfaceTest extends CommentHelperCase { $this->drupalLogin($this->web_user); $this->drupalGet('node/' . $this->node->nid); $form_comment = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); - $this->assertTrue($this->commentExists($form_comment), t('Form comment found.')); + $this->assertTrue($this->commentExists($form_comment), 'Form comment found.'); // Disable comment form on node page. $this->drupalLogout(); @@ -426,13 +426,13 @@ class CommentPreviewTest extends CommentHelperCase { $this->drupalPost('node/' . $this->node->nid, $edit, t('Preview')); // Check that the preview is displaying the title and body. - $this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".')); - $this->assertText($edit['subject'], t('Subject displayed.')); - $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.')); + $this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".'); + $this->assertText($edit['subject'], 'Subject displayed.'); + $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], 'Comment displayed.'); // Check that the title and body fields are displayed with the correct values. - $this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.')); - $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.')); + $this->assertFieldByName('subject', $edit['subject'], 'Subject field displayed.'); + $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], 'Comment field displayed.'); } /** @@ -457,17 +457,17 @@ class CommentPreviewTest extends CommentHelperCase { $this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview')); // Check that the preview is displaying the subject, comment, author and date correctly. - $this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".')); - $this->assertText($edit['subject'], t('Subject displayed.')); - $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.')); - $this->assertText($edit['name'], t('Author displayed.')); - $this->assertText($expected_date, t('Date displayed.')); + $this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".'); + $this->assertText($edit['subject'], 'Subject displayed.'); + $this->assertText($edit['comment_body[' . $langcode . '][0][value]'], 'Comment displayed.'); + $this->assertText($edit['name'], 'Author displayed.'); + $this->assertText($expected_date, 'Date displayed.'); // Check that the title and body fields are displayed with the correct values. - $this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.')); - $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.')); - $this->assertFieldByName('name', $edit['name'], t('Author field displayed.')); - $this->assertFieldByName('date', $edit['date'], t('Date field displayed.')); + $this->assertFieldByName('subject', $edit['subject'], 'Subject field displayed.'); + $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], 'Comment field displayed.'); + $this->assertFieldByName('name', $edit['name'], 'Author field displayed.'); + $this->assertFieldByName('date', $edit['date'], 'Date field displayed.'); } } @@ -502,7 +502,7 @@ class CommentAnonymous extends CommentHelperCase { // Post anonymous comment without contact info. $anonymous_comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName()); - $this->assertTrue($this->commentExists($anonymous_comment1), t('Anonymous comment without contact info found.')); + $this->assertTrue($this->commentExists($anonymous_comment1), 'Anonymous comment without contact info found.'); // Allow contact info. $this->drupalLogin($this->admin_user); @@ -511,15 +511,15 @@ class CommentAnonymous extends CommentHelperCase { // Attempt to edit anonymous comment. $this->drupalGet('comment/' . $anonymous_comment1->id . '/edit'); $edited_comment = $this->postComment(NULL, $this->randomName(), $this->randomName()); - $this->assertTrue($this->commentExists($edited_comment, FALSE), t('Modified reply found.')); + $this->assertTrue($this->commentExists($edited_comment, FALSE), 'Modified reply found.'); $this->drupalLogout(); // Post anonymous comment with contact info (optional). $this->drupalGet('comment/reply/' . $this->node->nid); - $this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.')); + $this->assertTrue($this->commentContactInfoAvailable(), 'Contact information available.'); $anonymous_comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName()); - $this->assertTrue($this->commentExists($anonymous_comment2), t('Anonymous comment with contact info (optional) found.')); + $this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.'); // Require contact info. $this->drupalLogin($this->admin_user); @@ -528,41 +528,41 @@ class CommentAnonymous extends CommentHelperCase { // Try to post comment with contact info (required). $this->drupalGet('comment/reply/' . $this->node->nid); - $this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.')); + $this->assertTrue($this->commentContactInfoAvailable(), 'Contact information available.'); $anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE); - $this->assertText(t('E-mail field is required.'), t('E-mail required.')); // Name should have 'Anonymous' for value by default. - $this->assertFalse($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) not found.')); + $this->assertText(t('E-mail field is required.'), 'E-mail required.'); // Name should have 'Anonymous' for value by default. + $this->assertFalse($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) not found.'); // Post comment with contact info (required). $author_name = $this->randomName(); $author_mail = $this->randomName() . '@example.com'; $anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), array('name' => $author_name, 'mail' => $author_mail)); - $this->assertTrue($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) found.')); + $this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.'); // Make sure the user data appears correctly when editing the comment. $this->drupalLogin($this->admin_user); $this->drupalGet('comment/' . $anonymous_comment3->id . '/edit'); - $this->assertRaw($author_name, t("The anonymous user's name is correct when editing the comment.")); - $this->assertRaw($author_mail, t("The anonymous user's e-mail address is correct when editing the comment.")); + $this->assertRaw($author_name, "The anonymous user's name is correct when editing the comment."); + $this->assertRaw($author_mail, "The anonymous user's e-mail address is correct when editing the comment."); // Unpublish comment. $this->performCommentOperation($anonymous_comment3, 'unpublish'); $this->drupalGet('admin/content/comment/approval'); - $this->assertRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was unpublished.')); + $this->assertRaw('comments[' . $anonymous_comment3->id . ']', 'Comment was unpublished.'); // Publish comment. $this->performCommentOperation($anonymous_comment3, 'publish', TRUE); $this->drupalGet('admin/content/comment'); - $this->assertRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was published.')); + $this->assertRaw('comments[' . $anonymous_comment3->id . ']', 'Comment was published.'); // Delete comment. $this->performCommentOperation($anonymous_comment3, 'delete'); $this->drupalGet('admin/content/comment'); - $this->assertNoRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was deleted.')); + $this->assertNoRaw('comments[' . $anonymous_comment3->id . ']', 'Comment was deleted.'); $this->drupalLogout(); // Reset. @@ -576,14 +576,14 @@ class CommentAnonymous extends CommentHelperCase { // NOTE: if authenticated user has permission to post comments, then a // "Login or register to post comments" type link may be shown. $this->drupalGet('node/' . $this->node->nid); - $this->assertNoPattern('/
]*?)id="comments"([^>]*?)>/', t('Comments were not displayed.')); - $this->assertNoLink('Add new comment', t('Link to add comment was found.')); + $this->assertNoPattern('/
]*?)id="comments"([^>]*?)>/', 'Comments were not displayed.'); + $this->assertNoLink('Add new comment', 'Link to add comment was found.'); // Attempt to view node-comment form while disallowed. $this->drupalGet('comment/reply/' . $this->node->nid); - $this->assertText('You are not authorized to view comments', t('Error attempting to post comment.')); - $this->assertNoFieldByName('subject', '', t('Subject field not found.')); - $this->assertNoFieldByName('comment[value]', '', t('Comment field not found.')); + $this->assertText('You are not authorized to view comments', 'Error attempting to post comment.'); + $this->assertNoFieldByName('subject', '', 'Subject field not found.'); + $this->assertNoFieldByName('comment[value]', '', 'Comment field not found.'); user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( 'access comments' => TRUE, @@ -591,9 +591,9 @@ class CommentAnonymous extends CommentHelperCase { 'post comments without approval' => FALSE, )); $this->drupalGet('node/' . $this->node->nid); - $this->assertPattern('/
]*?)id="comments"([^>]*?)>/', t('Comments were displayed.')); - $this->assertLink('Log in', 1, t('Link to log in was found.')); - $this->assertLink('register', 1, t('Link to register was found.')); + $this->assertPattern('/
]*?)id="comments"([^>]*?)>/', 'Comments were displayed.'); + $this->assertLink('Log in', 1, 'Link to log in was found.'); + $this->assertLink('register', 1, 'Link to register was found.'); } } @@ -637,22 +637,22 @@ class CommentPagerTest extends CommentHelperCase { // Check the first page of the node, and confirm the correct comments are // shown. $this->drupalGet('node/' . $node->nid); - $this->assertRaw(t('next'), t('Paging links found.')); - $this->assertTrue($this->commentExists($comments[0]), t('Comment 1 appears on page 1.')); - $this->assertFalse($this->commentExists($comments[1]), t('Comment 2 does not appear on page 1.')); - $this->assertFalse($this->commentExists($comments[2]), t('Comment 3 does not appear on page 1.')); + $this->assertRaw(t('next'), 'Paging links found.'); + $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page 1.'); + $this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 1.'); + $this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 1.'); // Check the second page. $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 1))); - $this->assertTrue($this->commentExists($comments[1]), t('Comment 2 appears on page 2.')); - $this->assertFalse($this->commentExists($comments[0]), t('Comment 1 does not appear on page 2.')); - $this->assertFalse($this->commentExists($comments[2]), t('Comment 3 does not appear on page 2.')); + $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page 2.'); + $this->assertFalse($this->commentExists($comments[0]), 'Comment 1 does not appear on page 2.'); + $this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 2.'); // Check the third page. $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 2))); - $this->assertTrue($this->commentExists($comments[2]), t('Comment 3 appears on page 3.')); - $this->assertFalse($this->commentExists($comments[0]), t('Comment 1 does not appear on page 3.')); - $this->assertFalse($this->commentExists($comments[1]), t('Comment 2 does not appear on page 3.')); + $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page 3.'); + $this->assertFalse($this->commentExists($comments[0]), 'Comment 1 does not appear on page 3.'); + $this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 3.'); // Post a reply to the oldest comment and test again. $replies = array(); @@ -664,21 +664,21 @@ class CommentPagerTest extends CommentHelperCase { // We are still in flat view - the replies should not be on the first page, // even though they are replies to the oldest comment. $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0))); - $this->assertFalse($this->commentExists($reply, TRUE), t('In flat mode, reply does not appear on page 1.')); + $this->assertFalse($this->commentExists($reply, TRUE), 'In flat mode, reply does not appear on page 1.'); // If we switch to threaded mode, the replies on the oldest comment // should be bumped to the first page and comment 6 should be bumped // to the second page. $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.')); $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0))); - $this->assertTrue($this->commentExists($reply, TRUE), t('In threaded mode, reply appears on page 1.')); - $this->assertFalse($this->commentExists($comments[1]), t('In threaded mode, comment 2 has been bumped off of page 1.')); + $this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.'); + $this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.'); // If (# replies > # comments per page) in threaded expanded view, // the overage should be bumped. $reply2 = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0))); - $this->assertFalse($this->commentExists($reply2, TRUE), t('In threaded mode where # replies > # comments per page, the newest reply does not appear on page 1.')); + $this->assertFalse($this->commentExists($reply2, TRUE), 'In threaded mode where # replies > # comments per page, the newest reply does not appear on page 1.'); $this->drupalLogout(); } @@ -780,7 +780,7 @@ class CommentPagerTest extends CommentHelperCase { $result_order[] = substr($anchor['id'], 8); } - return $this->assertIdentical($expected_cids, $result_order, t('Comment order: expected @expected, returned @returned.', array('@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)))); + return $this->assertIdentical($expected_cids, $result_order, 'Comment order: expected ' . implode(',', $expected_cids) . ', returned ' . implode(',', $result_order) . '.'); } /** @@ -840,7 +840,7 @@ class CommentPagerTest extends CommentHelperCase { foreach ($expected_pages as $new_replies => $expected_page) { $returned = comment_new_page_count($node->comment_count, $new_replies, $node); $returned_page = is_array($returned) ? $returned['page'] : 0; - $this->assertIdentical($expected_page, $returned_page, t('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page))); + $this->assertIdentical($expected_page, $returned_page, 'Flat mode, ' . $new_replies . ' replies: expected page ' . $expected_page . ', returned page ' . $returned_page . '.'); } $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.')); @@ -858,7 +858,7 @@ class CommentPagerTest extends CommentHelperCase { foreach ($expected_pages as $new_replies => $expected_page) { $returned = comment_new_page_count($node->comment_count, $new_replies, $node); $returned_page = is_array($returned) ? $returned['page'] : 0; - $this->assertEqual($expected_page, $returned_page, t('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page))); + $this->assertEqual($expected_page, $returned_page, 'Threaded mode, ' . $new_replies . ' replies: expected page ' . $expected_page . ', returned page ' . $returned_page . '.'); } } } @@ -895,7 +895,7 @@ class CommentApprovalTest extends CommentHelperCase { $subject = $this->randomName(); $body = $this->randomName(); $this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message. - $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.')); + $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.'); // Get unapproved comment id. $this->drupalLogin($this->admin_user); @@ -903,7 +903,7 @@ class CommentApprovalTest extends CommentHelperCase { $anonymous_comment4 = (object) array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body); $this->drupalLogout(); - $this->assertFalse($this->commentExists($anonymous_comment4), t('Anonymous comment was not published.')); + $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.'); // Approve comment. $this->drupalLogin($this->admin_user); @@ -911,7 +911,7 @@ class CommentApprovalTest extends CommentHelperCase { $this->drupalLogout(); $this->drupalGet('node/' . $this->node->nid); - $this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.')); + $this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.'); // Post 2 anonymous comments without contact info. $comments[] = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE); @@ -920,13 +920,13 @@ class CommentApprovalTest extends CommentHelperCase { // Publish multiple comments in one operation. $this->drupalLogin($this->admin_user); $this->drupalGet('admin/content/comment/approval'); - $this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), t('Two unapproved comments waiting for approval.')); + $this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), 'Two unapproved comments waiting for approval.'); $edit = array( "comments[{$comments[0]->id}]" => 1, "comments[{$comments[1]->id}]" => 1, ); $this->drupalPost(NULL, $edit, t('Update')); - $this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), t('All comments were approved.')); + $this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), 'All comments were approved.'); // Delete multiple comments in one operation. $edit = array( @@ -936,9 +936,9 @@ class CommentApprovalTest extends CommentHelperCase { "comments[{$anonymous_comment4->id}]" => 1, ); $this->drupalPost(NULL, $edit, t('Update')); - $this->assertText(t('Are you sure you want to delete these comments and all their children?'), t('Confirmation required.')); + $this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.'); $this->drupalPost(NULL, $edit, t('Delete comments')); - $this->assertText(t('No comments available.'), t('All comments were deleted.')); + $this->assertText(t('No comments available.'), 'All comments were deleted.'); } /** @@ -959,7 +959,7 @@ class CommentApprovalTest extends CommentHelperCase { $subject = $this->randomName(); $body = $this->randomName(); $this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message. - $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.')); + $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.'); // Get unapproved comment id. $this->drupalLogin($this->admin_user); @@ -967,20 +967,20 @@ class CommentApprovalTest extends CommentHelperCase { $anonymous_comment4 = (object) array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body); $this->drupalLogout(); - $this->assertFalse($this->commentExists($anonymous_comment4), t('Anonymous comment was not published.')); + $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.'); // Approve comment. $this->drupalLogin($this->admin_user); $this->drupalGet('comment/1/approve'); - $this->assertResponse(403, t('Forged comment approval was denied.')); + $this->assertResponse(403, 'Forged comment approval was denied.'); $this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged'))); - $this->assertResponse(403, t('Forged comment approval was denied.')); + $this->assertResponse(403, 'Forged comment approval was denied.'); $this->drupalGet('node/' . $this->node->nid); $this->clickLink(t('approve')); $this->drupalLogout(); $this->drupalGet('node/' . $this->node->nid); - $this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.')); + $this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.'); } } @@ -1007,7 +1007,7 @@ class CommentBlockFunctionalTest extends CommentHelperCase { 'comment_recent[region]' => 'sidebar_first', ); $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), t('Block saved to first sidebar region.')); + $this->assertText(t('The block settings have been updated.'), 'Block saved to first sidebar region.'); // Set block title and variables. $block = array( @@ -1015,7 +1015,7 @@ class CommentBlockFunctionalTest extends CommentHelperCase { 'comment_block_count' => 2, ); $this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block')); - $this->assertText(t('The block configuration has been saved.'), t('Block saved.')); + $this->assertText(t('The block configuration has been saved.'), 'Block saved.'); // Add some test comments, one without a subject. $comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName()); @@ -1027,20 +1027,20 @@ class CommentBlockFunctionalTest extends CommentHelperCase { $this->drupalLogout(); user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access comments')); $this->drupalGet(''); - $this->assertNoText($block['title'], t('Block was not found.')); + $this->assertNoText($block['title'], 'Block was not found.'); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments')); // Test that a user with the 'access comments' permission can see the // block. $this->drupalLogin($this->web_user); $this->drupalGet(''); - $this->assertText($block['title'], t('Block was found.')); + $this->assertText($block['title'], 'Block was found.'); // Test the only the 2 latest comments are shown and in the proper order. - $this->assertNoText($comment1->subject, t('Comment not found in block.')); - $this->assertText($comment2->subject, t('Comment found in block.')); - $this->assertText($comment3->comment, t('Comment found in block.')); - $this->assertTrue(strpos($this->drupalGetContent(), $comment3->comment) < strpos($this->drupalGetContent(), $comment2->subject), t('Comments were ordered correctly in block.')); + $this->assertNoText($comment1->subject, 'Comment not found in block.'); + $this->assertText($comment2->subject, 'Comment found in block.'); + $this->assertText($comment3->comment, 'Comment found in block.'); + $this->assertTrue(strpos($this->drupalGetContent(), $comment3->comment) < strpos($this->drupalGetContent(), $comment2->subject), 'Comments were ordered correctly in block.'); // Set the number of recent comments to show to 10. $this->drupalLogout(); @@ -1049,30 +1049,30 @@ class CommentBlockFunctionalTest extends CommentHelperCase { 'comment_block_count' => 10, ); $this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block')); - $this->assertText(t('The block configuration has been saved.'), t('Block saved.')); + $this->assertText(t('The block configuration has been saved.'), 'Block saved.'); // Post an additional comment. $comment4 = $this->postComment($this->node, $this->randomName(), $this->randomName()); // Test that all four comments are shown. - $this->assertText($comment1->subject, t('Comment found in block.')); - $this->assertText($comment2->subject, t('Comment found in block.')); - $this->assertText($comment3->comment, t('Comment found in block.')); - $this->assertText($comment4->subject, t('Comment found in block.')); + $this->assertText($comment1->subject, 'Comment found in block.'); + $this->assertText($comment2->subject, 'Comment found in block.'); + $this->assertText($comment3->comment, 'Comment found in block.'); + $this->assertText($comment4->subject, 'Comment found in block.'); // Test that links to comments work when comments are across pages. $this->setCommentsPerPage(1); $this->drupalGet(''); $this->clickLink($comment1->subject); - $this->assertText($comment1->subject, t('Comment link goes to correct page.')); + $this->assertText($comment1->subject, 'Comment link goes to correct page.'); $this->drupalGet(''); $this->clickLink($comment2->subject); - $this->assertText($comment2->subject, t('Comment link goes to correct page.')); + $this->assertText($comment2->subject, 'Comment link goes to correct page.'); $this->clickLink($comment4->subject); - $this->assertText($comment4->subject, t('Comment link goes to correct page.')); + $this->assertText($comment4->subject, 'Comment link goes to correct page.'); // Check that when viewing a comment page from a link to the comment, that // rel="canonical" is added to the head of the document. - $this->assertRaw('assertRaw('postComment($this->node, $this->randomName(), $this->randomName()); $this->drupalGet('rss.xml'); $raw = '' . url('node/' . $this->node->nid, array('fragment' => 'comments', 'absolute' => TRUE)) . ''; - $this->assertRaw($raw, t('Comments as part of RSS feed.')); + $this->assertRaw($raw, 'Comments as part of RSS feed.'); // Hide comments from RSS feed and check presence. $this->node->comment = COMMENT_NODE_HIDDEN; node_save($this->node); $this->drupalGet('rss.xml'); - $this->assertNoRaw($raw, t('Hidden comments is not a part of RSS feed.')); + $this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.'); } } @@ -1137,14 +1137,14 @@ class CommentContentRebuild extends CommentHelperCase { $comment_text = $this->randomName(); $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); $comment_loaded = comment_load($comment->id); - $this->assertTrue($this->commentExists($comment), t('Comment found.')); + $this->assertTrue($this->commentExists($comment), 'Comment found.'); // Add the property to the content array and then see if it still exists on build. $comment_loaded->content['test_property'] = array('#value' => $this->randomString()); $built_content = comment_view($comment_loaded, $this->node); // This means that the content was rebuilt as the added test property no longer exists. - $this->assertFalse(isset($built_content['test_property']), t('Comment content was emptied before being built.')); + $this->assertFalse(isset($built_content['test_property']), 'Comment content was emptied before being built.'); } } @@ -1210,11 +1210,11 @@ class CommentTokenReplaceTestCase extends CommentHelperCase { $tests['[comment:author:name]'] = check_plain($this->admin_user->name); // Test to make sure that we generated something for each token. - $this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.')); + $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { $output = token_replace($input, array('comment' => $comment), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized comment token %token replaced.', array('%token' => $input))); + $this->assertFalse(strcmp($output, $expected), 'Sanitized comment token ' . $input . ' replaced.'); } // Generate and test unsanitized tokens. @@ -1230,7 +1230,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('comment' => $comment), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized comment token %token replaced.', array('%token' => $input))); + $this->assertFalse(strcmp($output, $expected), 'Unsanitized comment token ' . $input . ' replaced.'); } // Load node so comment_count gets computed. @@ -1243,7 +1243,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Node comment token %token replaced.', array('%token' => $input))); + $this->assertFalse(strcmp($output, $expected), 'Node comment token ' . $input . ' replaced.'); } } } diff --git a/modules/contact/contact.test b/modules/contact/contact.test index 80a157b87d355d1ede5ee39b053069293aa491ff..04020947de8c77f6f3ebcdd07d4dd8ab57589dcc 100644 --- a/modules/contact/contact.test +++ b/modules/contact/contact.test @@ -33,7 +33,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase { $edit = array(); $edit['contact_default_status'] = TRUE; $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); + $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.'); // Delete old categories to ensure that new categories are used. $this->deleteCategories(); @@ -53,21 +53,21 @@ class ContactSitewideTestCase extends DrupalWebTestCase { $invalid_recipients = array('invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'); foreach ($invalid_recipients as $invalid_recipient) { $this->addCategory($this->randomName(16), $invalid_recipient, '', FALSE); - $this->assertRaw(t('%recipient is an invalid e-mail address.', array('%recipient' => $invalid_recipient)), t('Caught invalid recipient (' . $invalid_recipient . ').')); + $this->assertRaw(t('%recipient is an invalid e-mail address.', array('%recipient' => $invalid_recipient)), 'Caught invalid recipient (' . $invalid_recipient . ').'); } // Test validation of empty category and recipients fields. $this->addCategory($category = '', '', '', TRUE); - $this->assertText(t('Category field is required.'), t('Caught empty category field')); - $this->assertText(t('Recipients field is required.'), t('Caught empty recipients field.')); + $this->assertText(t('Category field is required.'), 'Caught empty category field'); + $this->assertText(t('Recipients field is required.'), 'Caught empty recipients field.'); // Create first valid category. $recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com'); $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); // Make sure the newly created category is included in the list of categories. - $this->assertNoUniqueText($category, t('New category included in categories list.')); + $this->assertNoUniqueText($category, 'New category included in categories list.'); // Test update contact form category. $categories = $this->getCategories(); @@ -77,80 +77,80 @@ class ContactSitewideTestCase extends DrupalWebTestCase { $this->assertEqual($category_array['recipients'], $recipients_str); $this->assertEqual($category_array['reply'], $reply); $this->assertFalse($category_array['selected']); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); // Ensure that the contact form is shown without a category selection input. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalLogout(); $this->drupalGet('contact'); - $this->assertText(t('Your e-mail address'), t('Contact form is shown when there is one category.')); - $this->assertNoText(t('Category'), t('When there is only one category, the category selection element is hidden.')); + $this->assertText(t('Your e-mail address'), 'Contact form is shown when there is one category.'); + $this->assertNoText(t('Category'), 'When there is only one category, the category selection element is hidden.'); $this->drupalLogin($admin_user); // Add more categories. $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); // Try adding a category that already exists. $this->addCategory($category, '', '', FALSE); - $this->assertNoRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category not saved.')); - $this->assertRaw(t('A contact form with category %category already exists.', array('%category' => $category)), t('Duplicate category error found.')); + $this->assertNoRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category not saved.'); + $this->assertRaw(t('A contact form with category %category already exists.', array('%category' => $category)), 'Duplicate category error found.'); // Clear flood table in preparation for flood test and allow other checks to complete. db_delete('flood')->execute(); $num_records_after = db_query("SELECT COUNT(*) FROM {flood}")->fetchField(); - $this->assertIdentical($num_records_after, '0', t('Flood table emptied.')); + $this->assertIdentical($num_records_after, '0', 'Flood table emptied.'); $this->drupalLogout(); // Check to see that anonymous user cannot see contact page without permission. user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalGet('contact'); - $this->assertResponse(403, t('Access denied to anonymous user without permission.')); + $this->assertResponse(403, 'Access denied to anonymous user without permission.'); // Give anonymous user permission and see that page is viewable. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalGet('contact'); - $this->assertResponse(200, t('Access granted to anonymous user with permission.')); + $this->assertResponse(200, 'Access granted to anonymous user with permission.'); // Submit contact form with invalid values. $this->submitContact('', $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('Your name field is required.'), t('Name required.')); + $this->assertText(t('Your name field is required.'), 'Name required.'); $this->submitContact($this->randomName(16), '', $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('Your e-mail address field is required.'), t('E-mail required.')); + $this->assertText(t('Your e-mail address field is required.'), 'E-mail required.'); $this->submitContact($this->randomName(16), $invalid_recipients[0], $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('You must enter a valid e-mail address.'), t('Valid e-mail required.')); + $this->assertText(t('You must enter a valid e-mail address.'), 'Valid e-mail required.'); $this->submitContact($this->randomName(16), $recipients[0], '', $categories[0], $this->randomName(64)); - $this->assertText(t('Subject field is required.'), t('Subject required.')); + $this->assertText(t('Subject field is required.'), 'Subject required.'); $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), $categories[0], ''); - $this->assertText(t('Message field is required.'), t('Message required.')); + $this->assertText(t('Message field is required.'), 'Message required.'); // Test contact form with no default category selected. db_update('contact') ->fields(array('selected' => 0)) ->execute(); $this->drupalGet('contact'); - $this->assertRaw(t('- Please choose -'), t('Without selected categories the visitor is asked to chose a category.')); + $this->assertRaw(t('- Please choose -'), 'Without selected categories the visitor is asked to chose a category.'); // Submit contact form with invalid category id (cid 0). $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), 0, ''); - $this->assertText(t('You must select a valid category.'), t('Valid category required.')); + $this->assertText(t('You must select a valid category.'), 'Valid category required.'); // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_limit; $i++) { $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('Your message has been sent.'), t('Message sent.')); + $this->assertText(t('Your message has been sent.'), 'Message sent.'); } // Submit contact form one over limit. $this->drupalGet('contact'); - $this->assertResponse(403, t('Access denied to anonymous user after reaching message treshold.')); - $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => variable_get('contact_threshold_limit', 3), '@interval' => format_interval(600))), t('Message threshold reached.')); + $this->assertResponse(403, 'Access denied to anonymous user after reaching message treshold.'); + $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => variable_get('contact_threshold_limit', 3), '@interval' => format_interval(600))), 'Message threshold reached.'); // Delete created categories. $this->drupalLogin($admin_user); @@ -158,8 +158,8 @@ class ContactSitewideTestCase extends DrupalWebTestCase { } /** - * Test auto-reply on the site-wide contact form. - */ + * Test auto-reply on the site-wide contact form. + */ function testAutoReply() { // Create and login administrative user. $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users')); @@ -179,8 +179,8 @@ class ContactSitewideTestCase extends DrupalWebTestCase { // We are testing the auto-reply, so there should be one e-mail going to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'foo@example.com')); - $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "foo".'), t('Contact')); - $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($foo_autoreply), t('Auto-reply e-mail body is correct for category "foo".'), t('Contact')); + $this->assertEqual(count($captured_emails), 1, 'Auto-reply e-mail was sent to the sender for category "foo".', 'Contact'); + $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($foo_autoreply), 'Auto-reply e-mail body is correct for category "foo".', 'Contact'); // Test the auto-reply for category 'bar'. $email = $this->randomName(32) . '@example.com'; @@ -188,14 +188,14 @@ class ContactSitewideTestCase extends DrupalWebTestCase { // Auto-reply for category 'bar' should result in one auto-reply e-mail to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'bar@example.com')); - $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "bar".'), t('Contact')); - $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($bar_autoreply), t('Auto-reply e-mail body is correct for category "bar".'), t('Contact')); + $this->assertEqual(count($captured_emails), 1, 'Auto-reply e-mail was sent to the sender for category "bar".', 'Contact'); + $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($bar_autoreply), 'Auto-reply e-mail body is correct for category "bar".', 'Contact'); // Verify that no auto-reply is sent when the auto-reply field is left blank. $email = $this->randomName(32) . '@example.com'; $this->submitContact($this->randomName(16), $email, $this->randomString(64), 4, $this->randomString(128)); $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'no_autoreply@example.com')); - $this->assertEqual(count($captured_emails), 0, t('No auto-reply e-mail was sent to the sender for category "no-autoreply".'), t('Contact')); + $this->assertEqual(count($captured_emails), 0, 'No auto-reply e-mail was sent to the sender for category "no-autoreply".', 'Contact'); } /** @@ -261,7 +261,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase { foreach ($categories as $category) { $category_name = db_query("SELECT category FROM {contact} WHERE cid = :cid", array(':cid' => $category))->fetchField(); $this->drupalPost('admin/structure/contact/delete/' . $category, array(), t('Delete')); - $this->assertRaw(t('Category %category has been deleted.', array('%category' => $category_name)), t('Category deleted sucessfully.')); + $this->assertRaw(t('Category %category has been deleted.', array('%category' => $category_name)), 'Category deleted sucessfully.'); } } @@ -336,7 +336,7 @@ class ContactPersonalTestCase extends DrupalWebTestCase { $this->drupalLogin($this->admin_user); $edit = array('contact_default_status' => FALSE); $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); + $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.'); $this->drupalLogout(); // Re-create our contacted user with personal contact forms disabled by @@ -388,7 +388,7 @@ class ContactPersonalTestCase extends DrupalWebTestCase { } // Submit contact form one over limit. - $this->drupalGet('user/' . $this->contact_user->uid. '/contact'); + $this->drupalGet('user/' . $this->contact_user->uid . '/contact'); $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => format_interval(variable_get('contact_threshold_window', 3600)))), 'Normal user denied access to flooded contact form.'); // Test that the admin user can still access the contact form even though diff --git a/modules/dashboard/dashboard.test b/modules/dashboard/dashboard.test index 6d9a21e4f2f7dced79664f3f41be21b101c67740..3b69614859e8fbce1a23b06a8b75567203ce2417 100644 --- a/modules/dashboard/dashboard.test +++ b/modules/dashboard/dashboard.test @@ -47,14 +47,14 @@ class DashboardAccessTestCase extends DrupalWebTestCase { // Ensure admin access. $this->drupalGet('admin'); - $this->assertResponse(200, t('Admin has access to the dashboard.')); - $this->assertRaw($custom_block['title'], t('Admin has access to a dashboard block.')); + $this->assertResponse(200, 'Admin has access to the dashboard.'); + $this->assertRaw($custom_block['title'], 'Admin has access to a dashboard block.'); // Ensure non-admin access is denied. $normal_user = $this->drupalCreateUser(); $this->drupalLogin($normal_user); $this->drupalGet('admin'); - $this->assertResponse(403, t('Non-admin has no access to the dashboard.')); - $this->assertNoText($custom_block['title'], t('Non-admin has no access to a dashboard block.')); + $this->assertResponse(403, 'Non-admin has no access to the dashboard.'); + $this->assertNoText($custom_block['title'], 'Non-admin has no access to a dashboard block.'); } } diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test index 92f0dd4d3e4a69aea9130bd64773b7f449186fbd..c26c6324e711fd2bd994e6361ef83fa5a82b4e67 100644 --- a/modules/dblog/dblog.test +++ b/modules/dblog/dblog.test @@ -55,10 +55,10 @@ class DBLogTestCase extends DrupalWebTestCase { // Check row limit variable. $current_limit = variable_get('dblog_row_limit', 1000); - $this->assertTrue($current_limit == $row_limit, t('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); + $this->assertTrue($current_limit == $row_limit, '[Cache] Row limit variable of ' . $current_limit . ' equals row limit of ' . $row_limit); // Verify dblog row limit equals specified row limit. $current_limit = unserialize(db_query("SELECT value FROM {variable} WHERE name = :dblog_limit", array(':dblog_limit' => 'dblog_row_limit'))->fetchField()); - $this->assertTrue($current_limit == $row_limit, t('[Variable table] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); + $this->assertTrue($current_limit == $row_limit, '[Variable table] Row limit variable of ' . $current_limit . ' equals row limit of ' . $row_limit); } /** @@ -71,13 +71,13 @@ class DBLogTestCase extends DrupalWebTestCase { $this->generateLogEntries($row_limit + 10); // Verify dblog row count exceeds row limit. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); - $this->assertTrue($count > $row_limit, t('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); + $this->assertTrue($count > $row_limit, 'Dblog row count of ' . $count . ' exceeds row limit of ' . $row_limit); // Run cron job. $this->cronRun(); // Verify dblog row count equals row limit plus one because cron adds a record after it runs. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); - $this->assertTrue($count == $row_limit + 1, t('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); + $this->assertTrue($count == $row_limit + 1, 'Dblog row count of ' . $count . ' equals row limit of ' . $row_limit . ' plus one'); } /** @@ -125,35 +125,35 @@ class DBLogTestCase extends DrupalWebTestCase { $this->drupalGet('admin/help/dblog'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Database logging'), t('DBLog help was displayed')); + $this->assertText(t('Database logging'), 'DBLog help was displayed'); } // View dblog report node. $this->drupalGet('admin/reports/dblog'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Recent log entries'), t('DBLog report was displayed')); + $this->assertText(t('Recent log entries'), 'DBLog report was displayed'); } // View dblog page-not-found report node. $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Top ' . $quote . 'page not found' . $quote . ' errors'), t('DBLog page-not-found report was displayed')); + $this->assertText(t('Top ' . $quote . 'page not found' . $quote . ' errors'), 'DBLog page-not-found report was displayed'); } // View dblog access-denied report node. $this->drupalGet('admin/reports/access-denied'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Top ' . $quote . 'access denied' . $quote . ' errors'), t('DBLog access-denied report was displayed')); + $this->assertText(t('Top ' . $quote . 'access denied' . $quote . ' errors'), 'DBLog access-denied report was displayed'); } // View dblog event node. $this->drupalGet('admin/reports/event/1'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Details'), t('DBLog event node was displayed')); + $this->assertText(t('Details'), 'DBLog event node was displayed'); } } @@ -192,7 +192,7 @@ class DBLogTestCase extends DrupalWebTestCase { $this->assertResponse(200); // Retrieve user object. $user = user_load_by_name($name); - $this->assertTrue($user != NULL, t('User @name was loaded', array('@name' => $name))); + $this->assertTrue($user != NULL, 'User ' . $name . ' was loaded'); $user->pass_raw = $pass; // Needed by drupalLogin. // Login user. $this->drupalLogin($user); @@ -204,7 +204,7 @@ class DBLogTestCase extends DrupalWebTestCase { $ids[] = $row->wid; } $count_before = (isset($ids)) ? count($ids) : 0; - $this->assertTrue($count_before > 0, t('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->name))); + $this->assertTrue($count_before > 0, 'DBLog contains ' . $count_before . ' records for ' . $user->name); // Login the admin user. $this->drupalLogin($this->big_user); @@ -238,12 +238,12 @@ class DBLogTestCase extends DrupalWebTestCase { $link = drupal_substr($value, strpos($value, 'admin/reports/event/')); $this->drupalGet($link); // Check for full message text on the details page. - $this->assertRaw($message, t('DBLog event details was found: [delete user]')); + $this->assertRaw($message, 'DBLog event details was found: [delete user]'); break; } } } - $this->assertTrue($link, t('DBLog event was recorded: [delete user]')); + $this->assertTrue($link, 'DBLog event was recorded: [delete user]'); // Visit random URL (to generate page not found event). $not_found_url = $this->randomName(60); $this->drupalGet($not_found_url); @@ -252,7 +252,7 @@ class DBLogTestCase extends DrupalWebTestCase { $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse(200); // Check that full-length url displayed. - $this->assertText($not_found_url, t('DBLog event was recorded: [page not found]')); + $this->assertText($not_found_url, 'DBLog event was recorded: [page not found]'); } /** @@ -275,7 +275,7 @@ class DBLogTestCase extends DrupalWebTestCase { $this->assertResponse(200); // Retrieve node object. $node = $this->drupalGetNodeByTitle($title); - $this->assertTrue($node != NULL, t('Node @title was loaded', array('@title' => $title))); + $this->assertTrue($node != NULL, 'Node ' . $title . ' was loaded'); // Edit node. $edit = $this->getContentUpdate($type); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); @@ -308,13 +308,13 @@ class DBLogTestCase extends DrupalWebTestCase { $this->drupalGet('admin/reports/access-denied'); $this->assertResponse(200); // Access denied. - $this->assertText(t('admin/reports/dblog'), t('DBLog event was recorded: [access denied]')); + $this->assertText(t('admin/reports/dblog'), 'DBLog event was recorded: [access denied]'); // View dblog page-not-found report node. $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse(200); // Page not found. - $this->assertText(t('node/@nid', array('@nid' => $node->nid)), t('DBLog event was recorded: [page not found]')); + $this->assertText(t('node/@nid', array('@nid' => $node->nid)), 'DBLog event was recorded: [page not found]'); } /** @@ -332,14 +332,14 @@ class DBLogTestCase extends DrupalWebTestCase { 'choice[new:0][chtext]' => $this->randomName(32), 'choice[new:1][chtext]' => $this->randomName(32), ); - break; + break; default: $content = array( "title" => $this->randomName(8), "body[$langcode][0][value]" => $this->randomName(32), ); - break; + break; } return $content; } @@ -357,14 +357,14 @@ class DBLogTestCase extends DrupalWebTestCase { 'choice[chid:1][chtext]' => $this->randomName(32), 'choice[chid:2][chtext]' => $this->randomName(32), ); - break; + break; default: $langcode = LANGUAGE_NONE; $content = array( "body[$langcode][0][value]" => $this->randomName(32), ); - break; + break; } return $content; } @@ -391,14 +391,14 @@ class DBLogTestCase extends DrupalWebTestCase { // Add a watchdog entry. dblog_watchdog($log); // Make sure the table count has actually incremented. - $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), t('dblog_watchdog() added an entry to the dblog :count', array(':count' => $count))); + $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), 'dblog_watchdog() added an entry to the dblog ' . $count); // Login the admin user. $this->drupalLogin($this->big_user); // Now post to clear the db table. $this->drupalPost('admin/reports/dblog', array(), t('Clear log messages')); // Count rows in watchdog that previously related to the deleted user. $count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(); - $this->assertEqual($count, 0, t('DBLog contains :count records after a clear.', array(':count' => $count))); + $this->assertEqual($count, 0, 'DBLog contains ' . $count . ' records after a clear.'); } /** diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.test b/modules/field/modules/field_sql_storage/field_sql_storage.test index 6af10a0b7ef7e0015ad9441114360da02e422621..ac3568403bdb20432955b9cfcb64add76c50d208 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.test +++ b/modules/field/modules/field_sql_storage/field_sql_storage.test @@ -41,7 +41,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $t1 = _field_sql_storage_etid('t1'); $t2 = _field_sql_storage_etid('t2'); - $this->assertEqual($t1+1, $t2, 'Entity type ids are sequential'); + $this->assertEqual($t1 + 1, $t2, 'Entity type ids are sequential'); $this->assertIdentical(variable_get('field_sql_storage_t1_etid', NULL), $t1, 'First entity type variable is correct'); $this->assertIdentical(variable_get('field_sql_storage_t2_etid', NULL), $t2, 'Second entity type variable is correct'); $this->assertEqual(db_query("SELECT etid FROM {field_config_entity_type} WHERE type='t1'")->fetchField(), $t1, 'First entity type in database is correct'); @@ -141,7 +141,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is inserted correctly")); + $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], "Value $delta is inserted correctly"); } else { $this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets inserted."); @@ -160,7 +160,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is updated correctly")); + $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], "Value $delta is updated correctly"); } else { $this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets updated."); @@ -190,7 +190,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Update with no field_name entry leaves value $delta untouched")); + $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], "Update with no field_name entry leaves value $delta untouched"); } } @@ -198,7 +198,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $entity->{$this->field_name} = NULL; field_attach_update($entity_type, $entity); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); - $this->assertEqual(count($rows), 0, t("Update with an empty field_name entry empties the field.")); + $this->assertEqual(count($rows), 0, "Update with an empty field_name entry empties the field."); } /** @@ -313,10 +313,10 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $field['settings']['scale'] = 3; try { field_update_field($field); - $this->fail(t('Cannot update field schema with data.')); + $this->fail('Cannot update field schema with data.'); } catch (FieldException $e) { - $this->pass(t('Cannot update field schema with data.')); + $this->pass('Cannot update field schema with data.'); } } @@ -335,8 +335,8 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { // Verify the indexes we will create do not exist yet. foreach ($tables as $table) { - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in $table")); - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in $table")); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), "No index named value exists in $table"); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), "No index named value_format exists in $table"); } // Add data so the table cannot be dropped. @@ -348,21 +348,21 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $field = array('field_name' => $field_name, 'indexes' => array('value' => array('value'))); field_update_field($field); foreach ($tables as $table) { - $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table")); + $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), "Index on value created in $table"); } // Add a different index, removing the existing custom one. $field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format'))); field_update_field($field); foreach ($tables as $table) { - $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table")); - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table")); + $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), "Index on value_format created in $table"); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), "Index on value removed in $table"); } // Verify that the tables were not dropped. $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); field_attach_load('test_entity', array(0 => $entity)); - $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', t("Index changes performed without dropping the tables")); + $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', "Index changes performed without dropping the tables"); } /** @@ -377,19 +377,19 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']); // The storage details are indexed by a storage engine type. - $this->assertTrue(array_key_exists('sql', $field['storage']['details']), t('The storage type is SQL.')); + $this->assertTrue(array_key_exists('sql', $field['storage']['details']), 'The storage type is SQL.'); // The SQL details are indexed by table name. $details = $field['storage']['details']['sql']; - $this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), t('Table name is available in the instance array.')); - $this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), t('Revision table name is available in the instance array.')); + $this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), 'Table name is available in the instance array.'); + $this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), 'Revision table name is available in the instance array.'); // Test current and revision storage details together because the columns // are the same. foreach ((array) $this->field['columns'] as $column_name => $attributes) { $storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name); - $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current))); - $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision))); + $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, 'Column name ' . $column_name . ' matches the definition in ' . $current . '.'); + $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, 'Column name ' . $column_name . ' matches the definition in ' . $revision . '.'); } } } diff --git a/modules/field/modules/list/tests/list.test b/modules/field/modules/list/tests/list.test index 13d20059e2827d1d878217311fd30b950e3e3514..2491e93d44a366d0b899403d2fde1611b0236161 100644 --- a/modules/field/modules/list/tests/list.test +++ b/modules/field/modules/list/tests/list.test @@ -52,28 +52,28 @@ class ListFieldTestCase extends FieldTestCase { // All three options appear. $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); + $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists'); // Removed options do not appear. $this->field['settings']['allowed_values'] = "2|Two"; field_update_field($this->field); $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); + $this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists'); + $this->assertTrue(empty($form[$this->field_name][$langcode][3]), 'Option 3 does not exist'); // Completely new options appear. $this->field['settings']['allowed_values'] = "10|Update\n20|Twenty"; field_update_field($this->field); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); - $this->assertTrue(empty($form[$this->field_name][$langcode][2]), t('Option 2 does not exist')); - $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][10]), t('Option 10 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][20]), t('Option 20 exists')); + $this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist'); + $this->assertTrue(empty($form[$this->field_name][$langcode][2]), 'Option 2 does not exist'); + $this->assertTrue(empty($form[$this->field_name][$langcode][3]), 'Option 3 does not exist'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][10]), 'Option 10 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][20]), 'Option 20 exists'); // Options are reset when a new field with the same name is created. field_delete_field($this->field_name); @@ -91,15 +91,15 @@ class ListFieldTestCase extends FieldTestCase { $this->instance = field_create_instance($this->instance); $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); + $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists'); } } /** -* List module UI tests. -*/ + * List module UI tests. + */ class ListFieldUITestCase extends FieldTestCase { public static function getInfo() { return array( @@ -139,21 +139,21 @@ class ListFieldUITestCase extends FieldTestCase { //Check that non-integer keys are rejected. $edit = array($element_name => "1.1|one\n"); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("keys must be integers", t('Form validation failed.')); + $this->assertText("keys must be integers", 'Form validation failed.'); // Test 'List (number)' field type. $admin_path = $this->createListFieldAndEdit('list_number'); //Check that non-numeric keys are rejected. $edit = array($element_name => "1|one\nB|two"); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("each key must be a valid integer or decimal", t('Form validation failed.')); + $this->assertText("each key must be a valid integer or decimal", 'Form validation failed.'); //Test 'List (text)' field type. $admin_path = $this->createListFieldAndEdit('list_text'); //Check that over long keys are rejected. $edit = array($element_name => "1|one\n" . $this->randomName(256) . "|two"); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("each key must be a string at most 255 characters long", t('Form validation failed.')); + $this->assertText("each key must be a string at most 255 characters long", 'Form validation failed.'); } /** diff --git a/modules/field/modules/options/options.test b/modules/field/modules/options/options.test index 8cbfd5bc7c2581a6697abb7c32bb10c07b8aa510..a593d023b11e26be0164ed1278991d20d005dd17 100644 --- a/modules/field/modules/options/options.test +++ b/modules/field/modules/options/options.test @@ -77,11 +77,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_test_entity_save($entity); // With no field data, no buttons are checked. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoFieldChecked("edit-card-1-$langcode-0"); $this->assertNoFieldChecked("edit-card-1-$langcode-1"); $this->assertNoFieldChecked("edit-card-1-$langcode-2"); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Select first option. $edit = array("card_1[$langcode]" => 0); @@ -89,7 +89,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0)); // Check that the selected button is checked. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertFieldChecked("edit-card-1-$langcode-0"); $this->assertNoFieldChecked("edit-card-1-$langcode-1"); $this->assertNoFieldChecked("edit-card-1-$langcode-2"); @@ -104,7 +104,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_update_field($this->card_1); $instance['required'] = TRUE; field_update_instance($instance); - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertFieldChecked("edit-card-1-$langcode-99"); } @@ -134,11 +134,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_test_entity_save($entity); // Display form: with no field data, nothing is checked. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoFieldChecked("edit-card-2-$langcode-0"); $this->assertNoFieldChecked("edit-card-2-$langcode-1"); $this->assertNoFieldChecked("edit-card-2-$langcode-2"); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select first and third options. $edit = array( @@ -150,7 +150,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0, 2)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertFieldChecked("edit-card-2-$langcode-0"); $this->assertNoFieldChecked("edit-card-2-$langcode-1"); $this->assertFieldChecked("edit-card-2-$langcode-2"); @@ -165,7 +165,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertFieldChecked("edit-card-2-$langcode-0"); $this->assertNoFieldChecked("edit-card-2-$langcode-1"); $this->assertNoFieldChecked("edit-card-2-$langcode-2"); @@ -177,7 +177,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { "card_2[$langcode][2]" => TRUE, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); + $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.'); // Submit form: uncheck all options. $edit = array( @@ -194,7 +194,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_update_field($this->card_2); $instance['required'] = TRUE; field_update_instance($instance); - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertFieldChecked("edit-card-2-$langcode-99"); } @@ -221,11 +221,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_test_entity_save($entity); // Display form: with no field data, nothing is selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select first option. $edit = array("card_1[$langcode]" => 0); @@ -233,21 +233,21 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); // Submit form: Unselect the option. $edit = array("card_1[$langcode]" => '_none'); - $this->drupalPost('test-entity/' . $entity->ftid .'/edit', $edit, t('Save')); + $this->drupalPost('test-entity/' . $entity->ftid . '/edit', $edit, t('Save')); $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); // A required select list does not have an empty key. $instance['required'] = TRUE; field_update_instance($instance); - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); - $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-1-' . $langcode)), t('A required select list does not have an empty key.')); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); + $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-1-' . $langcode)), 'A required select list does not have an empty key.'); // We do not have to test that a required select list with one option is // auto-selected because the browser does it for us. @@ -261,12 +261,12 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_update_instance($instance); // Display form: with no field data, nothing is selected - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); - $this->assertRaw('Group 1', t('Option groups are displayed.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); + $this->assertRaw('Group 1', 'Option groups are displayed.'); // Submit form: select first option. $edit = array("card_1[$langcode]" => 0); @@ -274,14 +274,14 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_1', $langcode, array(0)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); // Submit form: Unselect the option. $edit = array("card_1[$langcode]" => '_none'); - $this->drupalPost('test-entity/' . $entity->ftid .'/edit', $edit, t('Save')); + $this->drupalPost('test-entity/' . $entity->ftid . '/edit', $edit, t('Save')); $this->assertFieldValues($entity_init, 'card_1', $langcode, array()); } @@ -308,11 +308,11 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_test_entity_save($entity); // Display form: with no field data, nothing is selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select first and third options. $edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2)); @@ -320,7 +320,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0, 2)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertOptionSelected("edit-card-2-$langcode", 2); @@ -331,7 +331,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 2); @@ -339,7 +339,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Submit form: select the three options while the field accepts only 2. $edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2)); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); + $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.'); // Submit form: uncheck all options. $edit = array("card_2[$langcode][]" => array()); @@ -351,19 +351,19 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Check that the 'none' option has no efect if actual options are selected // as well. $edit = array("card_2[$langcode][]" => array('_none' => '_none', 0 => 0)); - $this->drupalPost('test-entity/' . $entity->ftid .'/edit', $edit, t('Save')); + $this->drupalPost('test-entity/' . $entity->ftid . '/edit', $edit, t('Save')); $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); // Check that selecting the 'none' option empties the field. $edit = array("card_2[$langcode][]" => array('_none' => '_none')); - $this->drupalPost('test-entity/' . $entity->ftid .'/edit', $edit, t('Save')); + $this->drupalPost('test-entity/' . $entity->ftid . '/edit', $edit, t('Save')); $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); // A required select list does not have an empty key. $instance['required'] = TRUE; field_update_instance($instance); - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); - $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), t('A required select list does not have an empty key.')); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); + $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.'); // We do not have to test that a required select list with one option is // auto-selected because the browser does it for us. @@ -378,12 +378,12 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_update_instance($instance); // Display form: with no field data, nothing is selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); - $this->assertRaw('Group 1', t('Option groups are displayed.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); + $this->assertRaw('Group 1', 'Option groups are displayed.'); // Submit form: select first option. $edit = array("card_2[$langcode][]" => array(0 => 0)); @@ -391,14 +391,14 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'card_2', $langcode, array(0)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 2); // Submit form: Unselect the option. $edit = array("card_2[$langcode][]" => array('_none' => '_none')); - $this->drupalPost('test-entity/' . $entity->ftid .'/edit', $edit, t('Save')); + $this->drupalPost('test-entity/' . $entity->ftid . '/edit', $edit, t('Save')); $this->assertFieldValues($entity_init, 'card_2', $langcode, array()); } @@ -425,9 +425,9 @@ class OptionsWidgetsTestCase extends FieldTestCase { field_test_entity_save($entity); // Display form: with no field data, option is unchecked. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoFieldChecked("edit-bool-$langcode"); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: check the option. $edit = array("bool[$langcode]" => TRUE); @@ -435,7 +435,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'bool', $langcode, array(0)); // Display form: check that the right options are selected. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertFieldChecked("edit-bool-$langcode"); // Submit form: uncheck the option. @@ -444,7 +444,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertFieldValues($entity_init, 'bool', $langcode, array(1)); // Display form: with 'off' value, option is unchecked. - $this->drupalGet('test-entity/' . $entity->ftid .'/edit'); + $this->drupalGet('test-entity/' . $entity->ftid . '/edit'); $this->assertNoFieldChecked("edit-bool-$langcode"); } } diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test index 51e2ce44a789123b66bf50d25d65f87bc895929a..a4ead6e48c5b4b429eb4681852adac6a118746db 100644 --- a/modules/field/modules/text/text.test +++ b/modules/field/modules/text/text.test @@ -106,8 +106,8 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed')); + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', 'Format selector is not displayed'); // Submit with some value. $value = $this->randomName(); @@ -117,7 +117,7 @@ class TextFieldTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); + $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); // Display the entity. $entity = field_test_entity_test_load($id); @@ -175,8 +175,8 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display the creation form. Since the user only has access to one format, // no format selector will be displayed. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed')); + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', 'Format selector is not displayed'); // Submit with data that should be filtered. $value = '' . $this->randomName() . ''; @@ -186,14 +186,14 @@ class TextFieldTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); + $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); // Display the entity. $entity = field_test_entity_test_load($id); $entity->content = field_attach_view($entity_type, $entity, 'full'); $this->content = drupal_render($entity->content); - $this->assertNoRaw($value, t('HTML tags are not displayed.')); - $this->assertRaw(check_plain($value), t('Escaped HTML is displayed correctly.')); + $this->assertNoRaw($value, 'HTML tags are not displayed.'); + $this->assertRaw(check_plain($value), 'Escaped HTML is displayed correctly.'); // Create a new text format that does not escape HTML, and grant the user // access to it. @@ -211,21 +211,21 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display edition form. // We should now have a 'text format' selector. $this->drupalGet('test-entity/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is displayed')); + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed'); + $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", '', 'Format selector is displayed'); // Edit and change the text format to the new one that was created. $edit = array( "{$this->field_name}[$langcode][0][format]" => $format_id, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated')); + $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); // Display the entity. $entity = field_test_entity_test_load($id); $entity->content = field_attach_view($entity_type, $entity, 'full'); $this->content = drupal_render($entity->content); - $this->assertRaw($value, t('Value is displayed unfiltered')); + $this->assertRaw($value, 'Value is displayed unfiltered'); } } @@ -359,9 +359,9 @@ class TextSummaryTestCase extends DrupalWebTestCase { // Test text_summary() for different sizes. for ($i = 0; $i <= 37; $i++) { - $this->callTextSummary($text, $expected[$i], NULL, $i); - $this->callTextSummary($text, $expected_lb[$i], 1, $i); - $this->callTextSummary($text, $expected_lb[$i], 2, $i); + $this->callTextSummary($text, $expected[$i], NULL, $i); + $this->callTextSummary($text, $expected_lb[$i], 1, $i); + $this->callTextSummary($text, $expected_lb[$i], 2, $i); } } @@ -370,7 +370,7 @@ class TextSummaryTestCase extends DrupalWebTestCase { */ function callTextSummary($text, $expected, $format = NULL, $size = NULL) { $summary = text_summary($text, $format, $size); - $this->assertIdentical($summary, $expected, t('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected))); + $this->assertIdentical($summary, $expected, 'Generated summary "' . $summary . '" matches expected "' . $expected . '".'); } } @@ -398,7 +398,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { // Set "Article" content type to use multilingual support with translation. $edit = array('language_content_type' => 2); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); - $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.')); + $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), 'Article content type has been updated.'); } /** @@ -410,7 +410,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { $edit = array('field[cardinality]' => -1); $this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings')); $this->drupalGet('node/add/article'); - $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), t('Body field cardinality set to multiple.')); + $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), 'Body field cardinality set to multiple.'); $body = array( $this->randomName(), @@ -434,7 +434,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { "body[$langcode][$delta][format]" => $format--, ); $this->drupalPost('node/1/edit', $edit, t('Save')); - $this->assertText($body[$delta], t('The body field with delta @delta has been saved.', array('@delta' => $delta))); + $this->assertText($body[$delta], 'The body field with delta ' . $delta . ' has been saved.'); } // Login as translator. @@ -444,7 +444,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { // Translate the article in french. $this->drupalGet('node/1/translate'); $this->clickLink(t('add translation')); - $this->assertNoText($body[0], t('The body field with delta @delta is hidden.', array('@delta' => 0))); - $this->assertText($body[1], t('The body field with delta @delta is shown.', array('@delta' => 1))); + $this->assertNoText($body[0], 'The body field with delta ' . 0 . ' is hidden.'); + $this->assertText($body[1], 'The body field with delta ' . 1 . ' is shown.'); } } diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 7fbdba694dbae8a8c0148f6cf14af8fa4bfb2f29..8038233be93f317bb4ed03ac1bc8234d179e6aa4 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -65,9 +65,9 @@ class FieldTestCase extends DrupalWebTestCase { $e = clone $entity; field_attach_load('test_entity', array($e->ftid => $e)); $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array(); - $this->assertEqual(count($values), count($expected_values), t('Expected number of values were saved.')); + $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.'); foreach ($expected_values as $key => $value) { - $this->assertEqual($values[$key][$column], $value, t('Value @value was saved correctly.', array('@value' => $value))); + $this->assertEqual($values[$key][$column], $value, 'Value ' . $value . ' was saved correctly.'); } } } @@ -166,12 +166,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $entity)); // Number of values per field loaded equals the field cardinality. - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Current revision: expected number of values')); + $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], 'Current revision: expected number of values'); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // The field value loaded matches the one inserted or updated. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'] , $values[$current_revision][$delta]['value'], t('Current revision: expected value %delta was found.', array('%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$current_revision][$delta]['value'], 'Current revision: expected value ' . $delta . ' was found.'); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Current revision: extra information for value %delta was found', array('%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', 'Current revision: extra information for value ' . $delta . ' was found'); } // Confirm each revision loads the correct data. @@ -179,12 +179,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, $revision_id, $this->instance['bundle']); field_attach_load_revision($entity_type, array(0 => $entity)); // Number of values per field loaded equals the field cardinality. - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id))); + $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], 'Revision ' . $revision_id . ': expected number of values.'); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // The field value loaded matches the one inserted or updated. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$revision_id][$delta]['value'], t('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$revision_id][$delta]['value'], 'Revision ' . $revision_id . ': expected value ' . $delta . ' was found.'); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Revision %revision_id: extra information for value %delta was found', array('%revision_id' => $revision_id, '%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', 'Revision ' . $revision_id . ': extra information for value ' . $delta . ' was found'); } } } @@ -250,19 +250,19 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instances = field_info_instances($entity_type, $bundles[$index]); foreach ($instances as $field_name => $instance) { // The field value loaded matches the one inserted. - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], t('Entity %index: expected value was found.', array('%index' => $index))); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], 'Entity ' . $index . ': expected value was found.'); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => $index))); + $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', 'Entity ' . $index . ': extra information was found'); } } // Check that the single-field load option works. $entity = field_test_create_stub_entity(1, 1, $bundles[1]); field_attach_load($entity_type, array(1 => $entity), FIELD_LOAD_CURRENT, array('field_id' => $field_ids[1])); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], t('Entity %index: expected value was found.', array('%index' => 1))); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => 1))); - $this->assert(!isset($entity->{$field_names[2]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 2, '%field_name' => $field_names[2]))); - $this->assert(!isset($entity->{$field_names[3]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 3, '%field_name' => $field_names[3]))); + $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], 'Entity ' . 1 . ': expected value was found.'); + $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', 'Entity ' . 1 . ': extra information was found'); + $this->assert(!isset($entity->{$field_names[2]}), 'Entity ' . 2 . ': field ' . $field_names[2] . ' is not loaded.'); + $this->assert(!isset($entity->{$field_names[3]}), 'Entity ' . 3 . ': field ' . $field_names[3] . ' is not loaded.'); } /** @@ -312,7 +312,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); foreach ($fields as $field) { - $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], t('%storage storage: expected values were found.', array('%storage' => $field['storage']['type']))); + $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], $field['storage']['type'] . ' storage: expected values were found.'); } } @@ -341,20 +341,20 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']); // The storage details are indexed by a storage engine type. - $this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), t('The storage type is Drupal variables.')); + $this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), 'The storage type is Drupal variables.'); $details = $field['storage']['details']['drupal_variables']; // The field_test storage details are indexed by variable name. The details // are altered, so moon and mars are correct for this test. - $this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), t('Moon is available in the instance array.')); - $this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), t('Mars is available in the instance array.')); + $this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), 'Moon is available in the instance array.'); + $this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), 'Mars is available in the instance array.'); // Test current and revision storage details together because the columns // are the same. foreach ((array) $field['columns'] as $column_name => $attributes) { - $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'moon[FIELD_LOAD_CURRENT]'))); - $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'mars[FIELD_LOAD_REVISION]'))); + $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, 'Column name ' . $column_name . ' matches the definition in ' . 'moon[FIELD_LOAD_CURRENT]' . '.'); + $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, 'Column name ' . $column_name . ' matches the definition in ' . 'mars[FIELD_LOAD_REVISION]' . '.'); } } @@ -372,7 +372,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Insert: missing field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Insert: missing field results in no value saved'); // Insert: Field is NULL. field_cache_clear(); @@ -382,7 +382,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Insert: NULL field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Insert: NULL field results in no value saved'); // Add some real data. field_cache_clear(); @@ -393,7 +393,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved'); // Update: Field is missing. Data should survive. field_cache_clear(); @@ -402,7 +402,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Update: missing field leaves existing values in place')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Update: missing field leaves existing values in place'); // Update: Field is NULL. Data should be wiped. field_cache_clear(); @@ -412,7 +412,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Update: NULL field removes existing values')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Update: NULL field removes existing values'); // Re-add some data. field_cache_clear(); @@ -423,7 +423,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved'); // Update: Field is empty array. Data should be wiped. field_cache_clear(); @@ -433,7 +433,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Update: empty array removes existing values')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Update: empty array removes existing values'); } /** @@ -455,7 +455,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), t('Insert: NULL field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), 'Insert: NULL field results in no value saved'); // Insert: Field is missing. field_cache_clear(); @@ -465,7 +465,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $values = field_test_default_value($entity_type, $entity, $this->field, $this->instance); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Insert: missing field results in default value saved')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Insert: missing field results in default value saved'); } /** @@ -520,7 +520,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { } $read = field_test_create_stub_entity(0, 2, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $read)); - $this->assertIdentical($read->{$this->field_name}, array(), t('The test entity current revision is deleted.')); + $this->assertIdentical($read->{$this->field_name}, array(), 'The test entity current revision is deleted.'); } /** @@ -759,7 +759,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { break; } } - $this->assertTrue($result, t('Variable $@field_name correctly populated.', array('@field_name' => $this->field_name))); + $this->assertTrue($result, 'Variable $' . $this->field_name . ' correctly populated.'); } /** @@ -776,18 +776,18 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $cid = "field:$entity_type:{$entity_init->ftid}"; // Check that no initial cache entry is present. - $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no initial cache entry')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_insert($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on insert')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no cache entry on insert'); // Load, and check that no cache entry is present. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on load')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no cache entry on load'); // Cacheable entity type. @@ -798,38 +798,38 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { field_create_instance($instance); // Check that no initial cache entry is present. - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no initial cache entry')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_insert($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on insert')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on insert'); // Load a single field, and check that no cache entry is present. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id)); $cache = cache_get($cid, 'cache_field'); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on loading a single field')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on loading a single field'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Update with different values, and check that the cache entry is wiped. $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on update')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on update'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Create a new revision, and check that the cache entry is wiped. $entity_init = field_test_create_stub_entity(1, 2, $this->instance['bundle']); @@ -838,17 +838,17 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); $cache = cache_get($cid, 'cache_field'); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on new revision creation')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on new revision creation'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Delete, and check that the cache entry is wiped. field_attach_delete($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry after delete')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry after delete'); } /** @@ -898,7 +898,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { catch (FieldValidationException $e) { $errors = $e->errors; } - $this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', t('Cardinality validation failed.')); + $this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', 'Cardinality validation failed.'); } @@ -996,39 +996,39 @@ class FieldInfoTestCase extends FieldTestCase { $info = field_info_field_types(); foreach ($field_test_info as $t_key => $field_type) { foreach ($field_type as $key => $val) { - $this->assertEqual($info[$t_key][$key], $val, t("Field type $t_key key $key is $val")); + $this->assertEqual($info[$t_key][$key], $val, "Field type $t_key key $key is $val"); } - $this->assertEqual($info[$t_key]['module'], 'field_test', t("Field type field_test module appears")); + $this->assertEqual($info[$t_key]['module'], 'field_test', "Field type field_test module appears"); } $info = field_info_formatter_types(); foreach ($formatter_info as $f_key => $formatter) { foreach ($formatter as $key => $val) { - $this->assertEqual($info[$f_key][$key], $val, t("Formatter type $f_key key $key is $val")); + $this->assertEqual($info[$f_key][$key], $val, "Formatter type $f_key key $key is $val"); } - $this->assertEqual($info[$f_key]['module'], 'field_test', t("Formatter type field_test module appears")); + $this->assertEqual($info[$f_key]['module'], 'field_test', "Formatter type field_test module appears"); } $info = field_info_widget_types(); foreach ($widget_info as $w_key => $widget) { foreach ($widget as $key => $val) { - $this->assertEqual($info[$w_key][$key], $val, t("Widget type $w_key key $key is $val")); + $this->assertEqual($info[$w_key][$key], $val, "Widget type $w_key key $key is $val"); } - $this->assertEqual($info[$w_key]['module'], 'field_test', t("Widget type field_test module appears")); + $this->assertEqual($info[$w_key]['module'], 'field_test', "Widget type field_test module appears"); } $info = field_info_storage_types(); foreach ($storage_info as $s_key => $storage) { foreach ($storage as $key => $val) { - $this->assertEqual($info[$s_key][$key], $val, t("Storage type $s_key key $key is $val")); + $this->assertEqual($info[$s_key][$key], $val, "Storage type $s_key key $key is $val"); } - $this->assertEqual($info[$s_key]['module'], 'field_test', t("Storage type field_test module appears")); + $this->assertEqual($info[$s_key]['module'], 'field_test', "Storage type field_test module appears"); } // Verify that no unexpected instances exist. $core_fields = field_info_fields(); $instances = field_info_instances('test_entity', 'test_bundle'); - $this->assertTrue(empty($instances), t('With no instances, info bundles is empty.')); + $this->assertTrue(empty($instances), 'With no instances, info bundles is empty.'); // Create a field, verify it shows up. $field = array( @@ -1037,16 +1037,16 @@ class FieldInfoTestCase extends FieldTestCase { ); field_create_field($field); $fields = field_info_fields(); - $this->assertEqual(count($fields), count($core_fields) + 1, t('One new field exists')); - $this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], t('info fields contains field name')); - $this->assertEqual($fields[$field['field_name']]['type'], $field['type'], t('info fields contains field type')); - $this->assertEqual($fields[$field['field_name']]['module'], 'field_test', t('info fields contains field module')); + $this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists'); + $this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], 'info fields contains field name'); + $this->assertEqual($fields[$field['field_name']]['type'], $field['type'], 'info fields contains field type'); + $this->assertEqual($fields[$field['field_name']]['module'], 'field_test', 'info fields contains field module'); $settings = array('test_field_setting' => 'dummy test string'); foreach ($settings as $key => $val) { - $this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, t("Field setting $key has correct default value $val")); + $this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, "Field setting $key has correct default value $val"); } - $this->assertEqual($fields[$field['field_name']]['cardinality'], 1, t('info fields contains cardinality 1')); - $this->assertEqual($fields[$field['field_name']]['active'], 1, t('info fields contains active 1')); + $this->assertEqual($fields[$field['field_name']]['cardinality'], 1, 'info fields contains cardinality 1'); + $this->assertEqual($fields[$field['field_name']]['active'], 1, 'info fields contains active 1'); // Create an instance, verify that it shows up $instance = array( @@ -1064,8 +1064,8 @@ class FieldInfoTestCase extends FieldTestCase { field_create_instance($instance); $instances = field_info_instances('test_entity', $instance['bundle']); - $this->assertEqual(count($instances), 1, t('One instance shows up in info when attached to a bundle.')); - $this->assertTrue($instance < $instances[$instance['field_name']], t('Instance appears in info correctly')); + $this->assertEqual(count($instances), 1, 'One instance shows up in info when attached to a bundle.'); + $this->assertTrue($instance < $instances[$instance['field_name']], 'Instance appears in info correctly'); } /** @@ -1096,7 +1096,7 @@ class FieldInfoTestCase extends FieldTestCase { // Check that all expected settings are in place. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($field['settings'], $field_type['settings'], t('All expected default field settings are present.')); + $this->assertIdentical($field['settings'], $field_type['settings'], 'All expected default field settings are present.'); } /** @@ -1138,18 +1138,18 @@ class FieldInfoTestCase extends FieldTestCase { // Check that all expected instance settings are in place. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($instance['settings'], $field_type['instance_settings'] , t('All expected instance settings are present.')); + $this->assertIdentical($instance['settings'], $field_type['instance_settings'], 'All expected instance settings are present.'); // Check that the default widget is used and expected settings are in place. - $this->assertIdentical($instance['widget']['type'], $field_type['default_widget'], t('Unavailable widget replaced with default widget.')); + $this->assertIdentical($instance['widget']['type'], $field_type['default_widget'], 'Unavailable widget replaced with default widget.'); $widget_type = field_info_widget_types($instance['widget']['type']); - $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'] , t('All expected widget settings are present.')); + $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'], 'All expected widget settings are present.'); // Check that display settings are set for the 'default' mode. $display = $instance['display']['default']; - $this->assertIdentical($display['type'], $field_type['default_formatter'], t("Formatter is set for the 'default' view mode")); + $this->assertIdentical($display['type'], $field_type['default_formatter'], "Formatter is set for the 'default' view mode"); $formatter_type = field_info_formatter_types($display['type']); - $this->assertIdentical($display['settings'], $formatter_type['settings'] , t("Formatter settings are set for the 'default' view mode")); + $this->assertIdentical($display['settings'], $formatter_type['settings'], "Formatter settings are set for the 'default' view mode"); } /** @@ -1172,7 +1172,7 @@ class FieldInfoTestCase extends FieldTestCase { // Disable coment module. This clears field_info cache. module_disable(array('comment')); - $this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), t('No instances are returned on disabled entity types.')); + $this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), 'No instances are returned on disabled entity types.'); } /** @@ -1319,13 +1319,13 @@ class FieldFormTestCase extends FieldTestCase { $this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); } -// function testFieldFormMultiple() { -// $this->field = $this->field_multiple; -// $this->field_name = $this->field['field_name']; -// $this->instance['field_name'] = $this->field_name; -// field_create_field($this->field); -// field_create_instance($this->instance); -// } + // function testFieldFormMultiple() { + // $this->field = $this->field_multiple; + // $this->field_name = $this->field['field_name']; + // $this->instance['field_name'] = $this->field_name; + // field_create_field($this->field); + // field_create_instance($this->instance); + // } function testFieldFormUnlimited() { $this->field = $this->field_unlimited; @@ -1469,7 +1469,7 @@ class FieldFormTestCase extends FieldTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '', t('Widget is displayed.')); + $this->assertFieldByName("{$this->field_name}[$langcode]", '', 'Widget is displayed.'); // Create entity with three values. $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3'); @@ -1483,12 +1483,12 @@ class FieldFormTestCase extends FieldTestCase { // Display the form, check that the values are correctly filled in. $this->drupalGet('test-entity/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', t('Widget is displayed.')); + $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', 'Widget is displayed.'); // Submit the form with more values than the field accepts. $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3, 4, 5'); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw('this field cannot hold more than 4 values', t('Form validation failed.')); + $this->assertRaw('this field cannot hold more than 4 values', 'Form validation failed.'); // Check that the field values were not submitted. $this->assertFieldValues($entity_init, $this->field_name, $langcode, array(1, 2, 3)); } @@ -1524,7 +1524,7 @@ class FieldFormTestCase extends FieldTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', t('Widget is not displayed if field access is denied.')); + $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', 'Widget is not displayed if field access is denied.'); // Create entity. $edit = array("{$field_name}[$langcode][0][value]" => 1); @@ -1534,8 +1534,8 @@ class FieldFormTestCase extends FieldTestCase { // Check that the default value was saved. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('Default value was saved for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, t('Entered value vas saved for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'Default value was saved for the field with no edit access.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, 'Entered value vas saved for the field with edit access.'); // Create a new revision. $edit = array("{$field_name}[$langcode][0][value]" => 2, 'revision' => TRUE); @@ -1543,13 +1543,13 @@ class FieldFormTestCase extends FieldTestCase { // Check that the new revision has the expected values. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); // Check that the revision is also saved in the revisions table. $entity = field_test_entity_test_load($id, $entity->ftvid); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); } } @@ -1615,9 +1615,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $this->drupalSetContent(drupal_render($output)); $settings = field_info_formatter_settings('field_test_default'); $setting = $settings['test_formatter_setting']; - $this->assertText($this->label, t('Label was displayed.')); - foreach($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($this->label, 'Label was displayed.'); + foreach ($this->values as $delta => $value) { + $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } // Check that explicit display settings are used. @@ -1631,12 +1631,12 @@ class FieldDisplayAPITestCase extends FieldTestCase { $output = field_view_field('test_entity', $this->entity, $this->field_name, $display); $this->drupalSetContent(drupal_render($output)); $setting = $display['settings']['test_formatter_setting_multiple']; - $this->assertNoText($this->label, t('Label was not displayed.')); + $this->assertNoText($this->label, 'Label was not displayed.'); $array = array(); - foreach($this->values as $delta => $value) { + foreach ($this->values as $delta => $value) { $array[] = $delta . ':' . $value['value']; } - $this->assertText($setting . '|' . implode('|', $array), t('Values were displayed with expected setting.')); + $this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.'); // Check the prepare_view steps are invoked. $display = array( @@ -1650,9 +1650,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $view = drupal_render($output); $this->drupalSetContent($view); $setting = $display['settings']['test_formatter_setting_additional']; - $this->assertNoText($this->label, t('Label was not displayed.')); + $this->assertNoText($this->label, 'Label was not displayed.'); foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), 'Value ' . $delta . ' was displayed with expected setting.'); } // View mode: check that display settings specified in the instance are @@ -1660,9 +1660,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $output = field_view_field('test_entity', $this->entity, $this->field_name, 'teaser'); $this->drupalSetContent(drupal_render($output)); $setting = $this->instance['display']['teaser']['settings']['test_formatter_setting']; - $this->assertText($this->label, t('Label was displayed.')); - foreach($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($this->label, 'Label was displayed.'); + foreach ($this->values as $delta => $value) { + $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } // Unknown view mode: check that display settings for 'default' view mode @@ -1670,9 +1670,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); $setting = $this->instance['display']['default']['settings']['test_formatter_setting']; - $this->assertText($this->label, t('Label was displayed.')); - foreach($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($this->label, 'Label was displayed.'); + foreach ($this->values as $delta => $value) { + $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } } @@ -1687,7 +1687,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } // Check that explicit display settings are used. @@ -1703,7 +1703,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|0:' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|0:' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } // Check that prepare_view steps are invoked. @@ -1719,7 +1719,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), 'Value ' . $delta . ' was displayed with expected setting.'); } // View mode: check that display settings specified in the instance are @@ -1729,7 +1729,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'teaser'); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } // Unknown view mode: check that display settings for 'default' view mode @@ -1739,7 +1739,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); } } } @@ -1782,26 +1782,26 @@ class FieldCrudTestCase extends FieldTestCase { $record['data'] = unserialize($record['data']); // Ensure that basic properties are preserved. - $this->assertEqual($record['field_name'], $field_definition['field_name'], t('The field name is properly saved.')); - $this->assertEqual($record['type'], $field_definition['type'], t('The field type is properly saved.')); + $this->assertEqual($record['field_name'], $field_definition['field_name'], 'The field name is properly saved.'); + $this->assertEqual($record['type'], $field_definition['type'], 'The field type is properly saved.'); // Ensure that cardinality defaults to 1. - $this->assertEqual($record['cardinality'], 1, t('Cardinality defaults to 1.')); + $this->assertEqual($record['cardinality'], 1, 'Cardinality defaults to 1.'); // Ensure that default settings are present. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($record['data']['settings'], $field_type['settings'], t('Default field settings have been written.')); + $this->assertIdentical($record['data']['settings'], $field_type['settings'], 'Default field settings have been written.'); // Ensure that default storage was set. - $this->assertEqual($record['storage_type'], variable_get('field_storage_default'), t('The field type is properly saved.')); + $this->assertEqual($record['storage_type'], variable_get('field_storage_default'), 'The field type is properly saved.'); // Guarantee that the name is unique. try { field_create_field($field_definition); - $this->fail(t('Cannot create two fields with the same name.')); + $this->fail('Cannot create two fields with the same name.'); } catch (FieldException $e) { - $this->pass(t('Cannot create two fields with the same name.')); + $this->pass('Cannot create two fields with the same name.'); } // Check that field type is required. @@ -1810,10 +1810,10 @@ class FieldCrudTestCase extends FieldTestCase { 'field_name' => 'field_1', ); field_create_field($field_definition); - $this->fail(t('Cannot create a field with no type.')); + $this->fail('Cannot create a field with no type.'); } catch (FieldException $e) { - $this->pass(t('Cannot create a field with no type.')); + $this->pass('Cannot create a field with no type.'); } // Check that field name is required. @@ -1822,10 +1822,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field' ); field_create_field($field_definition); - $this->fail(t('Cannot create an unnamed field.')); + $this->fail('Cannot create an unnamed field.'); } catch (FieldException $e) { - $this->pass(t('Cannot create an unnamed field.')); + $this->pass('Cannot create an unnamed field.'); } // Check that field name must start with a letter or _. @@ -1835,10 +1835,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field', ); field_create_field($field_definition); - $this->fail(t('Cannot create a field with a name starting with a digit.')); + $this->fail('Cannot create a field with a name starting with a digit.'); } catch (FieldException $e) { - $this->pass(t('Cannot create a field with a name starting with a digit.')); + $this->pass('Cannot create a field with a name starting with a digit.'); } // Check that field name must only contain lowercase alphanumeric or _. @@ -1848,10 +1848,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field', ); field_create_field($field_definition); - $this->fail(t('Cannot create a field with a name containing an illegal character.')); + $this->fail('Cannot create a field with a name containing an illegal character.'); } catch (FieldException $e) { - $this->pass(t('Cannot create a field with a name containing an illegal character.')); + $this->pass('Cannot create a field with a name containing an illegal character.'); } // Check that field name cannot be longer than 32 characters long. @@ -1861,10 +1861,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field', ); field_create_field($field_definition); - $this->fail(t('Cannot create a field with a name longer than 32 characters.')); + $this->fail('Cannot create a field with a name longer than 32 characters.'); } catch (FieldException $e) { - $this->pass(t('Cannot create a field with a name longer than 32 characters.')); + $this->pass('Cannot create a field with a name longer than 32 characters.'); } // Check that field name can not be an entity key. @@ -1875,10 +1875,10 @@ class FieldCrudTestCase extends FieldTestCase { 'field_name' => 'ftvid', ); $field = field_create_field($field_definition); - $this->fail(t('Cannot create a field bearing the name of an entity key.')); + $this->fail('Cannot create a field bearing the name of an entity key.'); } catch (FieldException $e) { - $this->pass(t('Cannot create a field bearing the name of an entity key.')); + $this->pass('Cannot create a field bearing the name of an entity key.'); } } @@ -1920,7 +1920,7 @@ class FieldCrudTestCase extends FieldTestCase { // Read the field back. $field = field_read_field($field_definition['field_name']); - $this->assertTrue($field_definition < $field, t('The field was properly read.')); + $this->assertTrue($field_definition < $field, 'The field was properly read.'); } /** @@ -1935,7 +1935,7 @@ class FieldCrudTestCase extends FieldTestCase { field_create_field($field_definition); $field = field_read_field($field_definition['field_name']); $expected_indexes = array('value' => array('value')); - $this->assertEqual($field['indexes'], $expected_indexes, t('Field type indexes saved by default')); + $this->assertEqual($field['indexes'], $expected_indexes, 'Field type indexes saved by default'); // Check that indexes specified by the field definition override the field // type indexes. @@ -1949,7 +1949,7 @@ class FieldCrudTestCase extends FieldTestCase { field_create_field($field_definition); $field = field_read_field($field_definition['field_name']); $expected_indexes = array('value' => array()); - $this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes override field type indexes')); + $this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes override field type indexes'); // Check that indexes specified by the field definition add to the field // type indexes. @@ -1963,7 +1963,7 @@ class FieldCrudTestCase extends FieldTestCase { field_create_field($field_definition); $field = field_read_field($field_definition['field_name']); $expected_indexes = array('value' => array('value'), 'value_2' => array('value')); - $this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes are merged with field type indexes')); + $this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes'); } /** @@ -1994,41 +1994,41 @@ class FieldCrudTestCase extends FieldTestCase { // Test that the first field is not deleted, and then delete it. $field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field is not marked for deletion.')); + $this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field is not marked for deletion.'); field_delete_field($this->field['field_name']); // Make sure that the field is marked as deleted when it is specifically // loaded. $field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($field['deleted']), t('A deleted field is marked for deletion.')); + $this->assertTrue(!empty($field['deleted']), 'A deleted field is marked for deletion.'); // Make sure that this field's instance is marked as deleted when it is // specifically loaded. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance['deleted']), t('An instance for a deleted field is marked for deletion.')); + $this->assertTrue(!empty($instance['deleted']), 'An instance for a deleted field is marked for deletion.'); // Try to load the field normally and make sure it does not show up. $field = field_read_field($this->field['field_name']); - $this->assertTrue(empty($field), t('A deleted field is not loaded by default.')); + $this->assertTrue(empty($field), 'A deleted field is not loaded by default.'); // Try to load the instance normally and make sure it does not show up. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(empty($instance), t('An instance for a deleted field is not loaded by default.')); + $this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.'); // Make sure the other field (and its field instance) are not deleted. $another_field = field_read_field($this->another_field['field_name']); - $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), t('A non-deleted field is not marked for deletion.')); + $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), 'A non-deleted field is not marked for deletion.'); $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); - $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('An instance of a non-deleted field is not marked for deletion.')); + $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'An instance of a non-deleted field is not marked for deletion.'); // Try to create a new field the same name as a deleted field and // write data into it. field_create_field($this->field); field_create_instance($this->instance_definition); $field = field_read_field($this->field['field_name']); - $this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field with a previously used name is created.')); + $this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field with a previously used name is created.'); $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new instance for a previously used field name is created.')); + $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new instance for a previously used field name is created.'); // Save an entity with data for the field $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); @@ -2051,10 +2051,10 @@ class FieldCrudTestCase extends FieldTestCase { $test_field = array('field_name' => 'does_not_exist', 'type' => 'number_decimal'); try { field_update_field($test_field); - $this->fail(t('Cannot update a field that does not exist.')); + $this->fail('Cannot update a field that does not exist.'); } catch (FieldException $e) { - $this->pass(t('Cannot update a field that does not exist.')); + $this->pass('Cannot update a field that does not exist.'); } } @@ -2065,10 +2065,10 @@ class FieldCrudTestCase extends FieldTestCase { $test_field = array('field_name' => 'field_type', 'type' => 'number_integer'); try { field_update_field($test_field); - $this->fail(t('Cannot update a field to a different type.')); + $this->fail('Cannot update a field to a different type.'); } catch (FieldException $e) { - $this->pass(t('Cannot update a field to a different type.')); + $this->pass('Cannot update a field to a different type.'); } } @@ -2126,18 +2126,18 @@ class FieldCrudTestCase extends FieldTestCase { $field['settings']['changeable']++; try { field_update_field($field); - $this->pass(t("A changeable setting can be updated.")); + $this->pass("A changeable setting can be updated."); } catch (FieldException $e) { - $this->fail(t("An unchangeable setting cannot be updated.")); + $this->fail("An unchangeable setting cannot be updated."); } $field['settings']['unchangeable']++; try { field_update_field($field); - $this->fail(t("An unchangeable setting can be updated.")); + $this->fail("An unchangeable setting can be updated."); } catch (FieldException $e) { - $this->pass(t("An unchangeable setting cannot be updated.")); + $this->pass("An unchangeable setting cannot be updated."); } } @@ -2181,18 +2181,18 @@ class FieldCrudTestCase extends FieldTestCase { // Read the field. $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, t('The field was properly read.')); + $this->assertTrue($field_definition <= $field, 'The field was properly read.'); module_disable($modules, FALSE); $fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE)); - $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('The field is properly read when explicitly fetching inactive fields.')); + $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, 'The field is properly read when explicitly fetching inactive fields.'); // Re-enable modules one by one, and check that the field is still inactive // while some modules remain disabled. while ($modules) { $field = field_read_field($field_name); - $this->assertTrue(empty($field), t('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules)))); + $this->assertTrue(empty($field), implode(', ', $modules) . ' disabled. The field is marked inactive.'); $module = array_shift($modules); module_enable(array($module), FALSE); @@ -2201,7 +2201,7 @@ class FieldCrudTestCase extends FieldTestCase { // Check that the field is active again after all modules have been // enabled. $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, t('The field was was marked active.')); + $this->assertTrue($field_definition <= $field, 'The field was was marked active.'); } } @@ -2253,35 +2253,35 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $formatter_type = field_info_formatter_types($field_type['default_formatter']); // Check that default values are set. - $this->assertIdentical($record['data']['required'], FALSE, t('Required defaults to false.')); - $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], t('Label defaults to field name.')); - $this->assertIdentical($record['data']['description'], '', t('Description defaults to empty string.')); - $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], t('Default widget has been written.')); - $this->assertTrue(isset($record['data']['display']['default']), t('Display for "full" view_mode has been written.')); - $this->assertIdentical($record['data']['display']['default']['type'], $field_type['default_formatter'], t('Default formatter for "full" view_mode has been written.')); + $this->assertIdentical($record['data']['required'], FALSE, 'Required defaults to false.'); + $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], 'Label defaults to field name.'); + $this->assertIdentical($record['data']['description'], '', 'Description defaults to empty string.'); + $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], 'Default widget has been written.'); + $this->assertTrue(isset($record['data']['display']['default']), 'Display for "full" view_mode has been written.'); + $this->assertIdentical($record['data']['display']['default']['type'], $field_type['default_formatter'], 'Default formatter for "full" view_mode has been written.'); // Check that default settings are set. - $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'] , t('Default instance settings have been written.')); - $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'] , t('Default widget settings have been written.')); - $this->assertIdentical($record['data']['display']['default']['settings'], $formatter_type['settings'], t('Default formatter settings for "full" view_mode have been written.')); + $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'], 'Default instance settings have been written.'); + $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'], 'Default widget settings have been written.'); + $this->assertIdentical($record['data']['display']['default']['settings'], $formatter_type['settings'], 'Default formatter settings for "full" view_mode have been written.'); // Guarantee that the field/bundle combination is unique. try { field_create_instance($this->instance_definition); - $this->fail(t('Cannot create two instances with the same field / bundle combination.')); + $this->fail('Cannot create two instances with the same field / bundle combination.'); } catch (FieldException $e) { - $this->pass(t('Cannot create two instances with the same field / bundle combination.')); + $this->pass('Cannot create two instances with the same field / bundle combination.'); } // Check that the specified field exists. try { $this->instance_definition['field_name'] = $this->randomName(); field_create_instance($this->instance_definition); - $this->fail(t('Cannot create an instance of a non-existing field.')); + $this->fail('Cannot create an instance of a non-existing field.'); } catch (FieldException $e) { - $this->pass(t('Cannot create an instance of a non-existing field.')); + $this->pass('Cannot create an instance of a non-existing field.'); } // Create a field restricted to a specific entity type. @@ -2299,10 +2299,10 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $instance['field_name'] = $field_restricted['field_name']; $instance['entity_type'] = 'test_cacheable_entity'; field_create_instance($instance); - $this->pass(t('Can create an instance on an entity type allowed by the field.')); + $this->pass('Can create an instance on an entity type allowed by the field.'); } catch (FieldException $e) { - $this->fail(t('Can create an instance on an entity type allowed by the field.')); + $this->fail('Can create an instance on an entity type allowed by the field.'); } // Check that an instance cannot be added to an entity type @@ -2311,10 +2311,10 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $instance = $this->instance_definition; $instance['field_name'] = $field_restricted['field_name']; field_create_instance($instance); - $this->fail(t('Cannot create an instance on an entity type forbidden by the field.')); + $this->fail('Cannot create an instance on an entity type forbidden by the field.'); } catch (FieldException $e) { - $this->pass(t('Cannot create an instance on an entity type forbidden by the field.')); + $this->pass('Cannot create an instance on an entity type forbidden by the field.'); } // TODO: test other failures. @@ -2328,7 +2328,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Read the instance back. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue($this->instance_definition < $instance, t('The field was properly read.')); + $this->assertTrue($this->instance_definition < $instance, 'The field was properly read.'); } /** @@ -2344,20 +2344,20 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $instance['label'] = $this->randomName(); $instance['description'] = $this->randomName(); $instance['settings']['test_instance_setting'] = $this->randomName(); - $instance['widget']['settings']['test_widget_setting'] =$this->randomName(); + $instance['widget']['settings']['test_widget_setting'] = $this->randomName(); $instance['widget']['weight']++; $instance['display']['default']['settings']['test_formatter_setting'] = $this->randomName(); $instance['display']['default']['weight']++; field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance['required'], $instance_new['required'], t('"required" change is saved')); - $this->assertEqual($instance['label'], $instance_new['label'], t('"label" change is saved')); - $this->assertEqual($instance['description'], $instance_new['description'], t('"description" change is saved')); - $this->assertEqual($instance['widget']['settings']['test_widget_setting'], $instance_new['widget']['settings']['test_widget_setting'], t('Widget setting change is saved')); - $this->assertEqual($instance['widget']['weight'], $instance_new['widget']['weight'], t('Widget weight change is saved')); - $this->assertEqual($instance['display']['default']['settings']['test_formatter_setting'], $instance_new['display']['default']['settings']['test_formatter_setting'], t('Formatter setting change is saved')); - $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], t('Widget weight change is saved')); + $this->assertEqual($instance['required'], $instance_new['required'], '"required" change is saved'); + $this->assertEqual($instance['label'], $instance_new['label'], '"label" change is saved'); + $this->assertEqual($instance['description'], $instance_new['description'], '"description" change is saved'); + $this->assertEqual($instance['widget']['settings']['test_widget_setting'], $instance_new['widget']['settings']['test_widget_setting'], 'Widget setting change is saved'); + $this->assertEqual($instance['widget']['weight'], $instance_new['widget']['weight'], 'Widget weight change is saved'); + $this->assertEqual($instance['display']['default']['settings']['test_formatter_setting'], $instance_new['display']['default']['settings']['test_formatter_setting'], 'Formatter setting change is saved'); + $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], 'Widget weight change is saved'); // Check that changing widget and formatter types updates the default settings. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); @@ -2366,13 +2366,13 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'] , t('Widget type change is saved.')); + $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'], 'Widget type change is saved.'); $settings = field_info_widget_settings($instance_new['widget']['type']); - $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings) , t('Widget type change updates default settings.')); - $this->assertEqual($instance['display']['default']['type'], $instance_new['display']['default']['type'] , t('Formatter type change is saved.')); + $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings), 'Widget type change updates default settings.'); + $this->assertEqual($instance['display']['default']['type'], $instance_new['display']['default']['type'], 'Formatter type change is saved.'); $info = field_info_formatter_types($instance_new['display']['default']['type']); $settings = $info['settings']; - $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings) , t('Changing formatter type updates default settings.')); + $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings), 'Changing formatter type updates default settings.'); // Check that adding a new view mode is saved and gets default settings. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); @@ -2380,11 +2380,11 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(isset($instance_new['display']['teaser']), t('Display for the new view_mode has been written.')); - $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], t('Default formatter for the new view_mode has been written.')); + $this->assertTrue(isset($instance_new['display']['teaser']), 'Display for the new view_mode has been written.'); + $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], 'Default formatter for the new view_mode has been written.'); $info = field_info_formatter_types($instance_new['display']['teaser']['type']); $settings = $info['settings']; - $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'] , t('Default formatter settings for the new view_mode have been written.')); + $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'], 'Default formatter settings for the new view_mode have been written.'); // TODO: test failures. } @@ -2406,21 +2406,21 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Test that the first instance is not deleted, and then delete it. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new field instance is not marked for deletion.')); + $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new field instance is not marked for deletion.'); field_delete_instance($instance); // Make sure the instance is marked as deleted when the instance is // specifically loaded. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance['deleted']), t('A deleted field instance is marked for deletion.')); + $this->assertTrue(!empty($instance['deleted']), 'A deleted field instance is marked for deletion.'); // Try to load the instance normally and make sure it does not show up. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(empty($instance), t('A deleted field instance is not loaded by default.')); + $this->assertTrue(empty($instance), 'A deleted field instance is not loaded by default.'); // Make sure the other field instance is not deleted. $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); - $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('A non-deleted field instance is not marked for deletion.')); + $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'A non-deleted field instance is not marked for deletion.'); } } @@ -2487,17 +2487,17 @@ class FieldTranslationsTestCase extends FieldTestCase { $available_languages = field_available_languages($this->entity_type, $this->field); foreach ($available_languages as $delta => $langcode) { if ($langcode != 'xx' && $langcode != 'en') { - $this->assertTrue(in_array($langcode, $enabled_languages), t('%language is an enabled language.', array('%language' => $langcode))); + $this->assertTrue(in_array($langcode, $enabled_languages), $langcode . ' is an enabled language.'); } } - $this->assertTrue(in_array('xx', $available_languages), t('%language was made available.', array('%language' => 'xx'))); - $this->assertFalse(in_array('en', $available_languages), t('%language was made unavailable.', array('%language' => 'en'))); + $this->assertTrue(in_array('xx', $available_languages), 'xx' . ' was made available.'); + $this->assertFalse(in_array('en', $available_languages), 'en' . ' was made unavailable.'); // Test field_available_languages() behavior for untranslatable fields. $this->field['translatable'] = FALSE; $this->field_name = $this->field['field_name'] = $this->instance['field_name'] = drupal_strtolower($this->randomName() . '_field_name'); $available_languages = field_available_languages($this->entity_type, $this->field); - $this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, t('For untranslatable fields only LANGUAGE_NONE is available.')); + $this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, 'For untranslatable fields only LANGUAGE_NONE is available.'); } /** @@ -2529,9 +2529,9 @@ class FieldTranslationsTestCase extends FieldTestCase { $hash = hash('sha256', serialize(array($entity_type, $entity, $this->field_name, $langcode, $values[$langcode]))); // Check whether the parameters passed to _field_invoke() were correctly // forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $langcode))); + $this->assertEqual($hash, $result, 'The result for ' . $langcode . ' is correctly stored.'); } - $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed.')); + $this->assertEqual(count($results), count($available_languages), 'No unavailable language has been processed.'); } /** @@ -2571,9 +2571,9 @@ class FieldTranslationsTestCase extends FieldTestCase { $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode]))); // Check whether the parameters passed to _field_invoke() were correctly // forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); + $this->assertEqual($hash, $result, 'The result for entity ' . $id . '/' . $langcode . ' is correctly stored.'); } - $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed for entity %id.', array('%id' => $id))); + $this->assertEqual(count($results), count($available_languages), 'No unavailable language has been processed for entity ' . $id . '.'); } } @@ -2584,7 +2584,7 @@ class FieldTranslationsTestCase extends FieldTestCase { // Enable field translations for nodes. field_test_entity_info_translatable('node', TRUE); $entity_info = entity_get_info('node'); - $this->assertTrue(count($entity_info['translation']), t('Nodes are translatable.')); + $this->assertTrue(count($entity_info['translation']), 'Nodes are translatable.'); // Prepare the field translations. field_test_entity_info_translatable('test_entity', TRUE); @@ -2593,7 +2593,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $entity = field_test_create_stub_entity($eid, $evid, $this->instance['bundle']); $field_translations = array(); $available_languages = field_available_languages($entity_type, $this->field); - $this->assertTrue(count($available_languages) > 1, t('Field is translatable.')); + $this->assertTrue(count($available_languages) > 1, 'Field is translatable.'); foreach ($available_languages as $langcode) { $field_translations[$langcode] = $this->_generateTestFieldValues($this->field['cardinality']); } @@ -2610,7 +2610,7 @@ class FieldTranslationsTestCase extends FieldTestCase { foreach ($items as $delta => $item) { $result = $result && $item['value'] == $entity->{$this->field_name}[$langcode][$delta]['value']; } - $this->assertTrue($result, t('%language translation correctly handled.', array('%language' => $langcode))); + $this->assertTrue($result, $langcode . ' translation correctly handled.'); } } @@ -2654,8 +2654,7 @@ class FieldTranslationsTestCase extends FieldTestCase { // Index 0 is reserved for the requested language, this way we ensure // that no field is actually populated with it. $langcode = $enabled_languages[mt_rand(1, count($enabled_languages) - 1)]; - } - while (isset($languages[$langcode])); + } while (isset($languages[$langcode])); $languages[$langcode] = TRUE; $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues($field['cardinality']); } @@ -2667,7 +2666,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $display_language = field_language($entity_type, $entity, NULL, $requested_language); foreach ($instances as $instance) { $field_name = $instance['field_name']; - $this->assertTrue($display_language[$field_name] == LANGUAGE_NONE, t('The display language for field %field_name is %language.', array('%field_name' => $field_name, '%language' => LANGUAGE_NONE))); + $this->assertTrue($display_language[$field_name] == LANGUAGE_NONE, 'The display language for field ' . $field_name . ' is ' . LANGUAGE_NONE . '.'); } // Test multiple-fields display languages for translatable entities. @@ -2681,13 +2680,13 @@ class FieldTranslationsTestCase extends FieldTestCase { // As the requested language was not assinged to any field, if the // returned language is defined for the current field, core fallback rules // were successfully applied. - $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); + $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, 'The display language for the field ' . $field_name . ' is ' . $langcode . '.'); } // Test single-field display language. drupal_static_reset('field_language'); $langcode = field_language($entity_type, $entity, $this->field_name, $requested_language); - $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); + $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, 'The display language for the (single) field ' . $field_name . ' is ' . $langcode . '.'); } /** @@ -2731,7 +2730,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $entity = field_test_entity_test_load($eid, $evid); foreach ($available_languages as $langcode => $value) { $passed = isset($entity->{$field_name}[$langcode]) && $entity->{$field_name}[$langcode][0]['value'] == $value + 1; - $this->assertTrue($passed, t('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->ftvid))); + $this->assertTrue($passed, 'The ' . $langcode . ' translation for revision ' . $entity->ftvid . ' was correctly stored'); } } } @@ -2745,7 +2744,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { public static function getInfo() { return array( 'name' => 'Field bulk delete tests', - 'description'=> 'Bulk delete fields and instances, and clean up afterwards.', + 'description' => 'Bulk delete fields and instances, and clean up afterwards.', 'group' => 'Field API', ); } @@ -2926,7 +2925,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { $this->assertEqual($stubs[$entity->ftid], $entity, 'hook_field_delete() called with the correct stub'); unset($stubs[$entity->ftid]); } - $this->assertEqual(count($stubs), $count-10, 'hook_field_delete was called with each entity once'); + $this->assertEqual(count($stubs), $count -10, 'hook_field_delete was called with each entity once'); // The instance still exists, deleted. $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1)); diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test index 5baaa341af44a77452884ab9508da25b3c0547e5..2274b75deb612cddd8b96bb655f024312727240b 100644 --- a/modules/field_ui/field_ui.test +++ b/modules/field_ui/field_ui.test @@ -10,7 +10,7 @@ * Field UI tests. */ class FieldUITestCase extends DrupalWebTestCase { - public static function getInfo() { + public static function getInfo() { return array( 'name' => 'Field UI tests', 'description' => 'Test the field UI functionality.', @@ -26,7 +26,7 @@ class FieldUITestCase extends DrupalWebTestCase { $this->drupalLogin($admin_user); // Create content type, with underscores. - $type_name = strtolower($this->randomName(8)) . '_' .'test'; + $type_name = strtolower($this->randomName(8)) . '_' . 'test'; $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name)); $this->type = $type->type; // Store a valid URL name, with hyphens instead of underscores. @@ -35,7 +35,7 @@ class FieldUITestCase extends DrupalWebTestCase { // Create random field name. $this->field_label = $this->randomName(8); $this->field_name_input = strtolower($this->randomName(8)); - $this->field_name = 'field_'. $this->field_name_input; + $this->field_name = 'field_' . $this->field_name_input; } /** @@ -66,13 +66,13 @@ class FieldUITestCase extends DrupalWebTestCase { ); foreach ($table_headers as $table_header) { // We check that the label appear in the table headings. - $this->assertRaw($table_header . '', t('%table_header table header was found.', array('%table_header' => $table_header))); + $this->assertRaw($table_header . '', $table_header . ' table header was found.'); } // "Add new field" and "Add existing field" aren't a table heading so just // test the text. foreach (array('Add new field', 'Add existing field') as $element) { - $this->assertText($element, t('"@element" was found.', array('@element' => $element))); + $this->assertText($element, '"' . $element . '" was found.'); } } @@ -95,7 +95,7 @@ class FieldUITestCase extends DrupalWebTestCase { // should also appear in the 'taxonomy term' entity. $vocabulary = taxonomy_vocabulary_load(1); $this->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/fields'); - $this->assertTrue($this->xpath('//select[@name="_add_existing_field[field_name]"]//option[@value="' . $this->field_name . '"]'), t('Existing field was found in account settings.')); + $this->assertTrue($this->xpath('//select[@name="_add_existing_field[field_name]"]//option[@value="' . $this->field_name . '"]'), 'Existing field was found in account settings.'); } /** @@ -118,7 +118,7 @@ class FieldUITestCase extends DrupalWebTestCase { $this->assertFieldSettings($this->type, $this->field_name, $string); // Assert redirection back to the "manage fields" page. - $this->assertText(t('Saved @label configuration.', array('@label' => $this->field_label)), t('Redirected to "Manage fields" page.')); + $this->assertText(t('Saved @label configuration.', array('@label' => $this->field_label)), 'Redirected to "Manage fields" page.'); } /** @@ -127,12 +127,12 @@ class FieldUITestCase extends DrupalWebTestCase { function addExistingField() { // Check "Add existing field" appears. $this->drupalGet('admin/structure/types/manage/page/fields'); - $this->assertRaw(t('Add existing field'), t('"Add existing field" was found.')); + $this->assertRaw(t('Add existing field'), '"Add existing field" was found.'); // Check that the list of options respects entity type restrictions on // fields. The 'comment' field is restricted to the 'comment' entity type // and should not appear in the list. - $this->assertFalse($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value="comment"]'), t('The list of options respects entity type restrictions.')); + $this->assertFalse($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value="comment"]'), 'The list of options respects entity type restrictions.'); // Add a new field based on an existing field. $edit = array( @@ -159,12 +159,12 @@ class FieldUITestCase extends DrupalWebTestCase { _field_info_collate_fields(TRUE); // Assert field settings. $field = field_info_field($field_name); - $this->assertTrue($field['settings']['test_field_setting'] == $string, t('Field settings were found.')); + $this->assertTrue($field['settings']['test_field_setting'] == $string, 'Field settings were found.'); // Assert instance and widget settings. $instance = field_info_instance($entity_type, $field_name, $bundle); - $this->assertTrue($instance['settings']['test_instance_setting'] == $string, t('Field instance settings were found.')); - $this->assertTrue($instance['widget']['settings']['test_widget_setting'] == $string, t('Field widget settings were found.')); + $this->assertTrue($instance['settings']['test_instance_setting'] == $string, 'Field instance settings were found.'); + $this->assertTrue($instance['widget']['settings']['test_widget_setting'] == $string, 'Field widget settings were found.'); } /** @@ -190,31 +190,31 @@ class FieldUITestCase extends DrupalWebTestCase { $element_id = "edit-$field_name-$langcode-0-value"; $element_name = "{$field_name}[$langcode][0][value]"; $this->drupalGet($admin_path); - $this->assertFieldById($element_id, '', t('The default value widget was empty.')); + $this->assertFieldById($element_id, '', 'The default value widget was empty.'); // Check that invalid default values are rejected. $edit = array($element_name => '-1'); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("$field_name does not accept the value -1", t('Form vaildation failed.')); + $this->assertText("$field_name does not accept the value -1", 'Form vaildation failed.'); // Check that the default value is saved. $edit = array($element_name => '1'); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("Saved $field_name configuration", t('The form was successfully submitted.')); + $this->assertText("Saved $field_name configuration", 'The form was successfully submitted.'); $instance = field_info_instance('node', $field_name, $this->type); - $this->assertEqual($instance['default_value'], array(array('value' => 1)), t('The default value was correctly saved.')); + $this->assertEqual($instance['default_value'], array(array('value' => 1)), 'The default value was correctly saved.'); // Check that the default value shows up in the form $this->drupalGet($admin_path); - $this->assertFieldById($element_id, '1', t('The default value widget was displayed with the correct value.')); + $this->assertFieldById($element_id, '1', 'The default value widget was displayed with the correct value.'); // Check that the default value can be emptied. $edit = array($element_name => ''); $this->drupalPost(NULL, $edit, t('Save settings')); - $this->assertText("Saved $field_name configuration", t('The form was successfully submitted.')); + $this->assertText("Saved $field_name configuration", 'The form was successfully submitted.'); field_info_cache_clear(); $instance = field_info_instance('node', $field_name, $this->type); - $this->assertEqual($instance['default_value'], NULL, t('The default value was correctly saved.')); + $this->assertEqual($instance['default_value'], NULL, 'The default value was correctly saved.'); } /** @@ -230,7 +230,7 @@ class FieldUITestCase extends DrupalWebTestCase { $this->fieldUIAddNewField($bundle_path1, $edit1); // Create an additional node type. - $type_name2 = strtolower($this->randomName(8)) . '_' .'test'; + $type_name2 = strtolower($this->randomName(8)) . '_' . 'test'; $type2 = $this->drupalCreateContentType(array('name' => $type_name2, 'type' => $type_name2)); $type_name2 = $type2->type; $hyphen_type2 = str_replace('_', '-', $type_name2); @@ -249,9 +249,9 @@ class FieldUITestCase extends DrupalWebTestCase { // Reset the fields info. _field_info_collate_fields(TRUE); // Check that the field instance was deleted. - $this->assertNull(field_info_instance('node', $this->field_name, $this->type), t('Field instance was deleted.')); + $this->assertNull(field_info_instance('node', $this->field_name, $this->type), 'Field instance was deleted.'); // Check that the field was not deleted - $this->assertNotNull(field_info_field($this->field_name), t('Field was not deleted.')); + $this->assertNotNull(field_info_field($this->field_name), 'Field was not deleted.'); // Delete the second instance. $this->fieldUIDeleteField($bundle_path2, $this->field_name, $this->field_label, $type_name2); @@ -259,9 +259,9 @@ class FieldUITestCase extends DrupalWebTestCase { // Reset the fields info. _field_info_collate_fields(TRUE); // Check that the field instance was deleted. - $this->assertNull(field_info_instance('node', $this->field_name, $type_name2), t('Field instance was deleted.')); + $this->assertNull(field_info_instance('node', $this->field_name, $type_name2), 'Field instance was deleted.'); // Check that the field was deleted too. - $this->assertNull(field_info_field($this->field_name), t('Field was deleted.')); + $this->assertNull(field_info_field($this->field_name), 'Field was deleted.'); } /** @@ -272,7 +272,7 @@ class FieldUITestCase extends DrupalWebTestCase { // Check that the field type is not available in the 'add new field' row. $this->drupalGet($bundle_path); - $this->assertFalse($this->xpath('//select[@id="edit--add-new-field-type"]//option[@value="hidden_test_field"]'), t("The 'add new field' select respects field types 'no_ui' property.")); + $this->assertFalse($this->xpath('//select[@id="edit--add-new-field-type"]//option[@value="hidden_test_field"]'), "The 'add new field' select respects field types 'no_ui' property."); // Create a field and an instance programmatically. $field_name = 'hidden_test_field'; @@ -285,18 +285,18 @@ class FieldUITestCase extends DrupalWebTestCase { 'widget_type' => 'test_field_widget', ); field_create_instance($instance); - $this->assertTrue(field_read_instance('node', $field_name, $this->type), t('An instance of the field %field was created programmatically.', array('%field' => $field_name))); + $this->assertTrue(field_read_instance('node', $field_name, $this->type), 'An instance of the field ' . $field_name . ' was created programmatically.'); // Check that the newly added instance appears on the 'Manage Fields' // screen. $this->drupalGet($bundle_path); - $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $instance['label'], t('Field was created and appears in the overview page.')); + $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $instance['label'], 'Field was created and appears in the overview page.'); // Check that the instance does not appear in the 'add existing field' row // on other bundles. $bundle_path = 'admin/structure/types/manage/article/fields/'; $this->drupalGet($bundle_path); - $this->assertFalse($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), t("The 'add existing field' select respects field types 'no_ui' property.")); + $this->assertFalse($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), "The 'add existing field' select respects field types 'no_ui' property."); } /** @@ -324,22 +324,22 @@ class FieldUITestCase extends DrupalWebTestCase { $field_name = $initial_edit['_add_new_field[field_name]']; // First step : 'Add new field' on the 'Manage fields' page. - $this->drupalPost("$bundle_path/fields", $initial_edit, t('Save')); - $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), t('Field settings page was displayed.')); + $this->drupalPost("$bundle_path/fields", $initial_edit, t('Save')); + $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Field settings page was displayed.'); // Second step : 'Field settings' form. $this->drupalPost(NULL, $field_edit, t('Save field settings')); - $this->assertRaw(t('Updated field %label field settings.', array('%label' => $label)), t('Redirected to instance and widget settings page.')); + $this->assertRaw(t('Updated field %label field settings.', array('%label' => $label)), 'Redirected to instance and widget settings page.'); // Assert the field settings are correct. $this->assertFieldSettings($this->type, $this->field_name); // Third step : 'Instance settings' form. $this->drupalPost(NULL, $instance_edit, t('Save settings')); - $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), t('Redirected to "Manage fields" page.')); + $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), 'Redirected to "Manage fields" page.'); // Check that the field appears in the overview form. - $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, t('Field was created and appears in the overview page.')); + $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, 'Field was created and appears in the overview page.'); } /** @@ -367,10 +367,10 @@ class FieldUITestCase extends DrupalWebTestCase { // Second step : 'Instance settings' form. $this->drupalPost(NULL, $instance_edit, t('Save settings')); - $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), t('Redirected to "Manage fields" page.')); + $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), 'Redirected to "Manage fields" page.'); // Check that the field appears in the overview form. - $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, t('Field was created and appears in the overview page.')); + $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, 'Field was created and appears in the overview page.'); } /** @@ -388,13 +388,13 @@ class FieldUITestCase extends DrupalWebTestCase { function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) { // Display confirmation form. $this->drupalGet("$bundle_path/fields/$field_name/delete"); - $this->assertRaw(t('Are you sure you want to delete the field %label', array('%label' => $label)), t('Delete confirmation was found.')); + $this->assertRaw(t('Are you sure you want to delete the field %label', array('%label' => $label)), 'Delete confirmation was found.'); // Submit confirmation form. $this->drupalPost(NULL, array(), t('Delete')); - $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), t('Delete message was found.')); + $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), 'Delete message was found.'); // Check that the field doesn not appear in the overview form - $this->assertNoFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $label, t('Field does not appear in the overview page.')); + $this->assertNoFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $label, 'Field does not appear in the overview page.'); } } diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index 2bf5b7f8631a9bdf1f835eb6072e7f53e3b3b450..f025d05295cdf33bf51f70090b18496cf49da425 100644 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -244,15 +244,15 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($node_file, 'New file saved to disk on node creation.'); // Test file download. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Ensure the edit page has a remove button instead of an upload button. $this->drupalGet("node/$nid/edit"); - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), t('Node with file does not display the "Upload" button.')); - $this->assertFieldByXpath('//input[@type="submit"]', t('Remove'), t('Node with file displays the "Remove" button.')); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), 'Node with file does not display the "Upload" button.'); + $this->assertFieldByXpath('//input[@type="submit"]', 'Remove', 'Node with file displays the "Remove" button.'); // "Click" the remove button (emulating either a nojs or js submission). switch ($type) { @@ -271,13 +271,13 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { } // Ensure the page now has an upload button instead of a remove button. - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After clicking the "Remove" button, it is no longer displayed.')); - $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), t('After clicking the "Remove" button, the "Upload" button is displayed.')); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), 'After clicking the "Remove" button, it is no longer displayed.'); + $this->assertFieldByXpath('//input[@type="submit"]', 'Upload', 'After clicking the "Remove" button, the "Upload" button is displayed.'); // Save the node and ensure it does not have the file. $this->drupalPost(NULL, array(), t('Save')); $node = node_load($nid, NULL, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), t('File was successfully removed from the node.')); + $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), 'File was successfully removed from the node.'); } // Test private download method. @@ -288,18 +288,18 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($node_file, 'New file saved to disk on node creation.'); // Test file download. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); - $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', t('Upload destination setting disabled.')); + $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.'); // Delete node and confirm that setting could be changed. node_delete($nid); $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); - $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', t('Upload destination setting enabled.')); + $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.'); } } @@ -345,25 +345,25 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { $node = node_load($nid, NULL, TRUE); $node_file_r1 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r1 = $node->vid; - $this->assertFileExists($node_file_r1, t('New file saved to disk on node creation.')); - $this->assertFileEntryExists($node_file_r1, t('File entry exists in database on node creation.')); - $this->assertFileIsPermanent($node_file_r1, t('File is permanent.')); + $this->assertFileExists($node_file_r1, 'New file saved to disk on node creation.'); + $this->assertFileEntryExists($node_file_r1, 'File entry exists in database on node creation.'); + $this->assertFileIsPermanent($node_file_r1, 'File is permanent.'); // Upload another file to the same node in a new revision. $this->replaceNodeFile($test_file, $field_name, $nid); $node = node_load($nid, NULL, TRUE); $node_file_r2 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r2 = $node->vid; - $this->assertFileExists($node_file_r2, t('Replacement file exists on disk after creating new revision.')); - $this->assertFileEntryExists($node_file_r2, t('Replacement file entry exists in database after creating new revision.')); - $this->assertFileIsPermanent($node_file_r2, t('Replacement file is permanent.')); + $this->assertFileExists($node_file_r2, 'Replacement file exists on disk after creating new revision.'); + $this->assertFileEntryExists($node_file_r2, 'Replacement file entry exists in database after creating new revision.'); + $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.'); // Check that the original file is still in place on the first revision. $node = node_load($nid, $node_vid_r1, TRUE); - $this->assertEqual($node_file_r1, (object) $node->{$field_name}[LANGUAGE_NONE][0], t('Original file still in place after replacing file in new revision.')); - $this->assertFileExists($node_file_r1, t('Original file still in place after replacing file in new revision.')); - $this->assertFileEntryExists($node_file_r1, t('Original file entry still in place after replacing file in new revision')); - $this->assertFileIsPermanent($node_file_r1, t('Original file is still permanent.')); + $this->assertEqual($node_file_r1, (object) $node->{$field_name}[LANGUAGE_NONE][0], 'Original file still in place after replacing file in new revision.'); + $this->assertFileExists($node_file_r1, 'Original file still in place after replacing file in new revision.'); + $this->assertFileEntryExists($node_file_r1, 'Original file entry still in place after replacing file in new revision'); + $this->assertFileIsPermanent($node_file_r1, 'Original file is still permanent.'); // Save a new version of the node without any changes. // Check that the file is still the same as the previous revision. @@ -371,23 +371,23 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { $node = node_load($nid, NULL, TRUE); $node_file_r3 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r3 = $node->vid; - $this->assertEqual($node_file_r2, $node_file_r3, t('Previous revision file still in place after creating a new revision without a new file.')); - $this->assertFileIsPermanent($node_file_r3, t('New revision file is permanent.')); + $this->assertEqual($node_file_r2, $node_file_r3, 'Previous revision file still in place after creating a new revision without a new file.'); + $this->assertFileIsPermanent($node_file_r3, 'New revision file is permanent.'); // Revert to the first revision and check that the original file is active. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert')); $node = node_load($nid, NULL, TRUE); $node_file_r4 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r4 = $node->vid; - $this->assertEqual($node_file_r1, $node_file_r4, t('Original revision file still in place after reverting to the original revision.')); - $this->assertFileIsPermanent($node_file_r4, t('Original revision file still permanent after reverting to the original revision.')); + $this->assertEqual($node_file_r1, $node_file_r4, 'Original revision file still in place after reverting to the original revision.'); + $this->assertFileIsPermanent($node_file_r4, 'Original revision file still permanent after reverting to the original revision.'); // Delete the second revision and check that the file is kept (since it is // still being used by the third revision). $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting second revision, since it is being used by the third revision.')); + $this->assertFileExists($node_file_r3, 'Second file is still available after deleting second revision, since it is being used by the third revision.'); + $this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting second revision, since it is being used by the third revision.'); + $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting second revision, since it is being used by the third revision.'); // Attach the second file to a user. $user = $this->drupalCreateUser(); @@ -398,9 +398,9 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { // Delete the third revision and check that the file is not deleted yet. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting third revision, since it is being used by the user.')); + $this->assertFileExists($node_file_r3, 'Second file is still available after deleting third revision, since it is being used by the user.'); + $this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting third revision, since it is being used by the user.'); + $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting third revision, since it is being used by the user.'); // Delete the user and check that the file is also deleted. user_delete($user->uid); @@ -408,13 +408,13 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { // not be necessary here. The file really is deleted, but stream wrappers // doesn't seem to think so unless we clear the PHP file stat() cache. clearstatcache(); - $this->assertFileNotExists($node_file_r3, t('Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.')); - $this->assertFileEntryNotExists($node_file_r3, t('Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.')); + $this->assertFileNotExists($node_file_r3, 'Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); + $this->assertFileEntryNotExists($node_file_r3, 'Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); // Delete the entire node and check that the original file is deleted. $this->drupalPost('node/' . $nid . '/delete', array(), t('Delete')); - $this->assertFileNotExists($node_file_r1, t('Original file is deleted after deleting the entire node with two revisions remaining.')); - $this->assertFileEntryNotExists($node_file_r1, t('Original file entry is deleted after deleting the entire node with two revisions remaining.')); + $this->assertFileNotExists($node_file_r1, 'Original file is deleted after deleting the entire node with two revisions remaining.'); + $this->assertFileEntryNotExists($node_file_r1, 'Original file entry is deleted after deleting the entire node with two revisions remaining.'); } } @@ -458,13 +458,13 @@ class FileFieldDisplayTestCase extends FileFieldTestCase { $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $default_output = theme('file_link', array('file' => $node_file)); - $this->assertRaw($default_output, t('Default formatter displaying correctly on full node view.')); + $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.'); // Turn the "display" option off and check that the file is no longer displayed. $edit = array($field_name . '[' . LANGUAGE_NONE . '][0][display]' => FALSE); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); - $this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.')); + $this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.'); } } @@ -500,15 +500,15 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $langcode = LANGUAGE_NONE; $edit = array("title" => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required file field was empty.'); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading to the required field.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required field.')); + $this->assertFileExists($node_file, 'File exists after uploading to the required field.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required field.'); // Try again with a multiple value field. field_delete_field($field_name); @@ -517,14 +517,14 @@ class FileFieldValidateTestCase extends FileFieldTestCase { // Try to post a new node without uploading a file in the multivalue field. $edit = array('title' => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required multiple value file field was empty.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required multiple value file field was empty.'); // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading to the required multiple value field.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required multipel value field.')); + $this->assertFileExists($node_file, 'File exists after uploading to the required multiple value field.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required multipel value field.'); // Remove our file field. field_delete_field($field_name); @@ -559,13 +559,13 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($small_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); + $this->assertFileExists($node_file, 'File exists after uploading a file (' . format_size($small_file->filesize) . ') under the max limit (' . $max_filesize . ').'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file (' . format_size($small_file->filesize) . ') under the max limit (' . $max_filesize . ').'); // Check that uploading the large file fails (1M limit). $nid = $this->uploadNodeFile($large_file, $field_name, $type_name); $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->filesize), '%maxsize' => format_size($file_limit))); - $this->assertRaw($error_message, t('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize))); + $this->assertRaw($error_message, 'Node save failed when file (' . format_size($large_file->filesize) . ') exceeded the max upload size (' . $max_filesize . ').'); } // Turn off the max filesize. @@ -575,8 +575,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($large_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); + $this->assertFileExists($node_file, 'File exists after uploading a file (' . format_size($large_file->filesize) . ') with no max limit.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file (' . format_size($large_file->filesize) . ') with no max limit.'); // Remove our file field. field_delete_field($field_name); @@ -602,8 +602,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file with no extension checking.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with no extension checking.')); + $this->assertFileExists($node_file, 'File exists after uploading a file with no extension checking.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.'); // Enable extension checking for text files. $this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt')); @@ -611,7 +611,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase { // Check that the file with the wrong extension cannot be uploaded. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $error_message = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => 'txt')); - $this->assertRaw($error_message, t('Node save failed when file uploaded with the wrong extension.')); + $this->assertRaw($error_message, 'Node save failed when file uploaded with the wrong extension.'); // Enable extension checking for text and image files. $this->updateFileField($field_name, $type_name, array('file_extensions' => "txt $test_file_extension")); @@ -620,8 +620,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.')); + $this->assertFileExists($node_file, 'File exists after uploading a file with extension checking.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with extension checking.'); // Remove our file field. field_delete_field($field_name); @@ -655,7 +655,7 @@ class FileFieldPathTestCase extends FileFieldTestCase { // Check that the file was uploaded to the file root. $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, 'The file ' . $node_file->uri . ' was uploaded to the correct path.'); // Change the path to contain multiple subdirectories. $field = $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz')); @@ -666,7 +666,7 @@ class FileFieldPathTestCase extends FileFieldTestCase { // Check that the file was uploaded into the subdirectory. $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, 'The file ' . $node_file->uri . ' was uploaded to the correct path.'); // Check the path when used with tokens. // Change the path to contain multiple token directories. @@ -680,7 +680,7 @@ class FileFieldPathTestCase extends FileFieldTestCase { $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $data = array('user' => $this->admin_user); $subdirectory = token_replace('[user:uid]/[user:name]', $data); - $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, 'The file ' . $node_file->uri . ' was uploaded to the correct path with token replacements.'); } /** @@ -760,11 +760,11 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { $tests['[file:owner:uid]'] = $file->uid; // Test to make sure that we generated something for each token. - $this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.')); + $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized file token %token replaced.', array('%token' => $input))); + $this->assertFalse(strcmp($output, $expected), 'Sanitized file token ' . $input . ' replaced.'); } // Generate and test unsanitized tokens. @@ -776,7 +776,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized file token %token replaced.', array('%token' => $input))); + $this->assertFalse(strcmp($output, $expected), 'Unsanitized file token ' . $input . ' replaced.'); } } } diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 973a0b77913ba73f779082a3da71836850b47fb4..fdee75de6dccf7d44ce77228e60417172ffd361d 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -60,11 +60,11 @@ class FilterCRUDTestCase extends DrupalWebTestCase { // Delete the text format. filter_format_delete($format); $db_format = db_query("SELECT * FROM {filter_format} WHERE format = :format", array(':format' => $format->format))->fetchObject(); - $this->assertFalse($db_format, t('Database: Deleted text format no longer exists.')); + $this->assertFalse($db_format, 'Database: Deleted text format no longer exists.'); $db_filters = db_query("SELECT * FROM {filter} WHERE format = :format", array(':format' => $format->format))->fetchObject(); - $this->assertFalse($db_filters, t('Database: Filters for deleted text format no longer exist.')); + $this->assertFalse($db_filters, 'Database: Filters for deleted text format no longer exist.'); $formats = filter_formats(); - $this->assertTrue(!isset($formats[$format->format]), t('filter_formats: Deleted text format no longer exists.')); + $this->assertTrue(!isset($formats[$format->format]), 'filter_formats: Deleted text format no longer exists.'); } /** @@ -78,17 +78,17 @@ class FilterCRUDTestCase extends DrupalWebTestCase { ->condition('format', $format->format) ->execute() ->fetchObject(); - $this->assertEqual($db_format->format, $format->format, t('Database: Proper format id for text format %format.', $t_args)); - $this->assertEqual($db_format->name, $format->name, t('Database: Proper title for text format %format.', $t_args)); - $this->assertEqual($db_format->cache, $format->cache, t('Database: Proper cache indicator for text format %format.', $t_args)); - $this->assertEqual($db_format->weight, $format->weight, t('Database: Proper weight for text format %format.', $t_args)); + $this->assertEqual($db_format->format, $format->format, 'Database: Proper format id for text format ' . $t_args['%format'] . '.'); + $this->assertEqual($db_format->name, $format->name, 'Database: Proper title for text format ' . $t_args['%format'] . '.'); + $this->assertEqual($db_format->cache, $format->cache, 'Database: Proper cache indicator for text format ' . $t_args['%format'] . '.'); + $this->assertEqual($db_format->weight, $format->weight, 'Database: Proper weight for text format ' . $t_args['%format'] . '.'); // Verify filter_format_load(). $filter_format = filter_format_load($format->format); - $this->assertEqual($filter_format->format, $format->format, t('filter_format_load: Proper format id for text format %format.', $t_args)); - $this->assertEqual($filter_format->name, $format->name, t('filter_format_load: Proper title for text format %format.', $t_args)); - $this->assertEqual($filter_format->cache, $format->cache, t('filter_format_load: Proper cache indicator for text format %format.', $t_args)); - $this->assertEqual($filter_format->weight, $format->weight, t('filter_format_load: Proper weight for text format %format.', $t_args)); + $this->assertEqual($filter_format->format, $format->format, 'filter_format_load: Proper format id for text format ' . $t_args['%format'] . '.'); + $this->assertEqual($filter_format->name, $format->name, 'filter_format_load: Proper title for text format ' . $t_args['%format'] . '.'); + $this->assertEqual($filter_format->cache, $format->cache, 'filter_format_load: Proper cache indicator for text format ' . $t_args['%format'] . '.'); + $this->assertEqual($filter_format->weight, $format->weight, 'filter_format_load: Proper weight for text format ' . $t_args['%format'] . '.'); // Verify the 'cache' text format property according to enabled filters. $filter_info = filter_get_filters(); @@ -102,7 +102,7 @@ class FilterCRUDTestCase extends DrupalWebTestCase { break; } } - $this->assertEqual($filter_format->cache, $cacheable, t('Text format contains proper cache property.')); + $this->assertEqual($filter_format->cache, $cacheable, 'Text format contains proper cache property.'); } /** @@ -116,20 +116,20 @@ class FilterCRUDTestCase extends DrupalWebTestCase { $t_args = array('%format' => $format->name, '%filter' => $name); // Verify that filter status is properly stored. - $this->assertEqual($filter->status, $format_filters[$name]['status'], t('Database: Proper status for %filter in text format %format.', $t_args)); + $this->assertEqual($filter->status, $format_filters[$name]['status'], 'Database: Proper status for ' . $t_args['%filter'] . ' in text format ' . $t_args['%format'] . '.'); // Verify that filter settings were properly stored. - $this->assertEqual(unserialize($filter->settings), isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), t('Database: Proper filter settings for %filter in text format %format.', $t_args)); + $this->assertEqual(unserialize($filter->settings), isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), 'Database: Proper filter settings for ' . $t_args['%filter'] . ' in text format ' . $t_args['%format'] . '.'); // Verify that each filter has a module name assigned. - $this->assertTrue(!empty($filter->module), t('Database: Proper module name for %filter in text format %format.', $t_args)); + $this->assertTrue(!empty($filter->module), 'Database: Proper module name for ' . $t_args['%filter'] . ' in text format ' . $t_args['%format'] . '.'); // Remove the filter from the copy of saved $format to check whether all // filters have been processed later. unset($format_filters[$name]); } // Verify that all filters have been processed. - $this->assertTrue(empty($format_filters), t('Database contains values for all filters in the saved format.')); + $this->assertTrue(empty($format_filters), 'Database contains values for all filters in the saved format.'); // Verify filter_list_format(). $filters = filter_list_format($format->format); @@ -138,20 +138,20 @@ class FilterCRUDTestCase extends DrupalWebTestCase { $t_args = array('%format' => $format->name, '%filter' => $name); // Verify that filter status is properly stored. - $this->assertEqual($filter->status, $format_filters[$name]['status'], t('filter_list_format: Proper status for %filter in text format %format.', $t_args)); + $this->assertEqual($filter->status, $format_filters[$name]['status'], 'filter_list_format: Proper status for ' . $t_args['%filter'] . ' in text format ' . $t_args['%format'] . '.'); // Verify that filter settings were properly stored. - $this->assertEqual($filter->settings, isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), t('filter_list_format: Proper filter settings for %filter in text format %format.', $t_args)); + $this->assertEqual($filter->settings, isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), 'filter_list_format: Proper filter settings for ' . $t_args['%filter'] . ' in text format ' . $t_args['%format'] . '.'); // Verify that each filter has a module name assigned. - $this->assertTrue(!empty($filter->module), t('filter_list_format: Proper module name for %filter in text format %format.', $t_args)); + $this->assertTrue(!empty($filter->module), 'filter_list_format: Proper module name for ' . $t_args['%filter'] . ' in text format ' . $t_args['%format'] . '.'); // Remove the filter from the copy of saved $format to check whether all // filters have been processed later. unset($format_filters[$name]); } // Verify that all filters have been processed. - $this->assertTrue(empty($format_filters), t('filter_list_format: Loaded filters contain values for all filters in the saved format.')); + $this->assertTrue(empty($format_filters), 'filter_list_format: Loaded filters contain values for all filters in the saved format.'); } } @@ -204,7 +204,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Verify that deleted text format no longer exists. $this->drupalGet('admin/config/content/formats/' . $format->format); - $this->assertResponse(404, t('Deleted text format no longer exists.')); + $this->assertResponse(404, 'Deleted text format no longer exists.'); } /** @@ -219,44 +219,44 @@ class FilterAdminTestCase extends DrupalWebTestCase { list($filtered, $full, $plain) = $this->checkFilterFormats(); // Check that the fallback format exists and cannot be deleted. - $this->assertTrue(!empty($plain) && $plain == filter_fallback_format(), t('The fallback format is set to plain text.')); + $this->assertTrue(!empty($plain) && $plain == filter_fallback_format(), 'The fallback format is set to plain text.'); $this->drupalGet('admin/config/content/formats'); - $this->assertNoRaw('admin/config/content/formats/' . $plain . '/delete', t('Delete link for the fallback format not found.')); + $this->assertNoRaw('admin/config/content/formats/' . $plain . '/delete', 'Delete link for the fallback format not found.'); $this->drupalGet('admin/config/content/formats/' . $plain . '/delete'); - $this->assertResponse(403, t('The fallback format cannot be deleted.')); + $this->assertResponse(403, 'The fallback format cannot be deleted.'); // Verify access permissions to Full HTML format. - $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), t('Admin user may use Full HTML.')); - $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), t('Web user may not use Full HTML.')); + $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), 'Admin user may use Full HTML.'); + $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), 'Web user may not use Full HTML.'); // Add an additional tag. $edit = array(); $edit['filters[filter_html][settings][allowed_html]'] = '