Skip to content

Commit

Permalink
let VersioncontrolRepositoryManagementTestCase 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 71d85b7 commit d7f9363
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 7 additions & 3 deletions tests/VersioncontrolRepositoryManagementTestCase.test
Expand Up @@ -2,6 +2,7 @@
class VersioncontrolRepositoryManagementTestCase extends DrupalWebTestCase {

protected $admin_user;
public $repoCache;

/**
* Implementation of getInfo().
Expand All @@ -24,6 +25,9 @@ class VersioncontrolRepositoryManagementTestCase extends DrupalWebTestCase {
// Create and login the admin user
$this->admin_user = $this->drupalCreateUser(array('administer version control systems'));
$this->drupalLogin($this->admin_user);

// repository cache
$this->repoCache = VersioncontrolRepositoryCache::getInstance();
}

public function testAddRepository() {
Expand All @@ -40,7 +44,7 @@ class VersioncontrolRepositoryManagementTestCase extends DrupalWebTestCase {

// Confirm that the repository has been created, and then query the repo name.
$this->assertRaw(t('The %repository repository has been added.', array('%repository' => $edit['repo_name'])), t('Repository successfully created.'));
$found_repositories = VersioncontrolRepository::getRepositories( array('names' => array($edit['repo_name'])) );
$found_repositories = $this->repoCache->getRepositories( array('names' => array($edit['repo_name'])) );
$this->assertTrue(count($found_repositories)==1, t('Repository found in database.'));
}

Expand All @@ -55,7 +59,7 @@ class VersioncontrolRepositoryManagementTestCase extends DrupalWebTestCase {

// confirm that the repository has been deleted, and then query the repo name.
$this->assertRaw(t('The %repository repository has been deleted.', array('%repository' => $edit['repo_name'])), t('Repository successfully deleted.'));
$found_repositories = VersioncontrolRepository::getRepositories( array('names' => array($edit['repo_name'])) );
$found_repositories = $this->repoCache->getRepositories( array('names' => array($edit['repo_name'])) );
$this->assertTrue(count($found_repositories)==0, t('Repository not found in database.'));
}

Expand All @@ -77,7 +81,7 @@ class VersioncontrolRepositoryManagementTestCase extends DrupalWebTestCase {
// confirm that the repository has been edited, and then query the repo root
//TODO do i need to validate all fields?
$this->assertRaw(t('The %repository repository has been updated.', array('%repository' => $edit['repo_name'])), t('Repository successfully updated.'));
$found_repositories = VersioncontrolRepository::getRepositories( array('names' => array($edit['repo_name'])) );
$found_repositories = $this->repoCache->getRepositories( array('names' => array($edit['repo_name'])) );
if ($is_repo_edited = (count($found_repositories)==1)) {
$edited_repo = array_shift($found_repositories);
$is_repo_edited = $edited_repo['root'] == $edit['root'];
Expand Down
13 changes: 12 additions & 1 deletion versioncontrol.admin.inc
Expand Up @@ -841,7 +841,18 @@ function versioncontrol_admin_repository_edit_submit($form, &$form_state) {
$repository->authorization_method = $form_state['values']['authorization_method'];
}
else {
$repository = new VersioncontrolRepository(null, $form_state['values']['repo_name'], $form['#vcs'], $form_state['values']['root'], $form_state['values']['authorization_method'], 'versioncontrol_default_urls', $repository_urls); // url_backend hardcoded for now
$backends = versioncontrol_get_backends();
//$repository = new VersioncontrolRepository(null, $form_state['values']['repo_name'], $form['#vcs'], $form_state['values']['root'], $form_state['values']['authorization_method'], 'versioncontrol_default_urls', $repository_urls); // url_backend hardcoded for now
$repository = array(
'name' => $form_state['values']['repo_name'],
'vcs' => $form['#vcs'],
'root' => $form_state['values']['root'],
'authorization_method' => $form_state['values']['authorization_method'],
'url_backend' => 'versioncontrol_default_urls', // url_backend hardcoded for now
'urls' => $repository_urls,
'backend' => $backends[$form['#vcs']],
);
$repository = new $backends[$form['#vcs']]->classes['repo'](null, $repository, FALSE);
}

// We also provide a 'data' array where other modules can put their own
Expand Down

0 comments on commit d7f9363

Please sign in to comment.