Commit 25171a17 authored by webchick's avatar webchick

Reverting #500866. Needs more discussion.

parent cacd044a
This diff is collapsed.
This diff is collapsed.
......@@ -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', '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');
$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'));
}
/**
......@@ -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', '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');
$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'));
}
/**
......@@ -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, 'Number of recent blog posts changed.');
$this->assertEqual(variable_get('blog_block_count', 10), 5, t('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'), 'Blog help node was displayed');
$this->assertText(t('Blog'), 'Blog help node was displayed');
$this->assertTitle(t('Blog | Drupal'), t('Blog help node was displayed'));
$this->assertText(t('Blog'), t('Blog help node was displayed'));
}
// Verify the blog block was displayed.
$this->drupalGet('');
$this->assertResponse(200);
$this->assertText(t('Recent blog posts'), 'Blog block was displayed');
$this->assertText(t('Recent blog posts'), t('Blog block was displayed'));
// View blog node.
$this->drupalGet('node/' . $node->nid);
$this->assertResponse(200);
$this->assertTitle($node->title . ' | Drupal', 'Blog node was displayed');
$this->assertTitle($node->title . ' | Drupal', t('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)), 'Breadcrumbs were displayed');
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), t('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', 'Blog edit node was displayed');
$this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', t('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"])), 'Blog node was edited');
$this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), t('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"])), 'Blog node was deleted');
$this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), t('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'), 'View recent blog entries link was displayed');
$this->assertText(t('View recent blog entries'), t('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))), 'View recent blog entries link target was correct');
$this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), t('View recent blog entries link target was correct'));
// Confirm a blog page was displayed.
$this->drupalGet('blog');
$this->assertResponse(200);
$this->assertTitle('Blogs | Drupal', 'Blog page was displayed');
$this->assertText(t('Home'), 'Breadcrumbs were displayed');
$this->assertTitle('Blogs | Drupal', t('Blog page was displayed'));
$this->assertText(t('Home'), t('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))), 'User blog node was displayed');
$this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), t('User blog node was displayed'));
// Confirm a blog feed was displayed.
$this->drupalGet('blog/feed');
$this->assertTitle(t('Drupal blogs'), 'Blog feed was displayed');
$this->assertTitle(t('Drupal blogs'), t('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))), 'User blog feed was displayed');
$this->assertTitle(t("@name's blog", array('@name' => format_username($user))), t('User blog feed was displayed'));
}
}
......@@ -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), 'Node ' . $number . ' outline confirmed.');
$this->assertPattern($this->generateOutlinePattern($nodes), t('Node ' . $number . ' outline confirmed.'));
}
else {
$this->pass('Node ' . $number . ' doesn\'t have outline.');
$this->pass(t('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')))), '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')))), t('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')))), 'Up page link found.');
$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.'));
}
if ($next) {
$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.');
$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.'));
}
// Compute the expected breadcrumb.
......@@ -153,12 +153,12 @@ class BookTestCase extends DrupalWebTestCase {
}
// Compare expected and got breadcrumbs.
$this->assertIdentical($expected_breadcrumb, $got_breadcrumb, 'The breadcrumb is correctly displayed on the page.');
$this->assertIdentical($expected_breadcrumb, $got_breadcrumb, t('The breadcrumb is correctly displayed on the page.'));
// Check printer friendly version.
$this->drupalGet('book/export/html/' . $node->nid);
$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.');
$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.'));
$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), 'Book node found in database.');
$this->assertNotNull(($node === FALSE ? NULL : $node), t('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, '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.');
$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.'));
}
// Make sure we can't export an unsupported format.
$this->drupalGet('book/export/foobar/' . $this->book->nid);
$this->assertResponse('404', 'Unsupported export format returned "not found".');
$this->assertResponse('404', t('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'), 'Anonymous user is not shown link to printer-friendly version.');
$this->assertNoLink(t('Printer-friendly version'), t('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', 'Anonymous user properly forbidden.');
$this->assertResponse('403', t('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.'), 'Block configuration set.');
$this->assertText(t('The block configuration has been saved.'), t('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.'), 'Block successfully move to footer region.');
$this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -47,14 +47,14 @@ class DashboardAccessTestCase extends DrupalWebTestCase {
// Ensure admin access.
$this->drupalGet('admin');
$this->assertResponse(200, 'Admin has access to the dashboard.');
$this->assertRaw($custom_block['title'], 'Admin has access to a dashboard block.');
$this->assertResponse(200, t('Admin has access to the dashboard.'));
$this->assertRaw($custom_block['title'], t('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, 'Non-admin has no access to the dashboard.');
$this->assertNoText($custom_block['title'], 'Non-admin has no access to a dashboard block.');
$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.'));
}
}
......@@ -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, '[Cache] Row limit variable of ' . $current_limit . ' equals row limit of ' . $row_limit);
$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)));
// 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, '[Variable table] Row limit variable of ' . $current_limit . ' equals row limit of ' . $row_limit);
$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)));
}
/**
......@@ -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, 'Dblog row count of ' . $count . ' exceeds row limit of ' . $row_limit);
$this->assertTrue($count > $row_limit, t('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $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, 'Dblog row count of ' . $count . ' equals row limit of ' . $row_limit . ' plus one');
$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)));
}
/**
......@@ -125,35 +125,35 @@ class DBLogTestCase extends DrupalWebTestCase {
$this->drupalGet('admin/help/dblog');
$this->assertResponse($response);
if ($response == 200) {
$this->assertText(t('Database logging'), 'DBLog help was displayed');
$this->assertText(t('Database logging'), t('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'), 'DBLog report was displayed');
$this->assertText(t('Recent log entries'), t('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'), 'DBLog page-not-found report was displayed');
$this->assertText(t('Top ' . $quote . 'page not found' . $quote . ' errors'), t('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'), 'DBLog access-denied report was displayed');
$this->assertText(t('Top ' . $quote . 'access denied' . $quote . ' errors'), t('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'), 'DBLog event node was displayed');
$this->assertText(t('Details'), t('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, 'User ' . $name . ' was loaded');
$this->assertTrue($user != NULL, t('User @name was loaded', array('@name' => $name)));
$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, 'DBLog contains ' . $count_before . ' records for ' . $user->name);
$this->assertTrue($count_before > 0, t('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $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, 'DBLog event details was found: [delete user]');
$this->assertRaw($message, t('DBLog event details was found: [delete user]'));
break;
}
}
}
$this->assertTrue($link, 'DBLog event was recorded: [delete user]');
$this->assertTrue($link, t('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, 'DBLog event was recorded: [page not found]');
$this->assertText($not_found_url, t('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, 'Node ' . $title . ' was loaded');
$this->assertTrue($node != NULL, t('Node @title was loaded', array('@title' => $title)));
// 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'), 'DBLog event was recorded: [access denied]');
$this->assertText(t('admin/reports/dblog'), t('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)), 'DBLog event was recorded: [page not found]');
$this->assertText(t('node/@nid', array('@nid' => $node->nid)), t('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(), 'dblog_watchdog() added an entry to the dblog ' . $count);
$this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), t('dblog_watchdog() added an entry to the dblog :count', array(':count' => $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, 'DBLog contains ' . $count . ' records after a clear.');
$this->assertEqual($count, 0, t('DBLog contains :count records after a clear.', array(':count' => $count)));
}
/**
......
......@@ -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'], "Value $delta is inserted correctly");
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("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'], "Value $delta is updated correctly");
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("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'], "Update with no field_name entry leaves value $delta untouched");
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("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, "Update with an empty field_name entry empties the field.");
$this->assertEqual(count($rows), 0, t("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('Cannot update field schema with data.');
$this->fail(t('Cannot update field schema with data.'));
}
catch (FieldException $e) {
$this->pass('Cannot update field schema with data.');
$this->pass(t('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'), "No index named value exists in $table");
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), "No index named value_format exists in $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"));
}
// 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"), "Index on value created in $table");
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("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"), "Index on value_format created in $table");
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), "Index on value removed in $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"));
}
// 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', "Index changes performed without dropping the tables");
$this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', t("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']), 'The storage type is SQL.');
$this->assertTrue(array_key_exists('sql', $field['storage']['details']), t('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]), '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.');
$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.'));
// 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, '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 . '.');
$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)));
}
}
}
......@@ -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]), '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');
$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'));
// 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]), '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');
$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'));
// 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]), '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');
$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'));
// 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]), 'Option 1 exists');
$this->assertTrue(!empty($form[$this