-
Notifications
You must be signed in to change notification settings - Fork 94
Add font library commands for WordPress 6.5+ #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
58047b4
Initial plan
Copilot 7bc9ba0
Add font library commands (collection, family, face)
Copilot 83b0161
Fix Behat syntax in font-collection feature file
Copilot bfdbe14
Remove redundant version checks from command methods
Copilot 2e49453
Refactor: Extract helper method and version check callback
Copilot 7fe7f7a
Fix error message formatting for consistency
Copilot 0850b36
Add `is-registered`
swissspidy 9a2bfbb
Changes before error encountered
Copilot 3d38b64
Add font library advanced commands (list-families, list-categories, i…
Copilot dae3d93
Add Behat tests for new font library commands
Copilot 71c790c
Fix incorrect line endings
swissspidy 18282ba
Some manual fixes
swissspidy d84384c
Address code review feedback: fix field names and array safety
Copilot 2604149
Merge branch 'main' into copilot/add-font-library-commands
swissspidy 2e97f1a
Tweak tests
swissspidy d0516dd
Merge branch 'main' into copilot/add-font-library-commands
swissspidy 273e156
Merge branch 'main' into copilot/add-font-library-commands
swissspidy c537a7f
Merge branch 'main' into copilot/add-font-library-commands
swissspidy 021f0f8
PHPStan fix
swissspidy f0b9178
Remove font family/face CRUD commands, keep install commands only
Copilot 58fe6d5
Merge branch 'main' into copilot/add-font-library-commands
swissspidy 7a88c0c
Formatting fixes
swissspidy f6cb7e7
Fix code review issues: field names, types, docblocks, error messages
Copilot 437a438
Update src/Font_Face_Command.php
swissspidy f9ee5a2
Extract format_categories helper to remove duplicated formatting logic
Copilot 80b8598
Fix Behat test to include categories column in font collection list
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| Feature: Manage WordPress font collections | ||
|
|
||
| Background: | ||
| Given a WP install | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Listing font collections | ||
| When I try `wp font collection list` | ||
| Then STDOUT should be a table containing rows: | ||
| | slug | name | description | | ||
| | google-fonts | Google Fonts | Install from Google Fonts. Fonts are copied to and served from your site. | | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Getting a non-existent font collection | ||
| When I try `wp font collection get nonexistent-collection` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| doesn't exist | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Checking whether a font collection is registered | ||
| When I try `wp font collection is-registered nonexistent-collection` | ||
| Then the return code should be 1 | ||
|
|
||
| When I run `wp font collection is-registered google-fonts` | ||
| Then the return code should be 0 | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Listing font families in a collection | ||
| When I run `wp font collection list-families google-fonts --format=count` | ||
| Then STDOUT should be a number | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Listing font families in a collection with fields | ||
| When I run `wp font collection list-families google-fonts --fields=slug,name --format=csv` | ||
| Then STDOUT should contain: | ||
| """ | ||
| slug,name | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Filtering font families by category | ||
| When I run `wp font collection list-families google-fonts --category=sans-serif --format=count` | ||
| Then STDOUT should be a number | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Listing categories in a collection | ||
| When I run `wp font collection list-categories google-fonts --format=csv` | ||
| Then STDOUT should contain: | ||
| """ | ||
| slug,name | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Getting a non-existent collection for list-families | ||
| When I try `wp font collection list-families nonexistent-collection` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| doesn't exist | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Getting a non-existent collection for list-categories | ||
| When I try `wp font collection list-categories nonexistent-collection` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| doesn't exist | ||
| """ | ||
|
|
||
| @less-than-wp-6.5 | ||
| Scenario: Font collection commands fail on WordPress < 6.5 | ||
| Given a WP install | ||
| When I try `wp font collection list` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| Requires WordPress 6.5 or greater | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| Feature: Manage WordPress font faces | ||
|
|
||
| Background: | ||
| Given a WP install | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Creating a font face | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
|
|
||
| When I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Regular" --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {FONT_FACE_ID} | ||
|
|
||
| When I run `wp font face get {FONT_FACE_ID} --field=post_title` | ||
| Then STDOUT should be: | ||
| """ | ||
| Regular | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Listing font faces | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
| And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Regular" --porcelain` | ||
| And save STDOUT as {FACE1} | ||
| And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Bold" --porcelain` | ||
| And save STDOUT as {FACE2} | ||
|
|
||
| When I run `wp font face list --format=csv --fields=ID,post_title,post_parent` | ||
|
swissspidy marked this conversation as resolved.
Outdated
|
||
| Then STDOUT should contain: | ||
| """ | ||
| Regular | ||
| """ | ||
| And STDOUT should contain: | ||
| """ | ||
| Bold | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Listing font faces by family | ||
| Given I run `wp font family create --post_title="Family One" --porcelain` | ||
| And save STDOUT as {FAMILY1} | ||
| And I run `wp font family create --post_title="Family Two" --porcelain` | ||
| And save STDOUT as {FAMILY2} | ||
| And I run `wp font face create --post_parent={FAMILY1} --post_title="F1 Regular" --porcelain` | ||
| And I run `wp font face create --post_parent={FAMILY2} --post_title="F2 Regular" --porcelain` | ||
|
|
||
| When I run `wp font face list --post_parent={FAMILY1} --format=csv --fields=post_title` | ||
|
swissspidy marked this conversation as resolved.
Outdated
|
||
| Then STDOUT should contain: | ||
| """ | ||
| F1 Regular | ||
| """ | ||
| And STDOUT should not contain: | ||
| """ | ||
| F2 Regular | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Getting a font face | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
| And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Bold" --porcelain` | ||
| And save STDOUT as {FONT_FACE_ID} | ||
|
|
||
| When I try `wp font face get {FONT_FACE_ID}` | ||
| Then the return code should be 0 | ||
| And STDOUT should contain: | ||
| """ | ||
| Bold | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Updating a font face | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
| And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Old Name" --porcelain` | ||
| And save STDOUT as {FONT_FACE_ID} | ||
|
|
||
| When I run `wp font face update {FONT_FACE_ID} --post_title="New Name"` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: Updated font face | ||
| """ | ||
|
|
||
| When I run `wp font face get {FONT_FACE_ID} --field=post_title` | ||
|
||
| Then STDOUT should be: | ||
| """ | ||
| New Name | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Deleting a font face | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
| And I run `wp font face create --post_parent={FONT_FAMILY_ID} --post_title="Delete Me" --porcelain` | ||
| And save STDOUT as {FONT_FACE_ID} | ||
|
|
||
| When I run `wp font face delete {FONT_FACE_ID}` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: Deleted font face | ||
| """ | ||
|
|
||
| When I try `wp font face get {FONT_FACE_ID}` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| doesn't exist | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Creating a font face requires parent | ||
| When I try `wp font face create --post_title="Regular"` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| --post_parent parameter is required | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Creating a font face with invalid parent | ||
| When I try `wp font face create --post_parent=999999 --post_title="Regular"` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| doesn't exist | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Installing a font face | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
|
|
||
| When I run `wp font face install {FONT_FAMILY_ID} --src="https://example.com/font.woff2" --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {FONT_FACE_ID} | ||
|
|
||
| When I run `wp font face get {FONT_FACE_ID} --field=post_parent` | ||
|
swissspidy marked this conversation as resolved.
Outdated
|
||
| Then STDOUT should be: | ||
| """ | ||
| {FONT_FAMILY_ID} | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Installing a font face with custom properties | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
|
|
||
| When I run `wp font face install {FONT_FAMILY_ID} --src="font.woff2" --font-weight=700 --font-style=italic --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {FONT_FACE_ID} | ||
|
|
||
| When I run `wp font face get {FONT_FACE_ID} --field=post_title` | ||
|
swissspidy marked this conversation as resolved.
Outdated
|
||
| Then STDOUT should contain: | ||
| """ | ||
| 700 | ||
| """ | ||
| And STDOUT should contain: | ||
| """ | ||
| italic | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Installing a font face with invalid parent | ||
| When I try `wp font face install 999999 --src="font.woff2"` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| doesn't exist | ||
| """ | ||
|
|
||
| @require-wp-6.5 | ||
| Scenario: Installing a font face without required src parameter | ||
| Given I run `wp font family create --post_title="Test Family" --porcelain` | ||
| And save STDOUT as {FONT_FAMILY_ID} | ||
|
|
||
| When I try `wp font face install {FONT_FAMILY_ID}` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| --src parameter is required | ||
| """ | ||
|
|
||
| @less-than-wp-6.5 | ||
| Scenario: Font face commands fail on WordPress < 6.5 | ||
| When I try `wp font face list` | ||
| Then the return code should be 1 | ||
| And STDERR should contain: | ||
| """ | ||
| Requires WordPress 6.5 or greater | ||
| """ | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.