/** * 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 = array('parse', 'render', 'test'); // Create the mock. $mockObject = $test->getMock('\\JDocument', $methods, array(), '', false); // Mock selected methods. $test->assignMockReturns($mockObject, array('parse' => $mockObject, 'test' => 'ok')); return $mockObject; }
/** * 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; }
/** * 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; }
/** * Adds mock objects for some methods. * * @param FOFTestCase $test A test object. * @param \PHPUnit_Framework_MockObject_MockObject $mockObject The mock object. * @param array $options A set of options to configure the mock. * * @return \PHPUnit_Framework_MockObject_MockObject The object with the behaviours added * * @since 3.4 */ public static function addBehaviours($test, $mockObject, $options) { $test->assignMockReturns($mockObject, array('close' => true)); return $mockObject; }