示例#1
0
 /**
  * Tests the loadFormData method.
  *
  * @since   3.4
  *
  * @return  void
  *
  * @testdox loadFormData() returns correct data from currently set states
  */
 public function testListInfoIsAppendedToFormData()
 {
     $method = new ReflectionMethod('JModelList', 'loadFormData');
     $method->setAccessible(true);
     $applicationMock = $this->getMockCmsApp();
     $applicationMock->expects($this->once())->method('getUserState')->with($this->equalTo('com_j.list'), $this->equalTo(new stdClass()))->will($this->returnValue((object) array("foo" => "bar")));
     JFactory::$application = $applicationMock;
     $this->object->setState('list.direction', 'ASC');
     $this->object->setState('list.limit', 30);
     $this->object->setState('list.ordering', 'enabled');
     $this->object->setState('list.start', 0);
     $expected = (object) array("foo" => "bar", "list" => array('direction' => 'ASC', 'limit' => 30, 'ordering' => 'enabled', 'start' => 0));
     $this->assertEquals($expected, $method->invoke($this->object));
 }
示例#2
0
 /**
  * Method to set model state variables. Update local vars.
  *
  * @access	public
  * @param	string	$property	The name of the property.
  * @param	mixed	$value	The value of the property to set or null.
  *
  * @return	mixed	The previous value of the property or null if not set.
  *
  * @since	11.1
  */
 public function setState($property, $value = null)
 {
     if ($property == 'context') {
         $this->context = $value;
     }
     return parent::setState($property, $value);
 }