Skip to content

Commit

Permalink
Merge pull request #71 from 10up/unit-tests
Browse files Browse the repository at this point in the history
PHPUnit tests
  • Loading branch information
jeffpaul authored Jul 7, 2022
2 parents c385d6b + 808bd7e commit 0dc3fca
Show file tree
Hide file tree
Showing 14 changed files with 2,925 additions and 139 deletions.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ LICENSE.md
package-lock.json
package.json
README.md
phpunit.xml.dist
54 changes: 54 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PHPUnit

env:
COMPOSER_VERSION: "2"
COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache"

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# We claim to support from 5.6+ but WP Mock only supports 7.1+
php: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
os: [ ubuntu-latest ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"
- name: Prepare composer cache
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer update -W

- name: PHPUnit
run: './vendor/bin/phpunit'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
tests/cypress/downloads
tests/cypress/screenshots
tests/cypress/videos
.phpunit.result.cache
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
"enshrined/svg-sanitize": "^0.15.2"
},
"require-dev": {
"10up/phpcs-composer": "dev-master"
"10up/phpcs-composer": "dev-master",
"10up/wp_mock": "^0.4.2",
"yoast/phpunit-polyfills": "^1.0"
},
"scripts": {
"phpcs": "./vendor/bin/phpcs . -p -s",
"phpcbf": "./vendor/bin/phpcbf .",
"phpcs:compat": "./vendor/bin/phpcs *.php includes -p --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.0-"
"phpcs:compat": "./vendor/bin/phpcs *.php includes -p --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.0-",
"test:unit": "./vendor/bin/phpunit"
},
"config": {
"allow-plugins": {
Expand Down
Loading

0 comments on commit 0dc3fca

Please sign in to comment.