Conversation
- Create SectionPattern helper class following existing helper pattern - Uses configured pattern_directory with fallback to /src/assets/background-patterns/ - Applies SVG escaping via Helper::EscapeSVG()
- Add CSS variables for reusable button padding at root level - Restructure buttons.scss with clear sections and documentation - Add fill (default) and outline appearance variants - Implement hover states with color reversals for all button styles - Update outline buttons to use currentColor for text with styled borders - Maintain existing icon sizing with improved CSS variable naming
- Update SectionPattern::render() to handle patternAlign attribute - Add alignment mapping for all 9 positions - Output classes in pattern-align--x-x format for CSS targeting
- Add PHPUnit test configuration - Set up test bootstrap with WP_Mock support
- Test matrix for PHP 8.1, 8.2, 8.3, 8.4 - PHPUnit tests with code coverage - PHPCS coding standards validation - PHP compatibility checks - Security vulnerability scanning - Codecov integration for coverage reports - Manual workflow dispatch support
- Remove version field from composer.json (use git tags instead) - Update release workflow to skip composer version bumps - Follow Composer best practices for version management - Prevents constant merge conflicts between branches
There was a problem hiding this comment.
Pull Request Overview
This PR sets up a comprehensive testing infrastructure for the WP Utility package, including PHPUnit configuration, test cases, and CI/CD workflows.
Key Changes
- Adds PHPUnit test framework with WP_Mock for WordPress-specific testing
- Creates base test classes and unit tests for core components (Utility, Helper, Component classes)
- Updates composer.json dependencies and scripts for testing and code quality tools
- Implements GitHub Actions workflows for automated testing and releases
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/bootstrap.php | Bootstrap file for PHPUnit with WordPress mocks and constants |
| tests/WPMockTestCase.php | Base test case class extending WP_Mock functionality |
| tests/Unit/*.php | Unit test files for main utility classes |
| tests/Unit/Utilities/ReadingTimeTest.php | Specific tests for ReadingTime utility functionality |
| phpunit.xml | PHPUnit configuration with test suites and coverage settings |
| phpcs.xml | PHP CodeSniffer configuration for coding standards |
| .phpunit.result.cache | PHPUnit test result cache file |
| .github/workflows/*.yml | CI/CD workflows for testing and automated releases |
| inc/Helpers/SectionPattern.php | New helper class for rendering section patterns |
| inc/Components/Image.php | Enhanced image component with SVG support |
| inc/Components/Button.php | Updated button component with appearance parameter |
| composer.json | Updated dependencies and scripts for development tools |
|
|
||
| // Assuming average reading speed of 200-250 words per minute | ||
| // 100 words should return 1 minute | ||
| $this->assertIsInt( 1 ); |
There was a problem hiding this comment.
The test is asserting that the integer 1 is an integer, which will always pass. This should be testing the actual reading time calculation result from the ReadingTime utility.
| $this->assertIsInt( 1 ); | |
| $reading_time = ReadingTime::calculate( $text ); | |
| $this->assertIsInt( $reading_time ); | |
| $this->assertEquals( 1, $reading_time ); |
| $text = str_repeat( 'word ', 500 ); | ||
|
|
||
| // This is a placeholder assertion | ||
| $this->assertIsInt( 2 ); |
There was a problem hiding this comment.
The test is asserting that the integer 2 is an integer, which will always pass. This should be testing the actual reading time calculation result from the ReadingTime utility.
| $this->assertIsInt( 2 ); | |
| // Assert the calculated reading time is as expected (2 or 3 minutes depending on implementation) | |
| $this->assertEquals( 2, ReadingTime::calculate( $text ) ); |
| $text = str_repeat( 'word ', 2000 ); | ||
|
|
||
| // This is a placeholder assertion | ||
| $this->assertIsInt( 10 ); |
There was a problem hiding this comment.
The test is asserting that the integer 10 is an integer, which will always pass. This should be testing the actual reading time calculation result from the ReadingTime utility.
| $this->assertIsInt( 10 ); | |
| // Assert that the calculated reading time is as expected (e.g., 10 minutes for 2000 words at 200 wpm) | |
| $this->assertEquals( 10, ReadingTime::calculate( $text ) ); |
| $html_content = '<p>This is <strong>some</strong> text with <a href="#">HTML</a> tags.</p>'; | ||
|
|
||
| // Should strip tags and calculate based on plain text | ||
| $this->assertIsString( $html_content ); |
There was a problem hiding this comment.
The test is asserting that the variable $html_content is a string, which will always pass since it's defined as a string literal above. This should be testing the actual reading time calculation result from the ReadingTime utility.
| $this->assertIsString( $html_content ); | |
| $reading_time = ReadingTime::calculate( $html_content ); | |
| $this->assertIsInt( $reading_time ); | |
| $this->assertEquals( 1, $reading_time ); |
| ->andReturn( '' ); | ||
|
|
||
| // Empty content should return 1 minute minimum | ||
| $this->assertIsInt( 1 ); |
There was a problem hiding this comment.
The test is asserting that the integer 1 is an integer, which will always pass. This should be testing the actual reading time calculation result from the ReadingTime utility.
| $this->assertIsInt( 1 ); | |
| $result = ReadingTime::calculate(''); | |
| $this->assertIsInt($result); | |
| $this->assertEquals(1, $result); |
| $text = 'This text has special characters: !@#$%^&*() and émojis 😀'; | ||
|
|
||
| // Should handle special characters properly | ||
| $this->assertIsString( $text ); |
There was a problem hiding this comment.
The test is asserting that the variable $text is a string, which will always pass since it's defined as a string literal above. This should be testing the actual reading time calculation result from the ReadingTime utility.
| $this->assertIsString( $text ); | |
| $this->assertIsInt( ReadingTime::calculate( $text ) ); |
| namespace BuiltNorth\WPUtility\Helpers; | ||
|
|
||
| use BuiltNorth\WPUtility\Helper; | ||
|
|
There was a problem hiding this comment.
The SectionPattern class is missing a docblock comment describing its purpose and functionality.
| /** | |
| * Class SectionPattern | |
| * | |
| * Provides functionality to render section patterns using SVG files from the theme. | |
| * Supports configurable pattern directories, alignment options, and integration with | |
| * a feature manager for enabling/disabling patterns and specifying available patterns. | |
| */ |
| */ | ||
| public static function render($attributes) | ||
| { | ||
| $pattern = !empty($attributes['pattern']) ? $attributes['pattern'] : ''; |
There was a problem hiding this comment.
[nitpick] Using the null coalescing operator (??) would be more concise and handle null values better: $pattern = $attributes['pattern'] ?? '';
| $pattern = !empty($attributes['pattern']) ? $attributes['pattern'] : ''; | |
| $pattern = $attributes['pattern'] ?? ''; |
| public static function render($attributes) | ||
| { | ||
| $pattern = !empty($attributes['pattern']) ? $attributes['pattern'] : ''; | ||
| $pattern_align = !empty($attributes['patternAlign']) ? $attributes['patternAlign'] : 'center center'; |
There was a problem hiding this comment.
[nitpick] Using the null coalescing operator (??) would be more concise: $pattern_align = $attributes['patternAlign'] ?? 'center center';
| $pattern_align = !empty($attributes['patternAlign']) ? $attributes['patternAlign'] : 'center center'; | |
| $pattern_align = $attributes['patternAlign'] ?? 'center center'; |
No description provided.