Example #1
0
 /**
  * Creates and instance of the mock JLanguage object.
  *
  * @param   FOFTestCase $test A test object.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test)
 {
     // Collect all the relevant methods in JDatabase.
     $methods = static::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('\\JLanguage', $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('getInstance' => $mockObject, 'getTag' => 'en-GB', 'test' => 'ok'));
     $test->assignMockCallbacks($mockObject, array('_' => array(get_called_class(), 'mock_'), 'load' => array(get_called_class(), 'mockload')));
     return $mockObject;
 }
Example #2
0
 /**
  * Creates an instance of the mock JSession object.
  *
  * @param   FOFTestCase  $test     A test object.
  * @param   array                       $options  An array of optional configuration values.
  *                                                getId : the value to be returned by the mock getId method
  *                                                get.user.id : the value to assign to the user object id returned by get('user')
  *                                                get.user.name : the value to assign to the user object name returned by get('user')
  *                                                get.user.username : the value to assign to the user object username returned by get('user')
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $options = array())
 {
     if (is_array($options)) {
         self::$options = $options;
     }
     // Mock all the public methods.
     $methods = array('clear', 'close', 'destroy', 'fork', 'get', 'getExpire', 'getFormToken', 'getId', 'getInstance', 'getName', 'getState', 'getStores', 'getToken', 'has', 'hasToken', 'getPrefix', 'isNew', 'restart', 'set');
     // Create the mock.
     $mockObject = $test->getMock('\\JSession', $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('getId' => self::getOption('getId')));
     $test->assignMockCallbacks($mockObject, array('get' => array(get_called_class(), 'mockGet')));
     return $mockObject;
 }