Esempio n. 1
0
 /**
  * test array var
  */
 function testArrayVars()
 {
     // make an eptTest object
     $this->assertTrue($o = new eptTest("XXX", "YYY", "ZZZ"));
     // wrap it with epObject
     $this->assertTrue($w = new epObject($o));
     $w->epSetDirty(false);
     $this->assertTrue($w->a = array("1" => "111", "2" => "222", "3" => "333"));
     $this->assertTrue($w->epIsDirty());
     // check values
     $this->assertTrue(count($w->a) == 3);
     $this->assertTrue($w->a['1'] == "111");
     $this->assertTrue($w->a['2'] == "222");
     $this->assertTrue($w->a['3'] == "333");
     // !!!note that the following does not work!!!
     // $w->a['4'] == "444";
     // a way of inserting new items into an array var
     $this->assertTrue($a = $w->a);
     $this->assertTrue(count($a) == 3);
     $this->assertTrue($a['1'] == "111");
     $this->assertTrue($a['2'] == "222");
     $this->assertTrue($a['3'] == "333");
     // now insert a new item
     $this->assertTrue($a['4'] = "444");
     // reassign the whole array back
     $w->epSetDirty(false);
     $this->assertTrue($w->a = $a);
     $this->assertTrue($w->epIsDirty());
     // check items
     $this->assertTrue($w->a['1'] == "111");
     $this->assertTrue($w->a['2'] == "222");
     $this->assertTrue($w->a['3'] == "333");
     // check new item ['4']
     $this->assertTrue($w->a['4'] == "444");
 }
Esempio n. 2
0
 /**
  * Remove all items
  * @return void
  * @access public
  */
 public function removeAll()
 {
     if ($this->array) {
         // notify on pre change
         if ($this->o && !$this->clean) {
             $this->_notifyChange('onPreChange');
         }
         // go through each object
         foreach ($this as $k => $v) {
             // update inverse
             $this->_updateInverse($v, self::UPDATE_INVERSE_REMOVE);
         }
         // remove everything in array
         $this->array = array();
         // notify the associated object that array has changed
         if ($this->o && !$this->clean) {
             $this->o->epSetDirty(true);
             $this->_notifyChange('onPostChange');
         }
     }
 }