Skip to content

Commit

Permalink
Merge pull request #370 from anktd/master
Browse files Browse the repository at this point in the history
Add Initial Unit Tests and Update Composer Dependencies
  • Loading branch information
DarrenWestwood committed Jul 5, 2024
2 parents 6976ee0 + 2c2a34f commit 9723644
Show file tree
Hide file tree
Showing 5 changed files with 2,595 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Run PHPUnit Tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress_tests
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=10s
--health-retries=10
steps:
- uses: actions/checkout@v2

- name: Setup PHP, with Composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.1' # Ensuring PHP 8.1 is used
extensions: mbstring, xml, curl, pdo_mysql
coverage: pcov
tools: composer:v2

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Start MySQL
run: sudo /etc/init.d/mysql start

- name: Prepare WordPress Database
run: |
mysql -e 'CREATE DATABASE wordpress_tests;' -uroot -proot
mysql -e "CREATE USER 'wp'@'localhost' IDENTIFIED BY 'wp';" -uroot -proot
mysql -e "GRANT ALL PRIVILEGES ON wordpress_tests.* TO 'wp'@'localhost';" -uroot -proot
mysql -e 'FLUSH PRIVILEGES;' -uroot -proot
- name: Run PHPUnit tests
run: vendor/bin/phpunit tests/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
vendor/
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "blockonomics/test",
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.5",
"10up/wp_mock": "^0.5.0"
},
"autoload": {
"psr-4": {
"": "php/"
}
},
"authors": [
{
"name": "blockonomics",
"email": "[email protected]"
}
]
}
Loading

0 comments on commit 9723644

Please sign in to comment.