Example #1
0
 public function testRetrivedModelsAreSavedToModel()
 {
     $coll = new JitCollection('Efficio\\Tests\\Dataset\\Post');
     $get = new ReflectionMethod('ArrayObject', 'offsetGet');
     $get = $get->getClosure($coll);
     $post = new Post();
     $post->label = uniqid();
     $post->save();
     $post_id = $post->id;
     $coll[] = $post_id;
     $post = $coll[0];
     $post = call_user_func($get, 0);
     $this->assertTrue(is_object($post));
     $this->assertEquals($post_id, $post->id);
 }
Example #2
0
 public function testJsonEncodingCollectionsEncodesModels()
 {
     $this->expectOutputString('[{"label":null,"created_date":null,"id":1}]');
     $posts = new DynamicCollection('Efficio\\Tests\\Dataset\\Post');
     $posts[] = \Efficio\Tests\Dataset\Post::create(['id' => 1]);
     echo json_encode($posts);
 }