From 3d3395d1b167866926fee89c02404114781777ef Mon Sep 17 00:00:00 2001
From: Marco Villegas <marvil07@gmail.com>
Date: Fri, 22 Oct 2010 03:51:47 -0500
Subject: [PATCH] debugging and fix the 2nd param passed to VersioncontrolEntityController::load() at testAddRepository()

Notice that there is a problem at the defaultPrefix on the query object
generated, it is empty instead of being the one selected by simpletest.

A dbtng problem?
---
 includes/controllers.inc                           |    6 ++++++
 ...VersioncontrolRepositoryManagementTestCase.test |    5 ++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git includes/controllers.inc includes/controllers.inc
index 48ff0ff..d3b706c 100644
--- includes/controllers.inc
+++ includes/controllers.inc
@@ -109,7 +109,9 @@ abstract class VersioncontrolEntityController {
     if ($ids === FALSE || $ids || ($conditions && !$passed_ids)) {
       // Build the query.
       $query = $this->buildQuery($ids, $conditions);
+      debug($query);
       $queried_entities = $this->executeQuery($query);
+      debug($queried_entities);
     }
 
     if (!empty($queried_entities)) {
@@ -221,6 +223,7 @@ abstract class VersioncontrolEntityController {
     }
     // If provided, attach generic conditions.
     if ($conditions) {
+      debug($conditions);
       foreach ($conditions as $field => $value) {
         $this->attachCondition($query, $field, $value);
       }
@@ -238,6 +241,9 @@ abstract class VersioncontrolEntityController {
   protected function attachCondition(&$query, $field, $value, $alias = 'base') {
     // If a condition value uses this special structure, we know the
     // requestor wants to do a complex condition with operator control.
+    debug($field);
+    debug($value);
+    debug($alias);
     if (is_array($value) && isset($value['values']) && isset($value['operator'])) {
       $query->condition("$alias.$field", $value['values'], $value['operator']);
     }
diff --git tests/VersioncontrolRepositoryManagementTestCase.test tests/VersioncontrolRepositoryManagementTestCase.test
index 750e84c..173145d 100644
--- tests/VersioncontrolRepositoryManagementTestCase.test
+++ tests/VersioncontrolRepositoryManagementTestCase.test
@@ -51,7 +51,10 @@ 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 = $this->controller->load(array(), array('name' => array($edit['repo_name'])));
+    $found_repositories = $this->controller->load(array(), array('name' => $edit['repo_name']));
+    debug($found_repositories);
+    $rid = db_result(db_query("SELECT repo_id FROM {versioncontrol_repositories} WHERE name = '%s'", $edit['repo_name']));
+    debug($rid);
     $this->assertTrue(count($found_repositories)==1, t('Repository found in database.'));
   }
 
-- 
1.7.1

