public function testPrepare() { $connection = Connection::instance(); $this->assertEquals(array('sql' => 'select * from users where age > 10', 'values' => array()), Reflection::invokeMethod($connection, '_prepare', array('select * from users where age > 10', array()))); $this->assertEquals(array('sql' => 'select * from users where age > ?', 'values' => array(10)), Reflection::invokeMethod($connection, '_prepare', array('select * from users where age > ?', array(10)))); $this->assertEquals(array('sql' => 'select * from users where id in (?,?) or (country = ? and city not in (?,?,?))', 'values' => array(1, 2, 'China', 'ShangHai', 'GuangZhou', 'BeiJing')), Reflection::invokeMethod($connection, '_prepare', array('select * from users where id in (?) or (country = ? and city not in (?))', array(array(1, 2), 'China', array('ShangHai', 'GuangZhou', 'BeiJing'))))); }
public function call($type) { $callbacks = $this->_getCallbacks($type); foreach ($callbacks as $callback) { $result = true; if ($callback instanceof Closure) { $result = $callback($this->_model); } else { $result = Reflection::invokeMethod($this->_model, $callback); } if ($result === false && strpos($type, 'before_') === 0) { return false; } } return true; }
public function testRegister() { self::$_callback->register('before_create', 'register'); $this->assertEquals(array('_init', 'register', 'before_save'), Reflection::invokeMethod(self::$_callback, '_getCallbacks', array('before_create'))); }