Skip to content

Commit d6e1571

Browse files
authored
Merge pull request #20 from FriendsOfREDAXO/phpunit_test
PHPUnit Test Dummytest
2 parents 4f7d58f + 50560fe commit d6e1571

File tree

1,171 files changed

+124241
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,171 files changed

+124241
-346
lines changed

.github/workflows/phpunit.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: PHPUnit
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
phpunit:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write # for Git to git apply
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
# setup PHP v8, install some extensions
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.2'
27+
extensions: gd, intl, pdo_mysql
28+
coverage: none # disable xdebug, pcov
29+
30+
# download the latest REDAXO release and unzip it
31+
# credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/
32+
- name: Download latest REDAXO release
33+
run: |
34+
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest)
35+
REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
36+
echo "Downloaded REDAXO $REDAXO_VERSION"
37+
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip
38+
unzip -oq redaxo.zip -d redaxo_cms
39+
rm redaxo.zip
40+
41+
# start mysql service, create a database called redaxo5, apply config patch
42+
- name: Init database
43+
run: |
44+
sudo /etc/init.d/mysql start
45+
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
46+
47+
# run REDAXO setup with the following parameters
48+
# Language: de
49+
# DB password: root
50+
# Create DB: no
51+
# Admin username: admin
52+
# Admin password: adminpassword
53+
# Error E-mail: test@redaxo.invalid
54+
- name: Setup REDAXO
55+
run: |
56+
php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-host=127.0.0.1 --db-name=redaxo5 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword --error-email=test@redaxo.invalid --ansi
57+
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.enabled true
58+
php redaxo_cms/redaxo/bin/console config:set --type boolean debug.throw_always_exception true
59+
60+
# copy Addon files, ignore some directories...
61+
# install the addon
62+
# if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name
63+
# if additional addons are needed, they can be installed via the console commands
64+
# see: https://www.redaxo.org/doku/main/basis-addons#console
65+
- name: Copy and install Addons
66+
run: |
67+
rsync -av --exclude='./vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}'
68+
redaxo_cms/redaxo/bin/console install:download 'yform' '4.*'
69+
redaxo_cms/redaxo/bin/console package:install 'yform'
70+
redaxo_cms/redaxo/bin/console package:install 'cronjob'
71+
redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}'
72+
73+
# install dependencies from composer.json
74+
- name: Install test dependencies
75+
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
76+
env:
77+
COMPOSER: composer.json
78+
run: composer install --prefer-dist --no-progress
79+
80+
- name: Setup Problem Matchers for PHPUnit
81+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
82+
83+
# run unit tests, see composer.json
84+
- name: Run phpunit
85+
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
86+
run: composer test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ modules.xml
1212
.idea/vcs.xml
1313
.idea/encodings.xml
1414
*.ipr
15-
.php-cs-fixer.cache
15+
.php-cs-fixer.cache
16+
.phpunit.result.cache

.tools/bootstrap.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
unset($REX);
4+
$REX['REDAXO'] = true;
5+
$REX['HTDOCS_PATH'] = '../../../../';
6+
$REX['BACKEND_FOLDER'] = 'redaxo';
7+
$REX['LOAD_PAGE'] = false;
8+
9+
require __DIR__.'../../../../core/boot.php';
10+
require __DIR__.'../../../../core/packages.php';
11+
12+
// use original error handlers of the tools
13+
rex_error_handler::unregister();

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"license": "MIT",
23
"require": {
34
"jfcherng/php-diff": "^6.15",
45
"html2text/html2text": "^4.3",
@@ -15,10 +16,12 @@
1516
},
1617
"require-dev": {
1718
"redaxo/php-cs-fixer-config": "^2.0",
18-
"friendsofphp/php-cs-fixer": "^3.14"
19+
"friendsofphp/php-cs-fixer": "^3.14",
20+
"phpunit/phpunit": "^9.5"
1921
},
2022
"scripts": {
2123
"cs-dry": "php-cs-fixer fix -v --ansi --dry-run --config=.php-cs-fixer.dist.php",
22-
"cs-fix": "php-cs-fixer fix -v --ansi --config=.php-cs-fixer.dist.php"
24+
"cs-fix": "php-cs-fixer fix -v --ansi --config=.php-cs-fixer.dist.php",
25+
"test": "phpunit --testdox"
2326
}
2427
}

0 commit comments

Comments
 (0)