本文整理汇总了PHP中JView::setModel方法的典型用法代码示例。如果您正苦于以下问题:PHP JView::setModel方法的具体用法?PHP JView::setModel怎么用?PHP JView::setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JView
的用法示例。
在下文中一共展示了JView::setModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetModel
/**
* 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);
}