/**
	 * Test JViewLegacy::getModel()
	 *
	 * @since   11.3
	 * @covers  JViewLegacy::getModel
	 */
	public function testGetModel()
	{
		//Prepare variable to compare against and a bunch of models
		$models = array();
		$model1 = new ModelMockupJView();
		$models['model'] = $model1;
		$model2 = new ModelMockupJView();
		$model2->name = 'test';
		$models['test'] = $model2;
		$model3 = new ModelMockupJView();
		$model3->name = 'defaulttest';
		$models['defaulttest'] = $model3;

		//Prepare JView object
		TestReflection::setValue($this->class, '_models', $models);
		TestReflection::setValue($this->class, '_defaultModel', 'defaulttest');

		//Assert that the function returns the model with the specific key
		$this->assertThat($this->class->getModel('test'), $this->equalTo($model2));

		//Assert that the function returns the model with an unspecific key
		$this->assertThat($this->class->getModel('Model'), $this->equalTo($model1));

		//Assert that the function returns the default model
		$this->assertThat($this->class->getModel(), $this->equalTo($model3));
	}
示例#2
0
 public function getModel($name = null)
 {
     if (empty($name)) {
         $name = $this->_name;
     }
     return parent::getModel($name);
 }