Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- type: postgresql
version: '13'
port: 5432
- type: sqlite
version: '3'
port: 0
fail-fast: false

name: PHP ${{ matrix.php-version }} - ${{ matrix.database.type }} ${{ matrix.database.version }}
Expand Down Expand Up @@ -84,7 +87,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: bcmath, curl, gd, iconv, mysqli, pdo_mysql, pdo_pgsql, pgsql, soap, zip, fileinfo, openssl, simplexml, mbstring, intl
extensions: bcmath, curl, gd, iconv, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, soap, zip, fileinfo, openssl, simplexml, mbstring, intl
coverage: xdebug
tools: composer:v2
env:
Expand All @@ -110,10 +113,13 @@ jobs:
echo "Testing ${{ matrix.database.type }} ${{ matrix.database.version }} connection..."
mysql --host=${{ env.DB_HOST }} --user=${{ env.DB_USER }} --password=${{ env.DB_PASS }} -e "SHOW DATABASES;"
mysql --host=${{ env.DB_HOST }} --user=${{ env.DB_USER }} --password=${{ env.DB_PASS }} -e "SELECT VERSION();"
else
elif [ "${{ matrix.database.type }}" = "postgresql" ]; then
echo "Testing PostgreSQL ${{ matrix.database.version }} connection..."
PGPASSWORD=${{ env.DB_PASS }} psql -h ${{ env.DB_HOST }} -U ${{ env.DB_USER }} -d ${{ env.DB_NAME }} -c "\l"
PGPASSWORD=${{ env.DB_PASS }} psql -h ${{ env.DB_HOST }} -U ${{ env.DB_USER }} -d ${{ env.DB_NAME }} -c "SELECT version();"
else
echo "Testing SQLite ${{ matrix.database.version }} support..."
php -r 'exit(in_array("sqlite", PDO::getAvailableDrivers(), true) ? 0 : 1);'
fi

- name: Create application config
Expand All @@ -140,7 +146,7 @@ jobs:
define('FS_DISABLE_ADD_PLUGINS', false);
define('FS_DISABLE_RM_PLUGINS', false);
EOF
else
elif [ "${{ matrix.database.type }}" = "postgresql" ]; then
cat > config.php << 'EOF'
<?php
define('FS_COOKIES_EXPIRE', 31536000);
Expand All @@ -160,6 +166,26 @@ jobs:
define('FS_DISABLE_ADD_PLUGINS', false);
define('FS_DISABLE_RM_PLUGINS', false);
EOF
else
cat > config.php << 'EOF'
<?php
define('FS_COOKIES_EXPIRE', 31536000);
define('FS_ROUTE', '');
define('FS_DB_TYPE', 'sqlite');
define('FS_DB_HOST', '');
define('FS_DB_PORT', 0);
define('FS_DB_NAME', 'MyFiles/facturascripts_test.sqlite');
define('FS_DB_USER', '');
define('FS_DB_PASS', '');
define('FS_DB_FOREIGN_KEYS', true);
define('FS_DB_TYPE_CHECK', true);
define('FS_LANG', 'es_ES');
define('FS_TIMEZONE', 'Europe/Madrid');
define('FS_HIDDEN_PLUGINS', '');
define('FS_DEBUG', true);
define('FS_DISABLE_ADD_PLUGINS', false);
define('FS_DISABLE_RM_PLUGINS', false);
EOF
fi

- name: Run PHPUnit tests
Expand Down
7 changes: 6 additions & 1 deletion Core/Base/DataBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
use FacturaScripts\Core\Base\DataBase\DataBaseEngine;
use FacturaScripts\Core\Base\DataBase\MysqlEngine;
use FacturaScripts\Core\Base\DataBase\PostgresqlEngine;
use FacturaScripts\Core\Base\DataBase\SqliteEngine;
use FacturaScripts\Core\KernelException;
use FacturaScripts\Core\Tools;

/**
* Generic class of access to the database, either MySQL or PostgreSQL.
* Generic class of access to the database, either MySQL, PostgreSQL or SQLite.
*
* @author Carlos García Gómez <carlos@facturascripts.com>
* @author Jose Antonio Cuello Principal <yopli2000@gmail.com>
Expand Down Expand Up @@ -84,6 +85,10 @@ public function __construct()
self::$engine = new PostgresqlEngine();
break;

case 'sqlite':
self::$engine = new SqliteEngine();
break;

default:
self::$engine = new MysqlEngine();
break;
Expand Down
Loading