Skip to content

Commit

Permalink
let VersioncontrolAccountStatusTestCase work again
Browse files Browse the repository at this point in the history
mainly following new repo cache class and how repo class constructor now behaves
  • Loading branch information
marvil07 committed Jul 22, 2009
1 parent d7f9363 commit 37d74ac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion includes/VersioncontrolAccount.php
Expand Up @@ -150,7 +150,9 @@ public static function getAccounts($constraints = array(), $include_unauthorized
$repo_ids = array();
while ($account = db_fetch_object($result)) {
$repo_ids[] = $account->repo_id;
$account_rows[] = new VersioncontrolAccount($account->username, $account->uid, new VersioncontrolRepository($account->repo_id));
$min_repo = new stdClass(); // full object is retrieved some lines down
$min_repo->repo_id = $account->repo_id;
$account_rows[] = new VersioncontrolAccount($account->username, $account->uid, $min_repo);
}
if (empty($repo_ids)) {
return array();
Expand Down
7 changes: 3 additions & 4 deletions versioncontrol.module
Expand Up @@ -355,8 +355,8 @@ function versioncontrol_private_account_access($vcs_accounts, $account = NULL) {
function versioncontrol_user_accounts_title_callback($accounts) {
$usernames = array();
foreach ($accounts as $uid => $user_accounts) {
foreach ($user_accounts as $repo_id => $username) {
$usernames[] = $username;
foreach ($user_accounts as $repo_id => $account) {
$usernames[] = $account->vcs_username;
}
}
$repositories = VersioncontrolRepositoryCache::getInstance()->getRepositories(array(
Expand All @@ -367,8 +367,7 @@ function versioncontrol_user_accounts_title_callback($accounts) {
$vcses[$repository['vcs']] = TRUE;
}
if (count($vcses) == 1) {
$repo = array_shift($vcses);
$vcs = key($vcses);
$repo = array_shift($repositories);
return check_plain($repo->backend->name);
}
return t('Repository accounts');
Expand Down
Expand Up @@ -709,7 +709,7 @@ function versioncontrol_account_status_form_alter_account_edit(&$form, $status_d
$form['#send_application_mails'] = TRUE;

if (!isset($form['overview'])) {
$repository = VersioncontrolRepository::getRepository($status_data['repo_id']);
$repository = VersioncontrolRepositoryCache::getInstance()->getRepository($status_data['repo_id']);
$registration_message = isset($repository['data']['versioncontrol']['registration_message'])
? $repository['data']['versioncontrol']['registration_message']
: '';
Expand Down Expand Up @@ -972,7 +972,7 @@ function _versioncontrol_account_status_send_application_mails($status_data, $is

$params = array(
'applicant_user' => $applicant,
'repository' => VersioncontrolRepository::getRepository($status_data['repo_id']),
'repository' => VersioncontrolRepositoryCache::getInstance()->getRepository($status_data['repo_id']),
'motivation_message' => $status_data['motivation'],
'status' => $status_data['status'],
'is_reapplication' => $is_reapplication,
Expand Down Expand Up @@ -1009,7 +1009,7 @@ function _versioncontrol_account_status_send_status_update_mails($status_data, $
$params = array(
'admin_user' => drupal_clone($user),
'applicant_user' => $applicant,
'repository' => VersioncontrolRepository::getRepository($status_data['repo_id']),
'repository' => VersioncontrolRepositoryCache::getInstance()->getRepository($status_data['repo_id']),
'admin_message' => $admin_message,
'status' => $status_data['status'],
);
Expand Down
Expand Up @@ -3,6 +3,7 @@ class VersioncontrolAccountStatusTestCase extends DrupalWebTestCase {

protected $admin_user;
protected $basic_user;
protected $repoCache;

/**
* Implementation of getInfo().
Expand All @@ -26,6 +27,8 @@ class VersioncontrolAccountStatusTestCase extends DrupalWebTestCase {
$this->admin_user = $this->drupalCreateUser(array('administer version control systems'));
$this->basic_user = $this->drupalCreateUser(array('use version control systems'));

$this->repoCache = VersioncontrolRepositoryCache::getInstance();

// Temporarily change the 'smtp_library' and implement drupal_mail_wrapper()
// Make sure our drupal_mail_wrapper function is called instead of the
// default mail handler.
Expand All @@ -51,7 +54,7 @@ class VersioncontrolAccountStatusTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/project/versioncontrol-repositories/add-test', $repo_edit, t('Save repository'));

// get the created repo
$found_repositories = VersioncontrolRepository::getRepositories( array('names' => array($repo_edit['repo_name'])) );
$found_repositories = $this->repoCache->getRepositories( array('names' => array($repo_edit['repo_name'])) );
$repo = array_shift($found_repositories);
$this->assertTrue(!is_null($repo), t('Repository found in database.'));

Expand Down

0 comments on commit 37d74ac

Please sign in to comment.