fixed tests, added possibility to edit multiple plants
authorSven Hecht <sven@sven-laptop.(none)>
Fri, 26 Jun 2009 18:55:52 +0000 (20:55 +0200)
committerSven Hecht <sven@sven-laptop.(none)>
Fri, 26 Jun 2009 18:55:52 +0000 (20:55 +0200)
web/index.php [changed mode: 0644->0755]
web/js/communication.js
web/php-tests/BuisnessLogicTest.php
web/php/Database.php
web/php/Plant.php

old mode 100644 (file)
new mode 100755 (executable)
index 2573367..68d5577 100644 (file)
@@ -393,7 +393,7 @@ Lseed.Communication = function() {
                var cmp = Ext.getCmp('contentTabPanel');
                if (cmp) {
                        var tab = this.getTab(tabname);
-                       if (tab) {
+                       if (!tab) {
                                console.error("Lseed.Communication.closeTab: '"+tabname+"' does not exist.");
                        }
                        cmp.remove(tab);
@@ -406,7 +406,7 @@ Lseed.Communication = function() {
                var cmp = Ext.getCmp("contentTabPanel");
                if (cmp) {
                        cmp.add(content);
-                       this.activateTab(name)
+                       this.activateTab(name);
                } else {
                        console.error("Lseed.Communication.showTab: 'contentTabPanel' does not exist.");
                }
@@ -564,8 +564,14 @@ Lseed.Editor = function() {
        };
        
        this.Edit = function(plant) {
-               communication.sendMessage(Lseed.MessageCommands.ContentRequest, {content: 'editplant'});
                this.LastEditPlant = plant;
+               var cmp = Ext.getCmp('ContentPanel_editplant');
+               if (cmp) {
+                       communication.activateTab('editplant');
+                       this.EditCallback();
+               } else {
+                       communication.sendMessage(Lseed.MessageCommands.ContentRequest, {content: 'editplant'});
+               }
        };
        this.EditCallback = function() {
                var cmp = Ext.getCmp("editplantdefinitionnamefield");
index f542818..404f3df 100644 (file)
                        $this->assertTrue($res->m_Data == $data, "'".$res->m_Data."' was unexpected, '".$data."' expected");
                }
                function testAuthentication() {
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("IsLoggedIn", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("IsLoggedIn", "", "", "", "", "");
                        $this->validateRPCResponse($res, "IsLoggedIn", "false");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Register", "test", "test", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Register", "test", "test", "", "", "");
                        $this->validateRPCResponse($res, "Register", "{ success: true, msg: 'Benutzer erstellt und erfolgreich angemeldet.' }");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("IsLoggedIn", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("IsLoggedIn", "", "", "", "", "");
                        $this->validateRPCResponse($res, "IsLoggedIn", "true");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Logout", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Logout", "", "", "", "", "");
                        $this->validateRPCResponse($res, "Logout", "true");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("IsLoggedIn", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("IsLoggedIn", "", "", "", "", "");
                        $this->validateRPCResponse($res, "IsLoggedIn", "false");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Auth", "test", "test", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Auth", "test", "test", "", "", "");
                        $this->validateRPCResponse($res, "Auth", "true");
                }
                
                function testPlantCreation() {
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("CreatePlant", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("CreatePlant", "", "", "", "", "");
                        $this->validateRPCResponse($res, "CreatePlant", "{ success: false, msg: 'Sie sind nicht angemeldet' }");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Register", "test", "test", "", "");
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Auth", "test", "test", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Register", "test", "test", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Auth", "test", "test", "", "", "");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("CreatePlant", "", "", "newplant", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("CreatePlant", "", "", "newplant", "", "");
                        $this->validateRPCResponse($res, "CreatePlant", "{ success: true, msg: 'Es wurde eine neue Pflanze für sie angelegt.' }");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("GetPlantList", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("GetPlantList", "", "", "", "", "");
                        $this->validateRPCResponseWithoutData($res, "GetPlantList");
                        $expectedEnd = "Name: 'newplant', Code: '' }] }";
                        substr($res->m_Data, -count($expectedEnd), 0);
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("SavePlant", "test", "", "newplant", "a b c");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("SavePlant", "test", "", "newplant", "a b c", "");
                        $this->validateRPCResponse($res, "SavePlant", "{ success: true, msg: '' }");
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("GetPlantList", "", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("GetPlantList", "", "", "", "", "");
                        $this->validateRPCResponseWithoutData($res, "GetPlantList");
                        $expectedEnd = "Name: 'newplant', Code: 'a b c' }] }";
                        substr($res->m_Data, -count($expectedEnd), 0);
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("DeletePlant", "test", "", "newplant", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("DeletePlant", "test", "", "newplant", "", "");
                        $this->validateRPCResponse($res, "DeletePlant", "{ success: true, msg: '' }");
                }
                
                function testValidation() {
                        
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Register", "test", "test", "", "");
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("Auth", "test", "test", "", "");
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("CreatePlant", "", "", "newplant", "RULE a GROW BY 1");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Register", "test", "test", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("Auth", "test", "test", "", "", "");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("CreatePlant", "", "", "newplant", "RULE a GROW BY 1", "");
                        
                        $GLOBALS['ValidatorFile'] = '../cgi/validate';
-                       $res = $this->m_Controller->HandleRemoteProcedureCall("ValidatePlant", "test", "", "newplant", "");
-                       $this->validateRPCResponse($res, "ValidatePlant", "{\"valid\":true}");
+                       $res = $this->m_Controller->HandleRemoteProcedureCall("CheckSyntax", "test", "", "newplant", "RULE a GROW BY 1", "");
+                       $this->validateRPCResponse($res, "CheckSyntax", "{\"valid\":true}");
                        
                }
        }
index ed29af0..e56a5b9 100644 (file)
                                }
                                $stmt->close();
                        } else {
-                               die("WHY YOU LITTLE...!");
+                               die("What the heck?");
                        }
                        
                        if ($result != null) {
index 0449c08..c1319e9 100644 (file)
                                $return_value = proc_close($process);
                                
                                //echo $return_value;
-                               $result = $output;
-                               $result_ok = 1;
+                               if ($output != null && count($output) > 0) {
+                                       $result = $output;
+                                       $result_ok = 1;
+                               }
                        }
 
                        return array($result_ok, $result);