Example #1
0
 public function test_build()
 {
     $association = new Jam_Association_Belongsto(array('polymorphic' => FALSE, 'inverse_of' => 'test_post'));
     $association->initialize($this->meta, 'test_author');
     $model = new Model_Test_Post();
     $value = $association->build($model);
     $this->assertInstanceOf('Model_Test_Author', $value);
     $this->assertSame($value->test_post, $model);
     $association = new Jam_Association_Belongsto(array('polymorphic' => TRUE, 'inverse_of' => 'test_post'));
     $association->initialize($this->meta, 'test_author');
     $model = new Model_Test_Post();
     $value = $association->build($model);
     $this->assertNull($value);
     $model->set('test_author_model', 'test_author');
     $value = $association->build($model);
     $this->assertInstanceOf('Model_Test_Author', $value);
     $this->assertSame($value->test_post, $model);
     $association = new Jam_Association_Belongsto(array('inverse_of' => 'test_post'));
     $association->initialize($this->meta, 'test_position');
     $value = $association->build($model);
     $this->assertInstanceOf('Model_Test_Position', $value);
     $value = $association->build($model, array('model' => 'test_position_big'));
     $this->assertInstanceOf('Model_Test_Position_Big', $value);
 }