Example #1
0
 /**
  * Creates and instance of the mock JApplicationWeb object.
  *
  * @param   object  $test     A test object.
  * @param   array   $options  A set of options to configure the mock.
  *
  * @return  object
  *
  * @since   11.3
  */
 public static function create($test, $options = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     // Collect all the relevant methods in JApplicationWeb (work in progress).
     $methods = array('get', 'getDocument', 'getLanguage', 'getSession');
     // Create the mock.
     $mockObject = $test->getMock('JApplicationWeb', $methods, array(), '', true);
     // Mock calls to JApplicationWeb::getDocument().
     $mockObject->expects($test->any())->method('getDocument')->will($test->returnValue(JDocumentGlobalMock::create($test)));
     // Mock calls to JApplicationWeb::getLanguage().
     $mockObject->expects($test->any())->method('getLanguage')->will($test->returnValue(JLanguageGlobalMock::create($test)));
     // Mock a call to JApplicationWeb::getSession().
     if (isset($options['session'])) {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue($options['session']));
     } else {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue(JSessionGlobalMock::create($test)));
     }
     return $mockObject;
 }
Example #2
0
 /**
  * Gets a mock language object.
  *
  * @return  JLanguage
  *
  * @since   11.3
  */
 public function getMockLanguage()
 {
     // Load the real class first otherwise the mock will be used if jimport is called again.
     require_once JPATH_PLATFORM . '/joomla/language/language.php';
     // Load the mock class builder.
     require_once JPATH_TESTS . '/includes/mocks/JLanguageMock.php';
     return JLanguageGlobalMock::create($this);
 }
 /**
  * Gets a mock language object.
  *
  * @return  object
  *
  * @since   11.3
  */
 protected function getMockLanguage()
 {
     require_once JPATH_TESTS . '/suite/joomla/language/JLanguageMock.php';
     return JLanguageGlobalMock::create($this);
 }
 /**
  * Gets a mock language object.
  *
  * @return  object
  *
  * @since   11.3
  */
 protected function getMockLanguage()
 {
     // Load the real class first otherwise the mock will be used if jimport is called again.
     require_once JPATH_PLATFORM . '/joomla/language/language.php';
     require_once JPATH_TESTS . '/suite/joomla/language/JLanguageMock.php';
     return JLanguageGlobalMock::create($this);
 }