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
- Remove composer.lock (libraries shouldn't commit lock files) - Add composer.lock to .gitignore - Allows CI to install dependencies from Packagist
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive testing infrastructure to the WP Utility library, setting up PHPUnit tests with WP_Mock for WordPress-specific functionality. The changes include test configuration files, GitHub Actions workflows for CI/CD, and actual test implementations for the core classes.
- Adds PHPUnit configuration and WP_Mock testing framework setup for WordPress development
- Implements unit tests for main classes (Utility, Helper, Component) and specific utilities like ReadingTime
- Sets up GitHub Actions workflows for automated testing and release management
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/bootstrap.php | Configures PHPUnit testing environment with WordPress constants and WP_Mock setup |
| tests/WPMockTestCase.php | Base test case class providing WordPress-specific testing utilities |
| tests/Unit/*.php | Unit tests for core classes verifying singleton patterns and class existence |
| tests/Unit/Utilities/ReadingTimeTest.php | Specific tests for ReadingTime utility functionality |
| phpunit.xml | PHPUnit configuration defining test suites and coverage settings |
| .github/workflows/*.yml | CI/CD workflows for automated testing and release management |
| inc/Components/Button.php | Adds appearance parameter to button component |
| inc/Components/Image.php | Improves SVG handling in image component |
| inc/Helpers/SectionPattern.php | New helper for rendering section patterns from SVG files |
| composer.json | Updates dependencies and adds testing scripts |
|
|
||
| // 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.
This assertion is testing that the integer 1 is an integer, which will always pass. It should be testing the actual result of a ReadingTime calculation method call.
| $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.
This assertion is testing that the integer 2 is an integer, which will always pass. It should be testing the actual result of a ReadingTime calculation method call.
| $this->assertIsInt( 2 ); | |
| // Calculate reading time and assert expected value | |
| $reading_time = ReadingTime::calculate( $text ); | |
| $this->assertIsInt( $reading_time ); | |
| // Assuming 500 words at 200 wpm = 3 minutes (rounded up) | |
| $this->assertEquals( 3, $reading_time ); |
| $text = str_repeat( 'word ', 2000 ); | ||
|
|
||
| // This is a placeholder assertion | ||
| $this->assertIsInt( 10 ); |
There was a problem hiding this comment.
This assertion is testing that the integer 10 is an integer, which will always pass. It should be testing the actual result of a ReadingTime calculation method call.
| $this->assertIsInt( 10 ); | |
| // Calculate reading time for 2000 words | |
| $reading_time = ReadingTime::calculate( $text ); | |
| $this->assertIsInt( $reading_time ); | |
| // For 2000 words at 200-250 wpm, expect 8-10 minutes (rounded up) | |
| $this->assertGreaterThanOrEqual( 8, $reading_time ); | |
| $this->assertLessThanOrEqual( 10, $reading_time ); |
| $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.
This assertion is testing that the input HTML content is a string, which doesn't test the ReadingTime functionality. It should be testing the actual result of a ReadingTime calculation method call.
| $this->assertIsString( $html_content ); | |
| $reading_time = ReadingTime::calculate( $html_content ); | |
| $this->assertIsInt( $reading_time ); | |
| // The plain text is: "This is some text with HTML tags." | |
| // That's 8 words, so should return 1 minute minimum | |
| $this->assertEquals( 1, $reading_time ); |
| ->andReturn( '' ); | ||
|
|
||
| // Empty content should return 1 minute minimum | ||
| $this->assertIsInt( 1 ); |
There was a problem hiding this comment.
This assertion is testing that the integer 1 is an integer, which will always pass. It should be testing the actual result of a ReadingTime calculation method call.
| $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.
This assertion is testing that the input text is a string, which doesn't test the ReadingTime functionality. It should be testing the actual result of a ReadingTime calculation method call.
| $this->assertIsString( $text ); | |
| $reading_time = ReadingTime::calculate( $text ); | |
| $this->assertIsInt( $reading_time ); |
| namespace BuiltNorth\WPUtility\Helpers; | ||
|
|
||
| use BuiltNorth\WPUtility\Helper; | ||
|
|
There was a problem hiding this comment.
The class is missing a docblock comment explaining its purpose, usage, and any important details about the section pattern functionality.
| /** | |
| * Helper class for rendering section background patterns from theme SVG files. | |
| * | |
| * This class provides functionality to render SVG-based background patterns for sections, | |
| * using pattern files located in the theme's assets directory. It supports configuration | |
| * via a feature manager (if available), allowing for enabling/disabling patterns and | |
| * specifying available patterns and directories. The class handles both child and parent | |
| * theme contexts, ensuring the correct SVG is loaded. The main usage is through the static | |
| * render() method, which outputs the HTML for the pattern, including proper alignment classes. | |
| * | |
| * Usage: | |
| * echo SectionPattern::render($attributes); | |
| * | |
| * @package BuiltNorth\WPUtility\Helpers | |
| */ |
No description provided.