Skip to content

Commit dae3d93

Browse files
Copilotswissspidy
andcommitted
Add Behat tests for new font library commands
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 3d38b64 commit dae3d93

3 files changed

Lines changed: 132 additions & 0 deletions

File tree

‎features/font-collection.feature‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,50 @@ Feature: Manage WordPress font collections
2727
When I run `wp font collection is-registered google-fonts`
2828
Then the return code should be 0
2929

30+
@require-wp-6.5
31+
Scenario: Listing font families in a collection
32+
When I run `wp font collection list-families google-fonts --format=count`
33+
Then STDOUT should be a number
34+
35+
@require-wp-6.5
36+
Scenario: Listing font families in a collection with fields
37+
When I run `wp font collection list-families google-fonts --fields=slug,name --format=csv`
38+
Then STDOUT should contain:
39+
"""
40+
slug,name
41+
"""
42+
43+
@require-wp-6.5
44+
Scenario: Filtering font families by category
45+
When I run `wp font collection list-families google-fonts --category=sans-serif --format=count`
46+
Then STDOUT should be a number
47+
48+
@require-wp-6.5
49+
Scenario: Listing categories in a collection
50+
When I run `wp font collection list-categories google-fonts --format=csv`
51+
Then STDOUT should contain:
52+
"""
53+
slug,name
54+
"""
55+
56+
@require-wp-6.5
57+
Scenario: Getting a non-existent collection for list-families
58+
When I try `wp font collection list-families nonexistent-collection`
59+
Then the return code should be 1
60+
And STDERR should contain:
61+
"""
62+
doesn't exist
63+
"""
64+
65+
@require-wp-6.5
66+
Scenario: Getting a non-existent collection for list-categories
67+
When I try `wp font collection list-categories nonexistent-collection`
68+
Then the return code should be 1
69+
And STDERR should contain:
70+
"""
71+
doesn't exist
72+
"""
73+
3074
@less-than-wp-6.5
3175
Scenario: Font collection commands fail on WordPress < 6.5
3276
Given a WP install

‎features/font-face.feature‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,61 @@ Feature: Manage WordPress font faces
127127
doesn't exist
128128
"""
129129

130+
@require-wp-6.5
131+
Scenario: Installing a font face
132+
Given I run `wp font family create --post_title="Test Family" --porcelain`
133+
And save STDOUT as {FONT_FAMILY_ID}
134+
135+
When I run `wp font face install {FONT_FAMILY_ID} --src="https://example.com/font.woff2" --porcelain`
136+
Then STDOUT should be a number
137+
And save STDOUT as {FONT_FACE_ID}
138+
139+
When I run `wp font face get {FONT_FACE_ID} --field=post_parent`
140+
Then STDOUT should be:
141+
"""
142+
{FONT_FAMILY_ID}
143+
"""
144+
145+
@require-wp-6.5
146+
Scenario: Installing a font face with custom properties
147+
Given I run `wp font family create --post_title="Test Family" --porcelain`
148+
And save STDOUT as {FONT_FAMILY_ID}
149+
150+
When I run `wp font face install {FONT_FAMILY_ID} --src="font.woff2" --font-weight=700 --font-style=italic --porcelain`
151+
Then STDOUT should be a number
152+
And save STDOUT as {FONT_FACE_ID}
153+
154+
When I run `wp font face get {FONT_FACE_ID} --field=post_title`
155+
Then STDOUT should contain:
156+
"""
157+
700
158+
"""
159+
And STDOUT should contain:
160+
"""
161+
italic
162+
"""
163+
164+
@require-wp-6.5
165+
Scenario: Installing a font face with invalid parent
166+
When I try `wp font face install 999999 --src="font.woff2"`
167+
Then the return code should be 1
168+
And STDERR should contain:
169+
"""
170+
doesn't exist
171+
"""
172+
173+
@require-wp-6.5
174+
Scenario: Installing a font face without required src parameter
175+
Given I run `wp font family create --post_title="Test Family" --porcelain`
176+
And save STDOUT as {FONT_FAMILY_ID}
177+
178+
When I try `wp font face install {FONT_FAMILY_ID}`
179+
Then the return code should be 1
180+
And STDERR should contain:
181+
"""
182+
--src parameter is required
183+
"""
184+
130185
@less-than-wp-6.5
131186
Scenario: Font face commands fail on WordPress < 6.5
132187
When I try `wp font face list`

‎features/font-family.feature‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,39 @@ Feature: Manage WordPress font families
8888
doesn't exist
8989
"""
9090

91+
@require-wp-6.5
92+
Scenario: Installing a font family from a collection
93+
When I run `wp font family install google-fonts "dm sans" --porcelain`
94+
Then STDOUT should be a number
95+
And save STDOUT as {FONT_FAMILY_ID}
96+
97+
When I run `wp font family get {FONT_FAMILY_ID} --field=post_title`
98+
Then STDOUT should contain:
99+
"""
100+
DM Sans
101+
"""
102+
103+
When I run `wp font face list --post_parent={FONT_FAMILY_ID} --format=count`
104+
Then STDOUT should be a number
105+
106+
@require-wp-6.5
107+
Scenario: Installing a font family from a non-existent collection
108+
When I try `wp font family install nonexistent-collection roboto`
109+
Then the return code should be 1
110+
And STDERR should contain:
111+
"""
112+
doesn't exist
113+
"""
114+
115+
@require-wp-6.5
116+
Scenario: Installing a non-existent font family from a collection
117+
When I try `wp font family install google-fonts nonexistent-family`
118+
Then the return code should be 1
119+
And STDERR should contain:
120+
"""
121+
not found
122+
"""
123+
91124
@less-than-wp-6.5
92125
Scenario: Font family commands fail on WordPress < 6.5
93126
When I try `wp font family list`

0 commit comments

Comments
 (0)