Example #1
0
 /**
  * Test the Model::to_array method.
  *
  * @group laravel
  */
 public function testConvertingToArray()
 {
     Model::$hidden = array('password', 'hidden');
     $array = array('name' => 'Taylor', 'age' => 25, 'password' => 'laravel', 'null' => null);
     $model = new Model($array);
     $first = new Model(array('first' => 'foo', 'password' => 'hidden'));
     $second = new Model(array('second' => 'bar', 'password' => 'hidden'));
     $third = new Model(array('third' => 'baz', 'password' => 'hidden'));
     $model->relationships['one'] = new Model(array('foo' => 'bar', 'password' => 'hidden'));
     $model->relationships['many'] = array($first, $second, $third);
     $model->relationships['hidden'] = new Model(array('should' => 'not_visible'));
     $model->relationships['null'] = null;
     $this->assertEquals(array('name' => 'Taylor', 'age' => 25, 'null' => null, 'one' => array('foo' => 'bar'), 'many' => array(array('first' => 'foo'), array('second' => 'bar'), array('third' => 'baz')), 'null' => null), $model->to_array());
 }