示例#1
0
 /**
  * Test JView::setModel()
  *
  * @since 11.3
  */
 public function testSetModel()
 {
     //Prepare variable to compare against and a bunch of models
     $models = array();
     $model1 = new ModelMockupJView();
     $model2 = new ModelMockupJView();
     $model2->name = 'test';
     $model3 = new ModelMockupJView();
     $model3->name = 'defaulttest';
     //Assert that initial state is empty
     $this->assertAttributeEquals($models, '_models', $this->class);
     //Assert that setModel() returns the model handed over
     $this->assertThat($this->class->setModel($model1), $this->equalTo($model1));
     $models['model'] = $model1;
     //Assert that model was correctly added to array
     $this->assertAttributeEquals($models, '_models', $this->class);
     //Assert that having more than one model works
     $this->class->setModel($model2);
     $models['test'] = $model2;
     $this->assertAttributeEquals($models, '_models', $this->class);
     //Assert that default model works correctly
     $this->assertAttributeEquals('', '_defaultModel', $this->class);
     $this->class->setModel($model3, true);
     $models['defaulttest'] = $model3;
     $this->assertAttributeEquals($models, '_models', $this->class);
     $this->assertAttributeEquals('defaulttest', '_defaultModel', $this->class);
 }