/** * 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)); }
/** * 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::$application = $this->getMockWeb(); $this->object = new JDocumentFeed(); }
/** * Class constructor. * * @param mixed $input An optional argument to provide dependency injection for the application's * input object. If the argument is a JInput object that object will become * the application's input object, otherwise a default input object is created. * @param mixed $config An optional argument to provide dependency injection for the application's * config object. If the argument is a JRegistry object that object will become * the application's config object, otherwise a default config object is created. * @param mixed $client An optional argument to provide dependency injection for the application's * client object. If the argument is a JApplicationWebClient object that object will become * the application's client object, otherwise a default client object is created. */ public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null) { parent::__construct($input, $config, $client); $this->config->set('session', false); // Inject the application into JFactory JFactory::$application = $this; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 3.5 */ protected function setUp() { parent::setUp(); $app = $this->getMockCmsApp(); JFactory::$application = $app; $router = new JComponentRouterViewInspector($app, $app->getMenu()); $router->set('name', 'content'); $categories = new JComponentRouterViewconfiguration('categories'); $categories->setKey('id'); $router->registerView($categories); $category = new JComponentRouterViewconfiguration('category'); $category->setKey('id')->setParent($categories)->setNestable()->addLayout('blog'); $router->registerView($category); $article = new JComponentRouterViewconfiguration('article'); $article->setKey('id')->setParent($category, 'catid'); $router->registerView($article); $archive = new JComponentRouterViewconfiguration('archive'); $router->registerView($archive); $featured = new JComponentRouterViewconfiguration('featured'); $router->registerView($featured); $form = new JComponentRouterViewconfiguration('form'); $router->registerView($form); $router->menu = new MockJComponentRouterRulesMenuMenuObject(); $this->object = new JComponentRouterRulesMenuInspector($router); }
public function __construct(JInput $input = null, JRegistry $config = null, JApplicationWebClient $client = null) { parent::__construct($input, $config, $client); // Load and set the dispatcher $this->loadDispatcher(); // Register the application to JFactory JFactory::$application = $this; // 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', 'site'); } // 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(); } }
/** * 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->getMockWeb(); $this->object = new JUcmContent(JTable::getInstance('Content'), 'com_content.article'); }
/** * 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(); JFactory::$application = $this->getMockCmsApp(); JFactory::$application->expects($this->any())->method('triggerEvent')->willReturn([]); }
/** * 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->getMockWeb(); $this->object = new JUcmBase('com_content.article'); }
/** * 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))); }
/** * 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(); $this->object = new JHelper(); JFactory::$application = $this->getMockCmsApp(); }
/** * 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->getMockApplication(); $this->object = new JUcmType(); }
/** * 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->checkAvailability(); $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); }
/** * 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(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); JFactory::$config = $this->getMockConfig(); parent::setUp(); }
/** * 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() { $this->toolbar = JToolbar::getInstance(); $this->object = $this->toolbar->loadButtonType('link'); $this->saveFactoryState(); JFactory::$application = $this->getMockApplication(); }
/** * 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(); // We need to mock the application $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); }
/** * 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. */ protected function setUp() { parent::setUp(); $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); $this->object = new JLayoutFile('joomla.sidebars.submenu'); }
/** * 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() { $this->object = new JToolbar('toolbar'); parent::setUp(); $this->saveFactoryState(); JFactory::$application = $this->getMockApplication(); }
/** * 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(); // We need to mock the application $this->saveFactoryState(); JFactory::$application = TestCase::getMockApplication(); }
/** * Sets up the fixture. * * This method is called before a test is executed. * * @return void */ protected function setUp() { JFactory::$application = $this->getMockApplication(); JFactory::$document = $this->getMockDocument(); $this->_instance = new JDocumentRendererMessage(JFactory::getDocument()); parent::setUp(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 3.2 */ public function setUp() { parent::setUp(); // Add JApplication and JLanguage dependencies $this->saveFactoryState(); JFactory::$language = $this->getMockLanguage(); JFactory::$application = $this->getMockCmsApp(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { //$this->object = new JErrorPage; $this->saveFactoryState(); JFactory::$application = $this->getMockApplication(); $this->user = $this->getMock('Observer', array('get', 'authorise')); JFactory::$application->expects($this->once())->method('getIdentity')->will($this->returnValue($this->user)); }
/** * 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(); $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); JFactory::$session = $this->getMockSession(); $this->id = bin2hex(random_bytes(8)); }
/** * Restore original Application instance * * @return void */ public static function restoreApplication() { $container = Container::getInstance(); $className = get_class(static::$originalApplication); $container->alias('app', $className); $container->share($className, static::$originalApplication); \JFactory::$application = static::$originalApplication; }
/** * Setup for testing. * * @return void * * @since 3.1 */ public function setUp() { parent::setUp(); // We are only coupled to Application and Language in JFactory. $this->saveFactoryState(); JFactory::$language = $this->getMockLanguage(); JFactory::$application = $this->getMockApplication(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { // Import dependencies jimport('joomla.application.router'); // We need to mock the application $this->saveFactoryState(); JFactory::$application = TestCase::getMockApplication(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 12.3 */ protected function setUp() { parent::setUp(); $this->saveFactoryState(); $mockApp = $this->getMockCmsApp(); $mockApp->expects($this->any())->method('getDispatcher')->willReturn($this->getMockDispatcher()); JFactory::$application = $mockApp; }
/** * 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()); }