/**
  * Class constructor.
  *
  * @since   3.1
  */
 public function __construct()
 {
     // Run the parent constructor
     parent::__construct();
     // Load and set the dispatcher
     $this->loadDispatcher();
     // Enable sessions by default.
     if (is_null($this->config->get('session'))) {
         $this->config->set('session', true);
     }
     // Set the session default name.
     if (is_null($this->config->get('session_name'))) {
         $this->config->set('session_name', 'installation');
     }
     // Create the session if a session name is passed.
     if ($this->config->get('session') !== false) {
         $this->loadSession();
         // Register the session with JFactory
         JFactory::$session = $this->getSession();
     }
     // Store the debug value to config based on the JDEBUG flag
     $this->config->set('debug', JDEBUG);
     // Register the config to JFactory
     JFactory::$config = $this->config;
     // Register the application to JFactory
     JFactory::$application = $this;
     // Register the application name
     $this->_name = 'installation';
     // Register the client ID
     $this->_clientId = 2;
     // Set the root in the URI one level up.
     $parts = explode('/', JUri::base(true));
     array_pop($parts);
     JUri::root(null, implode('/', $parts));
 }
Beispiel #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setup();
     $this->saveFactoryState();
     JFactory::$session = $this->getMockSession();
     $this->object = new JTableCategory(self::$dbo);
 }
Beispiel #3
0
 /**
  * Get a session object
  *
  * Returns the global {@link JSession} object, only creating it
  * if it doesn't already exist.
  *
  * @param array An array containing session options
  * @return object JSession
  */
 public static function getSession($options = array())
 {
     if (!is_object(JFactory::$session)) {
         JFactory::$session = JFactory::_createSession($options);
     }
     return JFactory::$session;
 }
Beispiel #4
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   12.1
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     // Set the session object for JUserHelper::addUserToGroup()
     JFactory::$session = $this->getMockSession();
 }
Beispiel #5
0
 /**
  * Class constructor.
  *
  * @since   3.1
  */
 public function __construct()
 {
     // Run the parent constructor
     parent::__construct();
     // Load and set the dispatcher
     $this->loadDispatcher();
     // Enable sessions by default.
     if (is_null($this->config->get('session'))) {
         $this->config->set('session', true);
     }
     // Set the session default name.
     if (is_null($this->config->get('session_name'))) {
         $this->config->set('session_name', 'installation');
     }
     // Create the session if a session name is passed.
     if ($this->config->get('session') !== false) {
         $this->loadSession();
         // Register the session with JFactory
         JFactory::$session = $this->getSession();
     }
     // Store the debug value to config based on the JDEBUG flag
     $this->config->set('debug', JDEBUG);
     // Register the config to JFactory
     JFactory::$config = $this->config;
     // Register the application to JFactory
     JFactory::$application = $this;
     // Set the root in the URI based on the application name
     JUri::root(null, str_ireplace('/installation', '', JUri::base(true)));
 }
Beispiel #6
0
 /**
  * Tests JHtml::calendar() method with and without 'readonly' attribute.
  */
 public function testCalendar()
 {
     // Create a world for the test
     jimport('joomla.session.session');
     jimport('joomla.application.application');
     jimport('joomla.document.document');
     $cfg = new JObject();
     JFactory::$session = $this->getMock('JSession', array('_start'));
     JFactory::$application = $this->getMock('ApplicationMock');
     JFactory::$config = $cfg;
     JFactory::$application->expects($this->any())->method('getTemplate')->will($this->returnValue('atomic'));
     $cfg->live_site = 'http://example.com';
     $cfg->offset = 'Europe/Kiev';
     $_SERVER['HTTP_USER_AGENT'] = 'Test Browser';
     // two sets of test data
     $test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010', 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d', 'attribs' => array());
     $test_data_ro = array_merge($test_data, array('attribs' => array('readonly' => 'readonly')));
     foreach (array($test_data, $test_data_ro) as $data) {
         // Reset the document
         JFactory::$document = JDocument::getInstance('html', array('unique_key' => serialize($data)));
         $input = JHtml::calendar($data['date'], $data['name'], $data['id'], $data['format'], $data['attribs']);
         $this->assertEquals((string) $xml->input['title'], $data['friendly_date'], 'Line:' . __LINE__ . ' The calendar input should have `title == "' . $data['friendly_date'] . '"`');
         $this->assertEquals((string) $xml->input['name'], $data['name'], 'Line:' . __LINE__ . ' The calendar input should have `name == "' . $data['name'] . '"`');
         $this->assertEquals((string) $xml->input['id'], $data['id'], 'Line:' . __LINE__ . ' The calendar input should have `id == "' . $data['id'] . '"`');
         $head_data = JFactory::getDocument()->getHeadData();
         if (!isset($data['attribs']['readonly']) || !$data['attribs']['readonly'] === 'readonly') {
             $this->assertArrayHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" should be loaded');
             $this->assertArrayHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" should be loaded');
         }
     }
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.2
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
 }
Beispiel #8
0
 /**
  * Get a session object
  *
  * Returns the global {@link JSession} object, only creating it
  * if it doesn't already exist.
  *
  * @param array $options An array containing session options
  *
  * @return JSession object
  */
 public static function getSession($options = array())
 {
     if (!self::$session) {
         self::$session = self::_createSession($options);
     }
     return self::$session;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
     $this->id = bin2hex(random_bytes(8));
 }
 /**
  * Constructor.
  *
  * @since   3.2
  */
 public function __construct()
 {
     parent::__construct();
     // Overrides application config and set the configuration.php file so the send function will work
     JFactory::$config = null;
     JFactory::getConfig(JPATH_SITE . '/configuration.php');
     JFactory::$session = null;
 }
Beispiel #11
0
 /**
  * Constructor: Deletes the default installation config file and recreates it with the good config file.
  *
  * @since  3.1
  */
 public function __construct()
 {
     // Overrides application config and set the configuration.php file so tokens and database works
     JFactory::$config = null;
     JFactory::getConfig(JPATH_SITE . '/configuration.php');
     JFactory::$session = null;
     parent::__construct();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.4
  */
 protected function setUp()
 {
     parent::setUp();
     $app = $this->getMockCmsApp();
     JFactory::$application = $app;
     JFactory::$session = $this->getMockSession();
     $this->object = new JComponentRouterViewInspector($app, $app->getMenu());
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.4
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
     require_once dirname(__DIR__) . '/controller/JCacheControllerRaw.php';
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     // Get the mocks
     $this->saveFactoryState();
     JFactory::$session = $this->getMockSession();
     $this->object = new JTableLanguage(self::$driver);
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setUp();
     // Get the mocks
     $this->saveFactoryState();
     JFactory::$session = $this->getMockSession();
     $this->object = new JTableCorecontent(static::$driver);
 }
 /**
  * Setup each test.
  *
  * @since   3.4
  *
  * @return  void
  */
 public function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
     $this->object = new JModelList(array("filter_fields" => array("field1", "field2")));
 }
 /**
  * Tests the JApplicationBase::loadIdentity method.
  *
  * @return  void
  *
  * @since   12.1
  * @covers  JApplicationBase::loadIdentity
  */
 public function testLoadIdentity()
 {
     $this->class->loadIdentity($this->getMock('JUser', array(), array(), '', false));
     $this->assertAttributeInstanceOf('JUser', 'identity', $this->class, 'Tests that the identity object is the correct class.');
     // Mock the session.
     JFactory::$session = $this->getMockSession(array('get.user.id' => 99));
     $this->class->loadIdentity();
     $this->assertEquals(99, TestReflection::getValue($this->class, 'identity')->get('id'), 'Tests that we got the identity from the factory.');
 }
Beispiel #18
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setup();
     $this->saveFactoryState();
     JFactory::$session = $this->getMockSession();
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['SCRIPT_NAME'] = '';
 }
 /**
  * Sets up the fixture.
  *
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$document = $this->getMockDocument();
     JFactory::$session = $this->getMockSession();
     $this->instance = new JDocumentRendererMessage(JFactory::getDocument());
 }
Beispiel #20
0
 /**
  * Sets up the fixture.
  *
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   12.1
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     $mockApp = $this->getMockCmsApp();
     $mockApp->expects($this->any())->method('getDispatcher')->willReturn($this->getMockDispatcher());
     JFactory::$application = $mockApp;
     $this->object = new JUser('42');
     JFactory::$session = $this->getMockSession();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.6
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
     $this->dispatcher = new JEventDispatcher();
     TestReflection::setValue($this->dispatcher, 'instance', $this->dispatcher);
     $this->dispatcher->register('onAfterRenderModules', array($this, 'eventCallback'));
 }
Beispiel #22
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$database = $this->getMockDatabase('Mysqli');
     JFactory::$session = $this->getMockSession();
     // Register the object
     $this->object = FinderIndexer::getInstance();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     parent::setUp();
     // Get the mocks
     $this->saveFactoryState();
     JFactory::$session = $this->getMockSession();
     $mockApp = $this->getMockCmsApp();
     $mockApp->expects($this->any())->method('getDispatcher')->willReturn($this->getMockDispatcher());
     JFactory::$application = $mockApp;
     $this->object = new JTableCorecontent(static::$driver);
 }
Beispiel #24
0
 /**
  * Sets the Factory pointers
  *
  * @return  void
  */
 protected function restoreFactoryState()
 {
     \JFactory::$application = $this->savedFactoryState['application'];
     \JFactory::$config = $this->savedFactoryState['config'];
     \JFactory::$dates = $this->savedFactoryState['dates'];
     \JFactory::$session = $this->savedFactoryState['session'];
     \JFactory::$language = $this->savedFactoryState['language'];
     \JFactory::$document = $this->savedFactoryState['document'];
     \JFactory::$acl = $this->savedFactoryState['acl'];
     \JFactory::$database = $this->savedFactoryState['database'];
     \JFactory::$mailer = $this->savedFactoryState['mailer'];
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.0
  */
 protected function setUp()
 {
     parent::setUp();
     $this->toolbar = JToolbar::getInstance();
     $this->object = $this->toolbar->loadButtonType('help');
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['SCRIPT_NAME'] = '';
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$application = $this->getMockApplication();
     JFactory::$session = $this->getMockSession();
     // Set up our mock database
     $this->db = JFactory::getDbo();
     $this->db->name = 'mysqli';
     // Register the object
     $this->object = FinderIndexer::getInstance();
 }
 /**
  * Setup for testing.
  *
  * @return  void
  *
  * @since   3.6
  */
 public function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$document = $this->getMockDocument();
     JFactory::$language = $this->getMockLanguage();
     JFactory::$session = $this->getMockSession();
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST;
     $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT;
     $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI;
     $_SERVER['SCRIPT_NAME'] = '/index.php';
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     parent::setup();
     $connect = parent::getConnection();
     $categories = $this->getDataSet();
     $this->_db = JFactory::getDbo();
     $this->object = new JTableCategory($this->_db);
     JFactory::$session = $this->getMock('JSession', array('_start'));
     // Set up a mock database to return db errors
     $badDB = $this->getMock('JDatabaseMySQL', array('getErrorNum'), array(array('prefix' => 'jos_')));
     $badDB->expects($this->any())->method('getErrorNum')->will($this->returnValue('1'));
     $this->badDB = $badDB;
 }
Beispiel #29
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     // Store the factory state so we can mock the necessary objects
     $this->saveFactoryState();
     JFactory::$application = $this->getMockApplication();
     JFactory::$config = $this->getMockConfig();
     JFactory::$session = $this->getMockSession();
     // Set up our mock config
     $this->config = JFactory::getConfig();
     $this->config->set('helpurl', 'http://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}');
     // Load the admin en-GB.ini language file
     JFactory::getLanguage()->load('', JPATH_ADMINISTRATOR);
 }
Beispiel #30
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.1
  */
 protected function setUp()
 {
     // Ensure the loaded states are reset
     JHtmlBehaviorInspector::resetLoaded();
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$document = $this->getMockDocument();
     JFactory::$session = $this->getMockSession();
     // We generate a random template name so that we don't collide or hit anything
     JFactory::$application->expects($this->any())->method('getTemplate')->willReturn('mytemplate' . mt_rand(1, 10000));
     $this->backupServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['SCRIPT_NAME'] = '';
 }