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
|
||||
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
|
||||
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
|
||||
# Update all dependencies based on composer.json/composer.lock and any modifications above
|
||||
composer update --prefer-dist --no-progress
|
||||
|
||||
- name: Run tests
|
||||
run: ./vendor/bin/phpunit
|
||||
@@ -57,7 +59,7 @@ jobs:
|
||||
tools: composer:v2, phpcs
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer update --prefer-dist --no-progress
|
||||
run: composer install --prefer-dist --no-progress
|
||||
|
||||
- name: Run PHPCS
|
||||
run: ./vendor/bin/phpcs --standard=WordPress ./includes ./admin ./wp-plugin-starter-template.php
|
||||
|
||||
@@ -27,7 +27,6 @@ class Admin {
|
||||
* @param Core $core Core instance.
|
||||
*/
|
||||
public function __construct( Core $core ) {
|
||||
error_log('Admin::__construct called');
|
||||
$this->core = $core;
|
||||
$this->initialize_hooks();
|
||||
}
|
||||
@@ -36,32 +35,34 @@ class Admin {
|
||||
* Initializes WordPress hooks.
|
||||
*/
|
||||
private function initialize_hooks() {
|
||||
error_log('Admin::initialize_hooks called');
|
||||
\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.
|
||||
* @phpcs:ignore WordPress.CodeAnalysis.UnusedFunctionParameter.Found
|
||||
*/
|
||||
public function enqueue_admin_assets( $hook_suffix ) {
|
||||
// Enqueue admin styles
|
||||
// Enqueue admin styles.
|
||||
\wp_enqueue_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(
|
||||
'wpst-admin-script',
|
||||
'path/to/admin/js/admin-scripts.js',
|
||||
array( 'jquery' ),
|
||||
null,
|
||||
$this->core->get_plugin_version(), // Version
|
||||
true
|
||||
);
|
||||
|
||||
// Localize script
|
||||
// Localize script.
|
||||
\wp_localize_script(
|
||||
'wpst-admin-script',
|
||||
'wpst_admin_params',
|
||||
|
||||
@@ -30,7 +30,7 @@ class AdminTest extends \WP_Mock\Tools\TestCase {
|
||||
/**
|
||||
* Set up test environment
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
// Set up mocks
|
||||
@@ -46,7 +46,7 @@ class AdminTest extends \WP_Mock\Tools\TestCase {
|
||||
/**
|
||||
* Tear down test environment
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown(): void {
|
||||
WP_Mock::tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user