public function testIncrement() { $entity = new Entity(array('data' => array('counter' => 0))); $this->assertEqual(0, $entity->counter); $entity->increment('counter'); $this->assertEqual(1, $entity->counter); $entity->decrement('counter', 5); $this->assertEqual(-4, $entity->counter); $this->assertNull($entity->increment); $entity->increment('foo'); $this->assertEqual(1, $entity->foo); $this->assertFalse(isset($entity->bar)); $entity->bar = 'blah'; $entity->update(); $this->expectException("/^Field 'bar' cannot be incremented.\$/"); $entity->increment('bar'); }
public function update($id = null, array $data = array()) { foreach ($this->_data as $key => $val) { if (is_object($val) && method_exists($val, 'update')) { $this->_data[$key]->update(null, isset($data[$key]) ? $data[$key] : array()); } } return parent::update($id, $data); }
public function update($id = null, array $data = array()) { foreach ($this->_data as $key => $val) { if (is_a($val, $this->_classes['entity'])) { $this->_data[$key]->update(null, isset($data[$key]) ? $data[$key] : array()); } } return parent::update($id, $data); }