Skip to content

Dev#12

Closed
dannorthern wants to merge 9 commits intomainfrom
dev
Closed

Dev#12
dannorthern wants to merge 9 commits intomainfrom
dev

Conversation

@dannorthern
Copy link
Member

No description provided.

- 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
@dannorthern dannorthern requested a review from Copilot August 11, 2025 18:33
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 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 );
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
$this->assertIsInt( 1 );
$reading_time = ReadingTime::calculate( $text );
$this->assertIsInt( $reading_time );
$this->assertEquals( 1, $reading_time );

Copilot uses AI. Check for mistakes.
$text = str_repeat( 'word ', 500 );

// This is a placeholder assertion
$this->assertIsInt( 2 );
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
$this->assertIsInt( 2 );
// Assert the calculated reading time is as expected (2 or 3 minutes depending on implementation)
$this->assertEquals( 2, ReadingTime::calculate( $text ) );

Copilot uses AI. Check for mistakes.
$text = str_repeat( 'word ', 2000 );

// This is a placeholder assertion
$this->assertIsInt( 10 );
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
$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 ) );

Copilot uses AI. Check for mistakes.
$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 );
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
$this->assertIsString( $html_content );
$reading_time = ReadingTime::calculate( $html_content );
$this->assertIsInt( $reading_time );
$this->assertEquals( 1, $reading_time );

Copilot uses AI. Check for mistakes.
->andReturn( '' );

// Empty content should return 1 minute minimum
$this->assertIsInt( 1 );
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
$this->assertIsInt( 1 );
$result = ReadingTime::calculate('');
$this->assertIsInt($result);
$this->assertEquals(1, $result);

Copilot uses AI. Check for mistakes.
$text = 'This text has special characters: !@#$%^&*() and émojis 😀';

// Should handle special characters properly
$this->assertIsString( $text );
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
$this->assertIsString( $text );
$this->assertIsInt( ReadingTime::calculate( $text ) );

Copilot uses AI. Check for mistakes.
namespace BuiltNorth\WPUtility\Helpers;

use BuiltNorth\WPUtility\Helper;

Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The SectionPattern class is missing a docblock comment describing its purpose and functionality.

Suggested change
/**
* 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.
*/

Copilot uses AI. Check for mistakes.
*/
public static function render($attributes)
{
$pattern = !empty($attributes['pattern']) ? $attributes['pattern'] : '';
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Using the null coalescing operator (??) would be more concise and handle null values better: $pattern = $attributes['pattern'] ?? '';

Suggested change
$pattern = !empty($attributes['pattern']) ? $attributes['pattern'] : '';
$pattern = $attributes['pattern'] ?? '';

Copilot uses AI. Check for mistakes.
public static function render($attributes)
{
$pattern = !empty($attributes['pattern']) ? $attributes['pattern'] : '';
$pattern_align = !empty($attributes['patternAlign']) ? $attributes['patternAlign'] : 'center center';
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Using the null coalescing operator (??) would be more concise: $pattern_align = $attributes['patternAlign'] ?? 'center center';

Suggested change
$pattern_align = !empty($attributes['patternAlign']) ? $attributes['patternAlign'] : 'center center';
$pattern_align = $attributes['patternAlign'] ?? 'center center';

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants