Skip to content
Closed
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
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_DSN=mysql://root:root@127.0.0.1:3306/jeedom_test
58 changes: 58 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Tests

on:
push:
pull_request:
branches:
- 'master'
- 'beta'
- 'alpha'

permissions:
contents: read

jobs:
phpunit:
name: PHP Unit
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4', '8.2']
services:
mariadb:
image: mariadb:10.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: composer install --prefer-dist --no-progress --optimize-autoloader
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-version }}'
extensions: json pdo_mysql curl gd imap xml opcache soap xml zip ssh2 mbstring ldap yaml snmp pcov
coverage: none

# Run Legacy test suite
- name: Run legacy test suite
env:
DATABASE_DSN: mysql://root:root@localhost:3306/jeedom_test
run: composer run-script test-legacy

# Run Unit test suite
- name: Run unit test suite
env:
DATABASE_DSN: mysql://root:root@localhost:3306/jeedom_test
run: composer run-script test-unit

# Run Backward Compatibility test suite
# If these tests fail, it means that the PR will have to be integrated into the futur major version.
# You need to ensure compatibility if you want your changes to be taken into account in the next minor version.
- name: Run BC test suite
env:
DATABASE_DSN: mysql://root:root@localhost:3306/jeedom_test
run: composer run-script test-bc
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Thumbs.db
.vscode
ui
composer.lock
.env
.env.local
.env.*.local
.phpunit.result.cache
var

test.php
core/config/common.config.php
Expand Down
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,18 @@
"allow-plugins": {
"php-http/discovery": true
}
},
"require-dev": {
"phpunit/phpunit": "^9.6"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"test-legacy": "phpunit --coverage-text --colors=never --testsuite \"Legacy tests\"",
"test-unit": "phpunit --coverage-text --colors=never --testsuite \"Unit tests\"",
"test-bc": "phpunit --coverage-text --colors=never --testsuite \"Backward Compatibility tests\""
}
}
Loading