[APPDB] Updated test_appData

Alexandru Băluț alexandru.balut at gmail.com
Mon Jun 21 13:52:20 CDT 2010


Updated test_appData, because using downloadurl objects does not work
anymore, because appData.listSubmittedBy() ignores queued downloadurls.
I also fixed a bug in url.php: after creating an Url, the create function
does not update the object properly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20100621/d602ffd4/attachment.htm>
-------------- next part --------------

---
 include/url.php            |   11 +++++---
 unit_test/test_appData.php |   65 ++++++++++++++++++++++++-------------------
 2 files changed, 43 insertions(+), 33 deletions(-)

diff --git a/include/url.php b/include/url.php
index 0419168..58eac2f 100644
--- a/include/url.php
+++ b/include/url.php
@@ -5,7 +5,10 @@
 require_once(BASE."include/util.php");
 
 /**
- * Url class for handling urls
+ * Class for handling URLs (aka Links) of applications and
+ * of application versions.
+ * 
+ * Uses the appData table to store the URLs in rows with type='url'.
  */
 class Url {
     var $iUrlId;
@@ -33,6 +36,8 @@ class Url {
                        WHERE type = 'url'
                        AND id = '?'";
             $hResult = query_parameters($sQuery, $iUrlId);
+            if(!$hResult)
+                return;
             $oRow = query_fetch_object($hResult);
         }
 
@@ -57,8 +62,6 @@ class Url {
     function create($sDescription = null, $sUrl = null, $iVersionId = null,
                     $iAppId = null, $bSilent = false)
     {
-        global $aClean;
-
         // Security, if we are not an administrator or a maintainer, the url must be queued.
         if(($iAppId && !url::canEdit(NULL, $iAppId)) ||
         ($iVersionId && !url::canEdit($iVersionId)))
@@ -78,7 +81,7 @@ class Url {
         }
 
         $this->iUrlId = query_appdb_insert_id();
-        $this->url($this->iUrlId,$this->bQueued);
+        $this->Url($this->iUrlId);
 
         if(!$bSilent)
             $this->SendNotificationMail();
diff --git a/unit_test/test_appData.php b/unit_test/test_appData.php
index 335a642..2772d4d 100644
--- a/unit_test/test_appData.php
+++ b/unit_test/test_appData.php
@@ -3,7 +3,7 @@
 require_once("path.php");
 require_once("test_common.php");
 require_once(BASE."include/appData.php");
-require_once(BASE."include/downloadurl.php");
+require_once(BASE."include/url.php");
 
 function test_appData_listSubmittedBy()
 {
@@ -19,38 +19,45 @@ function test_appData_listSubmittedBy()
         return FALSE;
     }
 
-    /* Create a queued appData entry */
-    $oDownloadUrl = new downloadurl;
-
-    $oDownloadUrl->sUrl = "http://www.microsoft.com/windowsmedia";
-    $oDownloadUrl->sDescription = "Download Meida Player";
-    $oDownloadUrl->iVersionId = 1;
-
-    $oDownloadUrl->create();
-
-    $shReturn = appData::listSubmittedBy($oUser->iUserId, true);
-
-    /* This is needed for deleting the entry */
-    $oUser->addPriv("admin");
-
-    /* There should be two lines; one header and one for the downloadurl */
-    $iExpected = 2;
-    $iReceived = substr_count($shReturn, "</tr>");
-    if($iExpected != $iReceived)
+    /* Create a queued Url, which will be stored in the appData table */
+    $oUrl = new Url;
+    $bResult = $oUrl->create($sDescription="test description", $sUrl="http://testurl", $bSilent=true);
+    if(!$bResult)
     {
-        error("Got $iReceived rows instead of $iExpected.");
         $bSuccess = false;
-    }
-
-    /* Clean up */
-    if(!$oDownloadUrl->purge())
+        error("Failed to create Url");
+    } else
     {
-        $bSuccess = false;
-        error("Failed to delete oDownloadUrl!");
+        $shReturn = appData::listSubmittedBy($oUser->iUserId, true);
+        if(!$shReturn)
+        {
+            $bSuccess = false;
+            error("Got empty list.");
+        } else
+        {
+            /* There should be two lines; one header and one for the linked data */
+            $iExpected = 2;
+            $iReceived = substr_count($shReturn, "</tr>");
+            if($iExpected != $iReceived)
+            {
+                error("Got $iReceived rows instead of $iExpected.");
+                $bSuccess = false;
+            }
+        }
+    
+        /* Clean up */
+        /* This is needed for deleting the entry */
+        $oUser->addPriv("admin");
+    
+        if(!$oUrl->purge())
+        {
+            $bSuccess = false;
+            error("Failed to delete oUrl!");
+        }
+    
+        $oUser->delete();
     }
-
-    $oUser->delete();
-
+    
     return $bSuccess;
 }
 
-- 
1.7.0.4


More information about the wine-patches mailing list