public static function setUpBeforeClass()
	{
		jimport('joomla.database.database');
		jimport('joomla.database.table');

		// Load the config if available.
		@ include_once JPATH_TESTS . '/config.php';
		if (class_exists('JTestConfig')) {
			$config = new JTestConfig;
		}

		if (!is_object(self :: $dbo)) {
			$options = array (
				'driver' => isset ($config) ? $config->dbtype : 'mysql',
				'host' => isset ($config) ? $config->host : '127.0.0.1',
				'user' => isset ($config) ? $config->user : '******',
				'password' => isset ($config) ? $config->password : '******',
				'database' => isset ($config) ? $config->db : 'joomla_ut',
				'prefix' => isset ($config) ? $config->dbprefix : 'jos_'
			);

			self :: $dbo = JDatabase :: getInstance($options);

			if (JError :: isError(self :: $dbo)) {
				//ignore errors
				define('DB_NOT_AVAILABLE', true);
			}
		}
		self :: $database = JFactory :: $database;
		JFactory :: $database = self :: $dbo;
	}
 /**
  * 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();
     $assets = $this->getDataSet();
     $this->_db = JFactory::getDbo();
 }
Esempio n. 3
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();
     // Clear the static caches.
     JAccess::clearStatics();
     $this->object = new JAccess();
 }
 /**
  * Sets up the fixture
  */
 protected function setUp()
 {
     parent::setUp();
     parent::setUpBeforeClass();
     // Force loading the component language
     $lang = JFactory::getLanguage();
     $lang->load('com_attachments', JPATH_BASE . '/administrator/components/com_attachments');
 }
Esempio n. 5
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     jimport('joomla.user.user');
     parent::setUp();
     $this->saveFactoryState();
     $this->saveErrorHandlers();
     $this->setErrorCallback('JUserHelperTest');
     JUserHelperTest::$actualError = array();
     $this->object = new JUserHelper();
 }
Esempio n. 6
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     include_once JPATH_BASE . '/libraries/joomla/event/dispatcher.php';
     include_once JPATH_BASE . '/libraries/joomla/user/authentication.php';
     parent::setUp();
     $this->saveErrorHandlers();
     $this->setErrorCallback('JAuthenticationTest');
     JAuthenticationTest::$actualError = array();
     $this->saveFactoryState();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function setUp()
 {
     @(include_once JPATH_TESTS . '/config_mysql.php');
     if (class_exists('JMySQLTestConfig')) {
         $config = new JMySQLTestConfig();
     } else {
         $this->markTestSkipped('There is no mysql test config file present.');
     }
     $this->object = JDatabase::getInstance(array('driver' => $config->dbtype, 'database' => $config->db, 'host' => $config->host, 'user' => $config->user, 'password' => $config->password));
     parent::setUp();
 }
Esempio n. 8
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     include_once JPATH_BASE . '/libraries/joomla/database/table.php';
     include_once JPATH_BASE . '/libraries/joomla/user/user.php';
     parent::setUp();
     parent::setUpBeforeClass();
     $this->saveFactoryState();
     JUser::getTable('user', 'JTable');
     $this->object = new JUser(42);
     $params = new JRegistry();
     $this->object->setParameters($params);
 }
Esempio n. 9
0
 /**
  * Tests the JAccess::getAuthorisedViewLevels method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testGetAuthorisedViewLevels()
 {
     // Run the parent::setUp() method here to save time (since we only need to run it once)
     parent::setUp();
     if (defined('DB_NOT_AVAILABLE')) {
         $this->markTestSkipped('The database is not available');
     }
     $access = new JAccess();
     $array1 = array(0 => 1, 1 => 3);
     $this->assertThat($access->getAuthorisedViewLevels(42), $this->equalTo($array1), 'Line:' . __LINE__ . ' Super user gets Public, Special (levels 1,3)');
     $array2 = array(0 => 1);
     $this->assertThat($access->getAuthorisedViewLevels(50), $this->equalTo($array2), 'Line:' . __LINE__ . ' User 50 gets Public (level 1)');
     $array3 = array(0 => 1, 1 => 4);
     $this->assertThat($access->getAuthorisedViewLevels(99), $this->equalTo($array3), 'Line:' . __LINE__ . ' User 99 gets Level 4');
 }
Esempio n. 10
0
 /**
  * Sets up the fixture
  */
 protected function setUp()
 {
     parent::setUp();
     parent::setUpBeforeClass();
 }
Esempio n. 11
0
 /**
  * Tears down the fixture.
  *
  * This method is called after a test is executed.
  *
  * @return  void
  *
  * @since   11.3
  */
 protected function tearDown()
 {
     $this->restoreFactoryState();
     parent::tearDown();
 }
Esempio n. 12
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();
     $this->object = new JUserHelper();
 }
Esempio n. 13
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     parent::tearDown();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function setUp()
 {
     $config = new JTestConfig();
     $this->object = JDatabase::getInstance(array('driver' => $config->dbtype, 'database' => $config->db, 'host' => $config->host, 'user' => $config->user, 'password' => $config->password));
     parent::setUp();
 }
Esempio n. 15
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   11.3
  */
 protected function setUp()
 {
     parent::setUp();
 }
Esempio n. 16
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   11.3
  */
 protected function setUp()
 {
     parent::setUp();
     jimport('joomla.html.html');
 }
Esempio n. 17
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->object = new JAccess();
 }