/**
  * Creates and instance of the mock JLanguage object.
  *
  * @param   PHPUnit_Framework_TestCase  $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;
 }
Exemplo n.º 2
0
 /**
  * Creates and instance of the mock JLanguage object.
  *
  * @param   PHPUnit_Framework_TestCase  $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('_', 'getInstance', 'getTag', 'test');
     // 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_')));
     return $mockObject;
 }
Exemplo n.º 3
0
 /**
  * Creates and instance of the mock JDatabaseDriver object.
  *
  * @param   PHPUnit_Framework_TestCase  $test          A test object.
  * @param   string                      $driver        Optional driver to create a sub-class of JDatabaseDriver.
  * @param   array                       $extraMethods  An array of additional methods to add to the mock.
  * @param   string                      $nullDate      A null date string for the driver.
  * @param   string                      $dateFormat    A date format for the driver.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $driver = '', array $extraMethods = array(), $nullDate = '0000-00-00 00:00:00', $dateFormat = 'Y-m-d H:i:s')
 {
     // Collect all the relevant methods in JDatabaseDriver.
     $methods = array_merge($extraMethods, array('connect', 'connected', 'disconnect', 'dropTable', 'escape', 'execute', 'fetchArray', 'fetchAssoc', 'fetchObject', 'freeResult', 'getAffectedRows', 'getCollation', 'getConnectors', 'getDateFormat', 'getErrorMsg', 'getErrorNum', 'getInstance', 'getLog', 'getNullDate', 'getNumRows', 'getPrefix', 'getQuery', 'getTableColumns', 'getTableCreate', 'getTableKeys', 'getTableList', 'getUtfSupport', 'getVersion', 'insertId', 'insertObject', 'loadAssoc', 'loadAssocList', 'loadColumn', 'loadObject', 'loadObjectList', 'loadResult', 'loadRow', 'loadRowList', 'lockTable', 'query', 'quote', 'quoteName', 'renameTable', 'replacePrefix', 'select', 'setQuery', 'setUTF', 'splitSql', 'test', 'isSupported', 'transactionCommit', 'transactionRollback', 'transactionStart', 'unlockTables', 'updateObject'));
     // Create the mock.
     $mockObject = $test->getMock('JDatabaseDriver' . $driver, $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('getNullDate' => $nullDate, 'getDateFormat' => $dateFormat));
     $test->assignMockCallbacks($mockObject, array('escape' => array(is_callable(array($test, 'mockEscape')) ? $test : __CLASS__, 'mockEscape'), 'getQuery' => array(is_callable(array($test, 'mockGetQuery')) ? $test : __CLASS__, 'mockGetQuery'), 'quote' => array(is_callable(array($test, 'mockQuote')) ? $test : __CLASS__, 'mockQuote'), 'quoteName' => array(is_callable(array($test, 'mockQuoteName')) ? $test : __CLASS__, 'mockQuoteName'), 'setQuery' => array(is_callable(array($test, 'mockSetQuery')) ? $test : __CLASS__, 'mockSetQuery')));
     return $mockObject;
 }
 /**
  * Creates an instance of the mock JSession object.
  *
  * @param   PHPUnit_Framework_TestCase  $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;
 }
 /**
  * Creates and instance of the mock JEventDispatcher object.
  *
  * @param   PHPUnit_Framework_TestCase  $test        A test object.
  * @param   boolean                     $defaults  True to create the default mock handlers and triggers.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $defaults = true)
 {
     // Clear the static tracker properties.
     self::$handlers = array();
     self::$triggered = array();
     // Collect all the relevant methods in JEventDispatcher.
     $methods = array('register', 'trigger', 'test');
     // Create the mock.
     $mockObject = $test->getMock('JEventDispatcher', $methods, array(), '', false);
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('test' => 'ok'));
     if ($defaults) {
         $test->assignMockCallbacks($mockObject, array('register' => array(get_called_class(), 'mockRegister'), 'trigger' => array(get_called_class(), 'mockTrigger')));
     }
     return $mockObject;
 }
Exemplo n.º 6
0
 /**
  * Creates and instance of the mock DispatcherInterface object.
  *
  * @param   PHPUnit_Framework_TestCase  $test      A test object.
  * @param   boolean                     $defaults  True to create the default mock handlers and triggers.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $defaults = true)
 {
     // Clear the static tracker properties.
     self::$handlers = array();
     self::$triggered = array();
     // Collect all the relevant methods in DispatcherInterface.
     $methods = array('addListener', 'dispatch', 'register', 'removeListener', 'trigger', 'test');
     // Create the mock.
     $mockObject = $test->getMockBuilder(DispatcherInterface::class)->setMethods($methods)->getMock();
     // Mock selected methods.
     $test->assignMockReturns($mockObject, array('test' => 'ok'));
     if ($defaults) {
         $test->assignMockCallbacks($mockObject, array('dispatch' => array(get_called_class(), 'mockDispatch'), 'addListener' => array(get_called_class(), 'mockRegister')));
     }
     return $mockObject;
 }