Skip to content

Conversation

@sjinks
Copy link
Member

@sjinks sjinks commented Jul 19, 2025

This pull request introduces several improvements to the codebase, with a primary focus on enhancing test code quality and consistency. Key changes include replacing require and include with their _once variants for improved safety, updating test functions to use public visibility for adherence to PHPUnit conventions, and refining test assertions for greater accuracy.

Test Code Improvements:

  • Updated all test functions to use public visibility in compliance with PHPUnit's requirements. This change affects multiple test files, such as test-cli-orchestrate-sites.php, test-event.php, test-events-store.php, test-events.php, and test-internal-events.php. [1] [2] [3] [4] [5]

  • Improved assertions for test accuracy, such as replacing assertEquals with assertEqualsWithDelta in time-sensitive tests to account for minor timing differences.

Dependency Loading Enhancements:

  • Replaced require and include with require_once and include_once in __tests__/bootstrap.php to prevent potential issues with multiple inclusions of the same files. [1] [2]

Minor Refactoring:

  • Removed unused variable assignments in test files to streamline the code, such as in test-events-store.php. [1] [2]

Fixes: #399

@sjinks sjinks self-assigned this Jul 19, 2025
@sjinks sjinks requested a review from Copilot July 19, 2025 04:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses multiple test failures by fixing type-related issues, updating dependencies, and improving code consistency. The changes focus on resolving PHP type compatibility issues and modernizing the test suite.

  • Updates function parameter types and return type hints for better PHP compatibility
  • Modernizes test method visibility and fixes logical operators
  • Updates Composer dependencies to use more flexible version constraints

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
includes/wp-cli/class-orchestrate-sites.php Fixes integer division and logical operator issues
includes/class-singleton.php Updates return type annotation from self to static
includes/class-events-store.php Adds nullable type hints for optional string parameters
composer.json Updates dependency versions to use flexible constraints and reorganizes configuration
tests/unit-tests/*.php Makes test methods public and improves code consistency
tests/bootstrap.php Changes include statements to include_once for better reliability
Comments suppressed due to low confidence (1)

tests/unit-tests/test-event.php:73

  • Using assertEqualsWithDelta instead of assertEquals for timestamp comparison is a good improvement as it accounts for minor timing variations during test execution.
		$this->assertEqualsWithDelta( time() + HOUR_IN_SECONDS, $event->get_timestamp(), 1 );

@rinatkhaziev rinatkhaziev merged commit 59634cc into main Jul 21, 2025
22 checks passed
@rinatkhaziev rinatkhaziev deleted the fix/issues branch July 21, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Orchestrate Sites CLI command generating a huge amount of implicit float conversion warnings on PHP >= 8.1

3 participants