[limb-svn] r5990 - in 3.x/trunk/limb/web_app: src/controller tests/cases/plain/controller

svn at limb-project.com svn at limb-project.com
Wed Jun 13 17:57:20 MSD 2007


Author: tony
Date: 2007-06-13 17:57:19 +0400 (Wed, 13 Jun 2007)
New Revision: 5990
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5990

Modified:
   3.x/trunk/limb/web_app/src/controller/lmbController.class.php
   3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php
Log:
-- lmbController::closePopup() writes code in response only if in_popup set to true
-- added new property to lmbController `in_popup` (true by default)

Modified: 3.x/trunk/limb/web_app/src/controller/lmbController.class.php
===================================================================
--- 3.x/trunk/limb/web_app/src/controller/lmbController.class.php	2007-06-13 13:08:11 UTC (rev 5989)
+++ 3.x/trunk/limb/web_app/src/controller/lmbController.class.php	2007-06-13 13:57:19 UTC (rev 5990)
@@ -1,21 +1,21 @@
 <?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com 
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/web_app/src/controller/lmbAbstractController.class.php');
 lmb_require('limb/validation/src/lmbErrorList.class.php');
-lmb_require('limb/validation/src/lmbValidator.class.php');
-
+lmb_require('limb/validation/src/lmbValidator.class.php');
+
 /**
  * class lmbController.
  *
  * @package web_app
  * @version $Id$
- */
+ */
 class lmbController extends lmbAbstractController
 {
   protected $toolkit;
@@ -26,6 +26,7 @@
   protected $error_list;
   protected $validator;
   protected $form_id;
+  protected $in_popup = true;
 
   function __construct()
   {
@@ -183,6 +184,9 @@
 
   function closePopup()
   {
+    if(!$this->in_popup)
+      return;
+
     $this->response->write('<html><script>if(window.opener){window.opener.focus();window.opener.location.reload();window.close();}</script></html>');
   }
 

Modified: 3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php
===================================================================
--- 3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php	2007-06-13 13:08:11 UTC (rev 5989)
+++ 3.x/trunk/limb/web_app/tests/cases/plain/controller/lmbControllerTest.class.php	2007-06-13 13:57:19 UTC (rev 5990)
@@ -1,10 +1,10 @@
 <?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com 
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/web_app/src/controller/lmbController.class.php');
 lmb_require('limb/view/src/wact/lmbWactTemplateLocator.class.php');
@@ -35,6 +35,17 @@
     $this->item = 'item';
   }
 
+  function doPopup()
+  {
+    $this->closePopup();
+  }
+
+  function doWithoutPopup()
+  {
+    $this->in_popup = false;
+    $this->closePopup();
+  }
+
   function addValidatorRule($r)
   {
     $this->validator->addRule($r);
@@ -189,6 +200,22 @@
     $controller = new lmbController();
     $this->assertEqual($controller->forward('testing', 'write'), "Hi!");
   }
+
+  function testClosePopup()
+  {
+    $controller = new TestingController();
+    $controller->setCurrentAction('popup');
+    $controller->performAction();
+    $this->assertPattern('~^<html><script>~', $this->toolkit->getResponse()->getResponseString());
+  }
+
+  function testDoNotClosePopup()
+  {
+    $controller = new TestingController();
+    $controller->setCurrentAction('without_popup');
+    $controller->performAction();
+    $this->assertPattern('~^Default empty output~', $this->toolkit->getResponse()->getResponseString());
+  }
 }
 
 ?>
\ No newline at end of file



More information about the limb-svn mailing list