function NotificationsTestCase::assertTableRows in Notifications 6.2
Same name and namespace in other branches
- 6.3 tests/notifications_test_case.inc \NotificationsTestCase::assertTableRows()
2 calls to NotificationsTestCase::assertTableRows()
- NotificationsLiteTests::testNotificationsLite in tests/
notifications_lite.test - Test simple sending cases
- NotificationsTestCase::assertUserRows in tests/
notifications_test_case.inc
File
- tests/
notifications_test_case.inc, line 34 - Base class for Notifications Tests
Class
- NotificationsTestCase
- @file Base class for Notifications Tests
Code
function assertTableRows($table, $target, $conditions = NULL, $message = NULL) {
$sql = 'SELECT COUNT(*) FROM {' . $table . '}';
if ($conditions) {
foreach ($conditions as $field => $value) {
$where[] = "{$field} = '%s'";
$print[] = "{$field}={$value}";
}
}
if (!empty($where)) {
$sql .= ' WHERE ' . implode(' AND ', $where);
}
$count = db_result(db_query($sql, $conditions));
$message = $message ? $message : 'Right number of rows in table ' . $table . '[' . implode(', ', $print) . ']=' . $target;
$message .= " ({$count})";
$this
->assertEqual($count, $target, $message);
}