Skip to content

Commit

Permalink
Merge pull request #3698 from elkarte/patch_1-1-9
Browse files Browse the repository at this point in the history
Patch 1 1 9
  • Loading branch information
Spuds committed Feb 18, 2023
2 parents d9e5ddd + a09fcf1 commit 36764dd
Show file tree
Hide file tree
Showing 277 changed files with 35,323 additions and 2,916 deletions.
14 changes: 4 additions & 10 deletions tests/travis-ci/setup_mysql.php → .github/ElkTestingMysql.php
Expand Up @@ -12,12 +12,6 @@
*
*/

define('TESTDIR', dirname(__FILE__));
define('BOARDDIR', dirname(__FILE__) . '/../..');
define('CACHEDIR', BOARDDIR . '/cache');
define('ELK', '1');

require_once(TESTDIR . '/setup.php');
require_once(BOARDDIR . '/sources/database/Db-mysql.class.php');
require_once(BOARDDIR . '/sources/database/DbTable.class.php');
require_once(BOARDDIR . '/sources/database/DbTable-mysql.php');
Expand Down Expand Up @@ -55,7 +49,7 @@ private function __construct($db)

/**
* Static method that allows to retrieve or create an instance of this class.
` *
*
* @param object $db - A Database_MySQL object
*
* @return object - A DbTable_MySQL object
Expand All @@ -74,14 +68,14 @@ public static function db_table($db)
/**
* Extend Elk_Testing_Setup with MySql values
*/
class Elk_Testing_mysql extends Elk_Testing_Setup
class ElkTestingMysql extends ElkTestingSetup
{
public function init()
{
global $db_name, $db_prefix;

$this->_boardurl = 'http://127.0.0.1';
$this->_db_server = 'localhost';
$this->_db_server = '127.0.0.1';
$this->_db_type = 'mysql';
$db_name = $this->_db_name = 'elkarte_test';
$this->_db_user = 'root';
Expand Down Expand Up @@ -109,5 +103,5 @@ public function init()
}
}

$setup = new Elk_Testing_mysql();
$setup = new ElkTestingMysql();
$setup->init();
23 changes: 9 additions & 14 deletions tests/travis-ci/setup_pgsql.php → .github/ElkTestingPsql.php
Expand Up @@ -13,12 +13,6 @@
*
*/

define('TESTDIR', dirname(__FILE__));
define('BOARDDIR', dirname(__FILE__) . '/../..');
define('CACHEDIR', BOARDDIR . '/cache');
define('ELK', '1');

require_once(TESTDIR . '/setup.php');
require_once(BOARDDIR . '/sources/database/Db-postgresql.class.php');
require_once(BOARDDIR . '/sources/database/DbTable.class.php');
require_once(BOARDDIR . '/sources/database/DbTable-postgresql.php');
Expand All @@ -35,7 +29,7 @@ class DbTable_PostgreSQL_Install extends DbTable_PostgreSQL
*
* @param object $db - A Database_PostgreSQL object
*/
private function __construct($db)
private function __construct($db, $db_prefix)
{
global $db_prefix;

Expand All @@ -52,6 +46,7 @@ private function __construct($db)

// This executes queries and things
$this->_db = $db;
$this->_db_prefix = $db_prefix;
}

/**
Expand All @@ -60,11 +55,11 @@ private function __construct($db)
* @param object $db - A Database_PostgreSQL object
* @return object - A DbTable_PostgreSQL object
*/
public static function db_table($db)
public static function db_table($db, $db_prefix)
{
if (is_null(self::$_tbl_inst))
{
self::$_tbl_inst = new DbTable_PostgreSQL_Install($db);
self::$_tbl_inst = new DbTable_PostgreSQL_Install($db, $db_prefix);
}

return self::$_tbl_inst;
Expand All @@ -74,24 +69,24 @@ public static function db_table($db)
/**
* Extend Elk_Testing_Setup with PostgreSQL values
*/
class Elk_Testing_psql extends Elk_Testing_Setup
class ElkTestingPsql extends ElkTestingSetup
{
public function init()
{
global $db_name, $db_prefix, $modSettings;

$this->_boardurl = 'http://127.0.0.1';
$this->_db_server = 'localhost';
$this->_db_server = '127.0.0.1';
$this->_db_type = 'postgresql';
$db_name = $this->_db_name = 'elkarte_test';
$this->_db_user = 'postgres';
$this->_db_passwd = '';
$this->_db_passwd = 'postgres';
$db_prefix = $this->_db_prefix = 'elkarte_';

// Start the database interface
Database_PostgreSQL::initiate($this->_db_server, $this->_db_name, $this->_db_user, $this->_db_passwd, $this->_db_prefix);
$this->_db = Database_PostgreSQL::db();
$this->_db_table = DbTable_PostgreSQL_Install::db_table($this->_db);
$this->_db_table = DbTable_PostgreSQL_Install::db_table($this->_db, $this->_db_prefix);

$modSettings['disableQueryCheck'] = 1;
// Load the postgre install sql queries
Expand All @@ -108,5 +103,5 @@ public function init()
}
}

$setup = new Elk_Testing_psql();
$setup = new ElkTestingPsql();
$setup->init();
29 changes: 29 additions & 0 deletions .github/LICENSE
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, ElkArte Forum contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 changes: 14 additions & 9 deletions tests/travis-ci/setup.php → .github/SetupDbUtil.php
Expand Up @@ -13,21 +13,26 @@

global $txt;

define('BOARDDIR', dirname(__FILE__) . '/..');
define('CACHEDIR', BOARDDIR . '/cache');
define('ELK', '1');

// Lots of needs
require_once(BOARDDIR . '/sources/database/Db.php');
require_once(BOARDDIR . '/sources/database/Db-abstract.class.php');
require_once(BOARDDIR . '/sources/Subs.php');
require_once(BOARDDIR . '/sources/subs/Cache.subs.php');
require_once(BOARDDIR . '/sources/database/Database.subs.php');
require_once(BOARDDIR . '/install/installcore.php');
require_once(BOARDDIR . '/sources/subs/Util.class.php');

// Composer-Autoloader
require_once(BOARDDIR . '/vendor/autoload.php');

/**
* Used to install ElkArte SQL files to a database scheme
*/
Class Elk_Testing_Setup
Class ElkTestingSetup
{
protected $_db;
protected $_install_instance;
Expand Down Expand Up @@ -227,13 +232,13 @@ public function update()
global $ssi_db_user, $scripturl, $ssi_db_passwd, $db_passwd;
global $sourcedir, $boarddir;

DEFINE('SUBSDIR', BOARDDIR . '/sources/subs');
DEFINE('EXTDIR', BOARDDIR . '/sources/ext');
DEFINE('SOURCEDIR', BOARDDIR . '/sources');
DEFINE('LANGUAGEDIR', BOARDDIR . '/themes/default/languages');
DEFINE('ADMINDIR', SOURCEDIR . '/admin');
DEFINE('CONTROLLERDIR', SOURCEDIR . '/controllers');
DEFINE('ADDONSDIR', SOURCEDIR . '/addons');
defined('SUBSDIR') || DEFINE('SUBSDIR', BOARDDIR . '/sources/subs');
defined('EXTDIR') || DEFINE('EXTDIR', BOARDDIR . '/sources/ext');
defined('SOURCEDIR') || DEFINE('SOURCEDIR', BOARDDIR . '/sources');
defined('LANGUAGEDIR') || DEFINE('LANGUAGEDIR', BOARDDIR . '/themes/default/languages');
defined('ADMINDIR') || DEFINE('ADMINDIR', SOURCEDIR . '/admin');
defined('CONTROLLERDIR') || DEFINE('CONTROLLERDIR', SOURCEDIR . '/controllers');
defined('ADDONSDIR') || DEFINE('ADDONSDIR', SOURCEDIR . '/addons');

require_once(BOARDDIR . '/Settings.php');
require_once(SOURCEDIR . '/Subs.php');
Expand Down Expand Up @@ -281,7 +286,7 @@ public function update()

if (date_default_timezone_set($timezone_id))
{
$db->insert('',
$db->insert('replace',
$db_prefix . 'settings',
array(
'variable' => 'string-255', 'value' => 'string-65534',
Expand Down
24 changes: 24 additions & 0 deletions .github/SetupMysql.php
@@ -0,0 +1,24 @@
<?php

/**
* Handles the mysql and mariadb install actions
*
* Called by setup-database.sh as part of the install
*
* @name ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause
*
* @version 1.1
*
*/

define('TESTDIR', dirname(__FILE__));

// Call in the support
require_once(TESTDIR . '/SetupDbUtil.php');
require_once(TESTDIR . '/ElkTestingMysql.php');

// Lets install the db
$setup = new ElkTestingMysql();
return $setup->init();
22 changes: 22 additions & 0 deletions .github/SetupPgsql.php
@@ -0,0 +1,22 @@
<?php

/**
* Handles the postgresql actions
*
* Called by setup-database.sh as part of the install
*
* @name ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause
*
* @version 1.1
*
*/

define('TESTDIR', dirname(__FILE__));

require_once(TESTDIR . '/SetupDbUtil.php');
require_once(TESTDIR . '/ElkTestingPsql.php');

$setup = new ElkTestingPsql();
return $setup->init();
14 changes: 7 additions & 7 deletions tests/travis-ci/bootstrap.php → .github/bootstrap.php
Expand Up @@ -27,10 +27,10 @@
if (!defined('ELK'))
{
DEFINE('ELK', '1');
DEFINE('CACHE_STALE', '?R11B2');
DEFINE('CACHE_STALE', '?R119');

// Get the forum's settings for database and file paths.
require_once('/var/www/Settings.php');
require_once('Settings.php');

// Set our site "variable" constants
DEFINE('BOARDDIR', $boarddir);
Expand All @@ -45,7 +45,7 @@
}
else
{
require_once('/var/www/Settings.php');
require_once('Settings.php');
}

// A few files we cannot live without and will not be autoload
Expand All @@ -72,28 +72,28 @@
loadDatabase();
Hooks::init(database(), Debug::instance());
reloadSettings();
elk_seed_generator();
loadSession();
loadUserSettings();
loadBoard();
loadPermissions();
loadTheme();

// It should be added to the install and upgrade scripts.
// But since the converters need to be updated also. This is easier.
updateSettings(array(
'attachmentUploadDir' => serialize(array(1 => $modSettings['attachmentUploadDir'])),
'currentAttachmentUploadDir' => 1,
'disableQueryCheck' => 1,
));
loadTheme();

// Basic language is good to have for functional tests
loadLanguage('index+Errors');

// If we are running functional tests as well
if (defined('PHPUNIT_SELENIUM'))
{
require_once('/var/www/tests/sources/controllers/ElkArteWebTest.php');
require_once('tests/sources/controllers/ElkArteWebTest.php');
PHPUnit_Extensions_Selenium2TestCase::shareSession(true);
}

file_put_contents('/var/www/bootstrapcompleted.lock', '1');
file_put_contents('bootstrapcompleted.lock', '1');
30 changes: 30 additions & 0 deletions .github/nginx.conf
@@ -0,0 +1,30 @@
# Basic Nginx Configuration for github action webserver
server {
listen 80;
listen [::]:80;

server_name example.com www.example.com;
root /home/runner/work/Elkarte/Elkarte/elkarte/;

error_log /var/log/nginx/example.com.error.log;
access_log /var/log/nginx/example.com.access.log;

location / {
index index.php index.html index.htm;
try_files $uri $uri/ @rewrites;
}

location @rewrites {
rewrite ^ /index.php last;
}

location ~ ^(.+?\.php)(/.*)?$ {
try_files $1 = 404;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_pass unix:/path/to/socket;
}
}
Expand Up @@ -7,11 +7,14 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true">
<testsuites>
<testsuite name="ElkArte Basic Tests">
<directory suffix="Basic.php">/var/www/tests</directory>
<testsuite name="Basic Tests">
<directory suffix="Basic.php">../tests</directory>
</testsuite>
</testsuites>

<logging>
<log type="coverage-text" target="php://stdout" />
</logging>
</phpunit>

0 comments on commit 36764dd

Please sign in to comment.