Skip to content

Commit

Permalink
chore: run pest tests through wp-env
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartui committed Apr 17, 2024
1 parent f4e8c8f commit e1da087
Show file tree
Hide file tree
Showing 6 changed files with 563 additions and 38 deletions.
39 changes: 12 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,23 @@ jobs:
matrix:
php: ['8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Checkout
uses: actions/checkout@v2
- name: Set Composer version
run: composer self-update --2.2
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: yarn
- name: Install yarn dependencies
run: yarn install --immutable
- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
- name: Install Composer build dependencies
run: composer bin build install --no-progress
- name: Compose dependencies
run: composer compose
- name: Remove unused dependencies
run: composer remove --dev szepeviktor/phpstan-wordpress
- name: Setup tests
run: bash tests/bin/install-wp-tests.sh
- name: Setup PHP ${{ matrix.php }}
# https://github.com/shivammathur/setup-php/issues/446#issuecomment-824001225
uses: shivammathur/setup-php@develop
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
tools: none
- name: PHPUnit
- name: Start wp-env
env:
WP_DB_HOST: 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
run: composer test
WP_ENV_PHP_VERSION: ${{ matrix.php }}
run: yarn run wp-env start
- name: Run Tests
run: yarn run test-php
css:
name: CSS Lint
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"phpVersion": "8.2",
"mappings": {
"wp-content/plugins/notification": "."
}
}
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"phpcbf": "phpcbf",
"phpcs": "phpcs",
"phplint": "parallel-lint --exclude node_modules --exclude vendor --exclude vendor-bin .",
"phpstan": "phpstan analyze --memory-limit=-1",
"test": "vendor/bin/pest"
"phpstan": "phpstan analyze --memory-limit=-1"
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"fix:css": "mp-scripts lint-style --fix",
"fix:js": "mp-scripts lint-js --fix",
"lint": "run-p \"lint:*\"",
"fix": "run-p \"fix:*\""
"fix": "run-p \"fix:*\"",
"test-php": "wp-env run tests-wordpress --env-cwd=wp-content/plugins/notification ./vendor/bin/pest -- --configuration phpunit.xml"
},
"author": "BracketSpace",
"license": "GPL-3.0-or-later",
"devDependencies": {
"@micropackage/scripts": "^1.2.5",
"@wordpress/env": "^9.7.0",
"npm-run-all": "^4.1.5"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<phpunit
bootstrap="vendor/autoload.php"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
Expand Down
Loading

0 comments on commit e1da087

Please sign in to comment.