[limb-svn] r7004 - 3.x/trunk/limb/core/tests/cases

svn at limb-project.com svn at limb-project.com
Mon May 12 10:24:50 MSD 2008


Author: serega
Date: 2008-05-12 10:24:50 +0400 (Mon, 12 May 2008)
New Revision: 7004
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7004

Modified:
   3.x/trunk/limb/core/tests/cases/lmbObjectTest.class.php
Log:
-- added an extra test for new lmbObject functionality. Just to be sure.

Modified: 3.x/trunk/limb/core/tests/cases/lmbObjectTest.class.php
===================================================================
--- 3.x/trunk/limb/core/tests/cases/lmbObjectTest.class.php	2008-05-12 05:20:50 UTC (rev 7003)
+++ 3.x/trunk/limb/core/tests/cases/lmbObjectTest.class.php	2008-05-12 06:24:50 UTC (rev 7004)
@@ -47,17 +47,21 @@
 class ObjectTestVersion3 extends lmbObject 
 {
   protected $protected;
-  public $getter_called = false;  
-  public $setter_called = false;
+  protected $protected2;
   
-  function setProtected()
+  public $getter_called_count = 0;  
+  public $setter_called_count = 0;
+  
+  function setProtected($value)
   {
-    $this->setter_called = true;
+    $this->setter_called_count++;
+    $this->protected = $value;
   }
   
   function getProtected()
   {
-    $this->getter_called = true;
+    $this->getter_called_count++;
+    return $this->protected;
   }
 }
 
@@ -357,22 +361,46 @@
     $this->assertTrue(true);
   }
   
-  function testAccessByMethodForProtectedProperties()
+  function testBetterCheckForAccessByMethod()
   {
     $obj = new ObjectTestVersion3();
-    $obj->protected = $obj->protected;
-    $this->assertTrue($obj->setter_called);
-    $this->assertTrue($obj->getter_called);
+    $obj->protected = 'value';
+    $this->assertEqual($obj->setter_called_count, 1);
+    $this->assertEqual($obj->protected, 'value');
+    $this->assertEqual($obj->getter_called_count, 1);
+
+    $obj = new ObjectTestVersion3();
+    $obj['protected'] = 'value';
+    $this->assertEqual($obj->setter_called_count, 1);
+    $this->assertEqual($obj['protected'], 'value');
+    $this->assertEqual($obj->getter_called_count, 1);
     
     $obj = new ObjectTestVersion3();
-    $obj['protected'] = $obj['protected'];
-    $this->assertTrue($obj->setter_called);
-    $this->assertTrue($obj->getter_called);
+    $obj->set('protected', 'value');
+    $this->assertEqual($obj->setter_called_count, 1);
+    $this->assertEqual($obj->get('protected'), 'value');
+    $this->assertEqual($obj->getter_called_count, 1);    
+  }  
+  
+  function _testAccessByMethodForProtectedPropertiesSeveralTimes()
+  {
+    $obj = new ObjectTestVersion3();
+    $obj->protected = 'value1';
+    $obj->protected = 'value2';
+    $this->assertEqual($obj->setter_called_count, 2);
+    $this->assertEqual($obj->protected, 'value2');
     
     $obj = new ObjectTestVersion3();
-    $obj->set('protected', $obj->get('protected'));
-    $this->assertTrue($obj->setter_called);
-    $this->assertTrue($obj->getter_called);    
-  }  
+    $obj['protected'] = 'value1';
+    $obj['protected'] = 'value2';
+    $this->assertEqual($obj->setter_called_count, 2);
+    $this->assertEqual($obj['protected'], 'value2');
+    
+    $obj = new ObjectTestVersion3();
+    $obj->set('protected', 'value1');
+    $obj->set('protected', 'value2');
+    $this->assertEqual($obj->setter_called_count, 2);
+    $this->assertEqual($obj->get('protected'), 'value1');
+  }
 }
 



More information about the limb-svn mailing list