Fix: Resolve CI dependency conflicts and PHPCS/PHPUnit errors
This commit is contained in:
16
.github/workflows/tests.yml
vendored
16
.github/workflows/tests.yml
vendored
@@ -28,15 +28,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ matrix.php-versions }}" == "7.0" ]]; then
|
# Install base dependencies from lock file
|
||||||
|
composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
# Update specific dependencies for higher PHP versions if needed
|
||||||
|
if [[ "${{ matrix.php-versions }}" == "7.4" || "${{ matrix.php-versions }}" == "8.0" ]]; then
|
||||||
|
echo "Updating dependencies for PHP ${{ matrix.php-versions }}..."
|
||||||
|
composer require --dev phpunit/phpunit:"^9.5" 10up/wp_mock:"^1.0" --no-update --no-plugins --no-scripts
|
||||||
|
elif [[ "${{ matrix.php-versions }}" == "7.0" ]]; then
|
||||||
# Force PHPUnit 6.5 for PHP 7.0
|
# Force PHPUnit 6.5 for PHP 7.0
|
||||||
composer require --dev phpunit/phpunit:"^6.5" --update-with-dependencies
|
composer require --dev phpunit/phpunit:"^6.5" --update-with-dependencies
|
||||||
elif [[ "${{ matrix.php-versions }}" == "8.0" ]]; then
|
|
||||||
# Update PHPUnit and WP_Mock for PHP 8.0
|
|
||||||
composer require --dev phpunit/phpunit:"^9.5" 10up/wp_mock:"^1.0" --no-update
|
|
||||||
fi
|
fi
|
||||||
# Update all dependencies based on composer.json/composer.lock and any modifications above
|
|
||||||
composer update --prefer-dist --no-progress
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./vendor/bin/phpunit
|
run: ./vendor/bin/phpunit
|
||||||
@@ -57,7 +59,7 @@ jobs:
|
|||||||
tools: composer:v2, phpcs
|
tools: composer:v2, phpcs
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer update --prefer-dist --no-progress
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
- name: Run PHPCS
|
- name: Run PHPCS
|
||||||
run: ./vendor/bin/phpcs --standard=WordPress ./includes ./admin ./wp-plugin-starter-template.php
|
run: ./vendor/bin/phpcs --standard=WordPress ./includes ./admin ./wp-plugin-starter-template.php
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class Admin {
|
|||||||
* @param Core $core Core instance.
|
* @param Core $core Core instance.
|
||||||
*/
|
*/
|
||||||
public function __construct( Core $core ) {
|
public function __construct( Core $core ) {
|
||||||
error_log('Admin::__construct called');
|
|
||||||
$this->core = $core;
|
$this->core = $core;
|
||||||
$this->initialize_hooks();
|
$this->initialize_hooks();
|
||||||
}
|
}
|
||||||
@@ -36,32 +35,34 @@ class Admin {
|
|||||||
* Initializes WordPress hooks.
|
* Initializes WordPress hooks.
|
||||||
*/
|
*/
|
||||||
private function initialize_hooks() {
|
private function initialize_hooks() {
|
||||||
error_log('Admin::initialize_hooks called');
|
|
||||||
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
|
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueues admin-specific assets.
|
* Enqueues admin scripts and styles.
|
||||||
*
|
*
|
||||||
* @param string $hook_suffix The current admin page.
|
* @param string $hook_suffix The current admin page.
|
||||||
|
* @phpcs:ignore WordPress.CodeAnalysis.UnusedFunctionParameter.Found
|
||||||
*/
|
*/
|
||||||
public function enqueue_admin_assets( $hook_suffix ) {
|
public function enqueue_admin_assets( $hook_suffix ) {
|
||||||
// Enqueue admin styles
|
// Enqueue admin styles.
|
||||||
\wp_enqueue_style(
|
\wp_enqueue_style(
|
||||||
'wpst-admin-style',
|
'wpst-admin-style',
|
||||||
'path/to/admin/css/admin-styles.css'
|
'path/to/admin/css/admin-styles.css',
|
||||||
|
array(), // Dependencies
|
||||||
|
$this->core->get_plugin_version() // Version
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue admin scripts
|
// Enqueue admin scripts.
|
||||||
\wp_enqueue_script(
|
\wp_enqueue_script(
|
||||||
'wpst-admin-script',
|
'wpst-admin-script',
|
||||||
'path/to/admin/js/admin-scripts.js',
|
'path/to/admin/js/admin-scripts.js',
|
||||||
array( 'jquery' ),
|
array( 'jquery' ),
|
||||||
null,
|
$this->core->get_plugin_version(), // Version
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Localize script
|
// Localize script.
|
||||||
\wp_localize_script(
|
\wp_localize_script(
|
||||||
'wpst-admin-script',
|
'wpst-admin-script',
|
||||||
'wpst_admin_params',
|
'wpst_admin_params',
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class AdminTest extends \WP_Mock\Tools\TestCase {
|
|||||||
/**
|
/**
|
||||||
* Set up test environment
|
* Set up test environment
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Set up mocks
|
// Set up mocks
|
||||||
@@ -46,7 +46,7 @@ class AdminTest extends \WP_Mock\Tools\TestCase {
|
|||||||
/**
|
/**
|
||||||
* Tear down test environment
|
* Tear down test environment
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown(): void {
|
||||||
WP_Mock::tearDown();
|
WP_Mock::tearDown();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user