public function test_to_json_methods_method_same_as_attribute()
 {
     $book = Book::find(1);
     $json = $book->to_json(array('methods' => 'name'));
     $decoded = (array) json_decode($json);
     $this->assert_true(array_key_exists('name', array_flip(array_keys($decoded))));
     $this->assert_true(ActiveRecord\Inflector::is_lower($decoded['name']));
 }
 public function __call($meth, $args)
 {
     $camel_cased_method = ActiveRecord\Inflector::instance()->camelize($meth);
     if (method_exists($this, $camel_cased_method)) {
         return call_user_func_array(array($this, $camel_cased_method), $args);
     }
     $class_name = get_called_class();
     $trace = debug_backtrace();
     die("PHP Fatal Error:  Call to undefined method {$class_name}::{$meth}() in {$trace[1]['file']} on line {$trace[1]['line']}" . PHP_EOL);
 }
Пример #3
0
 public function set_up()
 {
     $this->inflector = ActiveRecord\Inflector::instance();
 }