Merge pull request #5 from wpallstars/fix/test-workflow-v3
Fix: Update test workflow for PHP 7.0 compatibility
This commit is contained in:
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@@ -30,12 +30,8 @@ jobs:
|
||||
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
|
||||
composer install --prefer-dist --no-progress
|
||||
|
||||
- name: Run tests
|
||||
run: ./vendor/bin/phpunit
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0",
|
||||
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.0 || ^9.0",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"wp-coding-standards/wpcs": "^2.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0"
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"10up/wp_mock": "0.3.0",
|
||||
"antecedent/patchwork": "^2.1.21"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -1 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Core functionality for the plugin
|
||||
*
|
||||
* @package WPALLSTARS\PluginStarterTemplate
|
||||
*/
|
||||
|
||||
namespace WPALLSTARS\PluginStarterTemplate;
|
||||
|
||||
/**
|
||||
* Core class
|
||||
*/
|
||||
class Core {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Initialize hooks.
|
||||
}
|
||||
|
||||
/**
|
||||
* Example method to filter content
|
||||
*
|
||||
* @param string $content The content to filter.
|
||||
* @return string The filtered content.
|
||||
*/
|
||||
public function filter_content( $content ) {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
// First, we need to load the composer autoloader so we can use WP Mock.
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
// Import WP_Mock class
|
||||
use WP_Mock\Tools\TestCase;
|
||||
use WP_Mock;
|
||||
// No need to import WP_Mock classes here
|
||||
|
||||
// Now call the bootstrap method of WP Mock.
|
||||
WP_Mock::bootstrap();
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
|
||||
use WPALLSTARS\PluginStarterTemplate\Admin\Admin;
|
||||
use WPALLSTARS\PluginStarterTemplate\Core;
|
||||
use WP_Mock\Tools\TestCase;
|
||||
use WP_Mock;
|
||||
|
||||
/**
|
||||
* Admin test case.
|
||||
*/
|
||||
class AdminTest extends TestCase {
|
||||
class AdminTest extends \WP_Mock\Tools\TestCase {
|
||||
|
||||
/**
|
||||
* Test instance
|
||||
@@ -32,7 +30,7 @@ class AdminTest extends TestCase {
|
||||
/**
|
||||
* Set up test environment
|
||||
*/
|
||||
public function setUp(): void {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Set up mocks
|
||||
@@ -54,7 +52,7 @@ class AdminTest extends TestCase {
|
||||
/**
|
||||
* Tear down test environment
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
public function tearDown() {
|
||||
WP_Mock::tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
*/
|
||||
|
||||
use WPALLSTARS\PluginStarterTemplate\Core;
|
||||
use WP_Mock\Tools\TestCase;
|
||||
use WP_Mock;
|
||||
|
||||
/**
|
||||
* Core test case.
|
||||
*/
|
||||
class CoreTest extends TestCase {
|
||||
class CoreTest extends \WP_Mock\Tools\TestCase {
|
||||
|
||||
/**
|
||||
* Test instance
|
||||
@@ -24,7 +22,7 @@ class CoreTest extends TestCase {
|
||||
/**
|
||||
* Set up test environment
|
||||
*/
|
||||
public function setUp(): void {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Set up mocks
|
||||
@@ -37,7 +35,7 @@ class CoreTest extends TestCase {
|
||||
/**
|
||||
* Tear down test environment
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
public function tearDown() {
|
||||
WP_Mock::tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user