Merge pull request #3 from wpallstars/fix/test-workflow

Fix test workflow issues with WP_Mock and PHP 7.0 compatibility
This commit is contained in:
2025-04-18 15:53:29 +01:00
committed by GitHub
4 changed files with 35 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
name: Tests name: Tests - Run PHP compatibility and unit tests
on: on:
push: push:
@@ -27,7 +27,15 @@ jobs:
tools: composer:v2 tools: composer:v2
- name: Install dependencies - name: Install dependencies
run: composer install --prefer-dist --no-progress run: |
if [[ "${{ matrix.php-versions }}" == "7.0" ]]; then
composer require --dev phpunit/phpunit:"^6.5" --update-with-dependencies
composer require --dev 10up/wp_mock:"^0.4.2" --update-with-dependencies
composer require --dev antecedent/patchwork:"^2.1.21" --update-with-dependencies
else
composer install --prefer-dist --no-progress
composer require --dev 10up/wp_mock:"^0.4.2" --update-with-dependencies
fi
- name: Run tests - name: Run tests
run: ./vendor/bin/phpunit run: ./vendor/bin/phpunit
@@ -51,4 +59,4 @@ jobs:
run: composer install --prefer-dist --no-progress run: composer install --prefer-dist --no-progress
- name: Run PHPCS - name: Run PHPCS
run: ./vendor/bin/phpcs --standard=WordPress --runtime-set installed_paths vendor/wp-coding-standards/wpcs run: ./vendor/bin/phpcs --standard=WordPress --runtime-set installed_paths vendor/wp-coding-standards/wpcs ./includes ./admin ./wp-plugin-starter-template.php

View File

@@ -8,6 +8,10 @@
// First, we need to load the composer autoloader so we can use WP Mock. // First, we need to load the composer autoloader so we can use WP Mock.
require_once dirname(__DIR__) . '/vendor/autoload.php'; require_once dirname(__DIR__) . '/vendor/autoload.php';
// Import WP_Mock class
use WP_Mock\Tools\TestCase;
use WP_Mock;
// Now call the bootstrap method of WP Mock. // Now call the bootstrap method of WP Mock.
WP_Mock::bootstrap(); WP_Mock::bootstrap();

View File

@@ -7,11 +7,13 @@
use WPALLSTARS\PluginStarterTemplate\Admin\Admin; use WPALLSTARS\PluginStarterTemplate\Admin\Admin;
use WPALLSTARS\PluginStarterTemplate\Core; use WPALLSTARS\PluginStarterTemplate\Core;
use WP_Mock\Tools\TestCase;
use WP_Mock;
/** /**
* Admin test case. * Admin test case.
*/ */
class AdminTest extends WP_Mock\Tools\TestCase { class AdminTest extends TestCase {
/** /**
* Test instance * Test instance

View File

@@ -6,11 +6,13 @@
*/ */
use WPALLSTARS\PluginStarterTemplate\Core; use WPALLSTARS\PluginStarterTemplate\Core;
use WP_Mock\Tools\TestCase;
use WP_Mock;
/** /**
* Core test case. * Core test case.
*/ */
class CoreTest extends WP_Mock\Tools\TestCase { class CoreTest extends TestCase {
/** /**
* Test instance * Test instance