示例#1
0
 /**
  * Test JViewLegacy::setModel()
  *
  * @since   11.3
  *
  * @return  void
  */
 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);
 }
示例#2
0
文件: view.html.php 项目: JozefAB/qk
 protected function assignExtrasView()
 {
     // Create the View
     $view = new JViewLegacy(array('name' => 'extras', 'base_path' => JPATH_SITE . '/components/com_rsmembership'));
     // Create the Model
     $model = JModelLegacy::getInstance('Extras', 'RSMembershipModel');
     // Assign the Model to the View and set it as default.
     $view->setModel($model, true);
     $view->model =& $model;
     $view->item = $this->membership;
     $view->extras = $model->getItems();
     $view->show_subscribe_btn = false;
     $this->extrasview = $view->loadTemplate();
 }