Skip to content

Commit e83063d

Browse files
authored
Merge pull request #891 from alleyinteractive/feature/889-tests
Migrating to Mantle Testkit / PHPUnit 11/12 with updated GitHub workflows
2 parents 675b322 + 6cb2830 commit e83063d

Some content is hidden

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

43 files changed

+386
-469
lines changed

.editorconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ trim_trailing_whitespace = true
1414
indent_style = tab
1515
indent_size = 4
1616

17-
[*.json,*.yml,*.feature]
17+
[*.{ts,tsx,js,jsx,scss,css,json,yaml,yml,feature,xml}]
18+
indent_style = space
19+
indent_size = 2
20+
21+
# Dotfiles
22+
[.*]
1823
indent_style = space
1924
indent_size = 2

.gitattributes

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Exclude these files from release archives.
3+
#
4+
# This will also make the files unavailable when using Composer with `--prefer-dist`.
5+
#
6+
# Via WPCS.
7+
#
8+
/.github export-ignore
9+
/.phpcs export-ignore
10+
/apigen.neon export-ignore
11+
/package.json export-ignore
12+
/phpcs.xml export-ignore
13+
/phpunit.xml export-ignore
14+
/rector.php export-ignore
15+
/tests export-ignore
16+
17+
#
18+
# Auto detect text files and perform LF normalization.
19+
#
20+
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
21+
#
22+
* text=auto
23+
24+
#
25+
# The above will handle all files not found below.
26+
#
27+
*.md text
28+
*.php text
29+
*.inc text

.github/workflows/all-pr-tests.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "All Pull Request Tests"
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- main
8+
pull_request:
9+
branches:
10+
- develop
11+
- main
12+
types: [opened, synchronize, reopened, ready_for_review]
13+
14+
jobs:
15+
# We use a single job to ensure that all steps run in the same environment and
16+
# reduce the number of minutes used.
17+
pr-tests:
18+
# Don't run on draft PRs
19+
if: github.event.pull_request.draft == false
20+
# Timeout after 10 minutes
21+
timeout-minutes: 10
22+
# Define a matrix of PHP/WordPress versions to test against
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
php: [8.1, 8.2, 8.3, 8.4]
27+
wordpress: ["latest"]
28+
multisite: ['true', 'false']
29+
runs-on: ubuntu-latest
30+
# Cancel any existing runs of this workflow
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-P${{ matrix.php }}-WP${{ matrix.wordpress }}-MS${{ matrix.multisite }}
33+
cancel-in-progress: true
34+
# Name the job in the matrix
35+
name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }} Multisite ${{ matrix.multisite }}"
36+
steps:
37+
- uses: actions/checkout@v5
38+
39+
- name: Run General Tests
40+
# See https://github.com/alleyinteractive/action-test-general for more options
41+
uses: alleyinteractive/action-test-general@develop
42+
43+
- name: Run PHP Tests
44+
# See https://github.com/alleyinteractive/action-test-php for more options
45+
uses: alleyinteractive/action-test-php@develop
46+
with:
47+
php-version: '${{ matrix.php }}'
48+
wordpress-version: '${{ matrix.wordpress }}'
49+
wordpress-multisite: '${{ matrix.multisite }}'
50+
skip-wordpress-install: 'true'
51+
# This required job ensures that all PR checks have passed before merging.
52+
all-pr-checks-passed:
53+
name: All PR checks passed
54+
needs:
55+
- pr-tests
56+
runs-on: ubuntu-latest
57+
if: always()
58+
steps:
59+
- name: Check job statuses
60+
run: |
61+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
62+
echo "One or more jobs failed"
63+
exit 1
64+
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
65+
echo "One or more jobs were cancelled"
66+
exit 1
67+
else
68+
echo "All jobs passed or were skipped"
69+
exit 0
70+
fi

.github/workflows/phpcs.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/phpunit.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Dependencies
22
vendor
3+
!tests/js/vendor
34
node_modules
45
.env
56
composer.lock

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Fieldmanager is a powerful library which can make the development of sophisticat
99
## Requirements
1010

1111
* WordPress: 5.8+
12-
* PHP: 7.4+
12+
* PHP: 8.1+
1313

1414
## Downloads and Versioning.
1515

composer.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,27 @@
1111
}
1212
],
1313
"require": {
14+
"php": ">=8.1",
1415
"composer/installers": "^1.0 || ^2.0"
1516
},
1617
"require-dev": {
17-
"alleyinteractive/alley-coding-standards": "^0.3.0",
18-
"yoast/phpunit-polyfills": "^1.0"
18+
"alleyinteractive/alley-coding-standards": "^1.0",
19+
"mantle-framework/testkit": "^1.3"
1920
},
2021
"scripts": {
2122
"phpcs": "vendor/bin/phpcs",
2223
"phpcbf": "vendor/bin/phpcbf",
23-
"phpunit": "vendor/bin/phpunit"
24+
"phpunit": "vendor/bin/phpunit",
25+
"test": [
26+
"@phpcs",
27+
"@phpunit"
28+
]
2429
},
2530
"config": {
2631
"allow-plugins": {
2732
"dealerdirect/phpcodesniffer-composer-installer": true,
28-
"composer/installers": true
33+
"composer/installers": true,
34+
"alleyinteractive/composer-wordpress-autoloader": true
2935
}
3036
}
3137
}

multisite.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

phpunit.xml

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1+
<?xml version="1.0"?>
12
<phpunit
2-
bootstrap="tests/php/bootstrap.php"
3-
backupGlobals="false"
4-
colors="true"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
5+
bootstrap="tests/php/bootstrap.php"
6+
backupGlobals="false"
7+
colors="true"
58
>
6-
<testsuites>
7-
<!-- Default test suite to run all tests -->
8-
<testsuite name="Fieldmanager Tests">
9-
<directory suffix=".php">tests</directory>
10-
</testsuite>
11-
</testsuites>
12-
<groups>
13-
<exclude>
14-
<group>ajax</group>
15-
</exclude>
16-
</groups>
17-
<logging>
18-
<log type="junit" target="build/logs/junit.xml" />
19-
</logging>
20-
<filter>
21-
<whitelist processUncoveredFilesFromWhitelist="true">
22-
<directory suffix=".php">php</directory>
23-
</whitelist>
24-
</filter>
9+
<testsuites>
10+
<testsuite name="Fieldmanager Tests">
11+
<directory suffix="Test.php">tests</directory>
12+
</testsuite>
13+
</testsuites>
14+
<php>
15+
<ini name="error_reporting" value="-1" />
16+
<ini name="display_errors" value="1" />
17+
</php>
2518
</phpunit>

0 commit comments

Comments
 (0)