Skip to content

Commit 07cd4f3

Browse files
authored
Tests: improve Windows compatibility (#82)
1 parent 1253d63 commit 07cd4f3

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

features/sidebar.feature

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ Feature: Manage WordPress sidebars
3030
0
3131
"""
3232

33-
When I run `wp eval 'update_option( "sidebars_widgets", array_merge( wp_get_sidebars_widgets(), [ "orphaned-sidebar-1" => [] ] ) );'`
33+
Given a sidebar-update.php file:
34+
"""
35+
<?php
36+
update_option( 'sidebars_widgets', array_merge( wp_get_sidebars_widgets(), [ 'orphaned-sidebar-1' => [] ] ) );
37+
"""
38+
When I run `wp eval-file sidebar-update.php`
3439
And I run `wp sidebar list --inactive --fields=id --format=csv`
3540
Then STDOUT should be:
3641
"""

features/widget-reset.feature

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Feature: Reset WordPress sidebars
129129
text-1
130130
"""
131131

132+
@skip-windows
132133
Scenario: Testing movement of widgets while reset
133134
When I run `wp widget add calendar sidebar-2 --title="Calendar"`
134135
Then STDOUT should not be empty
@@ -141,6 +142,8 @@ Feature: Reset WordPress sidebars
141142
"""
142143
calendar-1 search-1
143144
"""
145+
146+
# TODO: Investigate why output is not empty on Windows
144147
When I run `wp widget list wp_inactive_widgets --format=ids`
145148
Then STDOUT should be empty
146149

@@ -166,7 +169,15 @@ Feature: Reset WordPress sidebars
166169
Then STDOUT should not be empty
167170

168171
# Simulate an inactive (unregistered) sidebar by moving widget data to an orphaned key
169-
When I run `wp eval '$w = wp_get_sidebars_widgets(); $w["orphaned-sidebar-1"] = $w["sidebar-1"]; $w["sidebar-1"] = []; update_option( "sidebars_widgets", $w );'`
172+
Given a widget-orphaned-reset.php file:
173+
"""
174+
<?php
175+
$w = wp_get_sidebars_widgets();
176+
$w['orphaned-sidebar-1'] = $w['sidebar-1'];
177+
$w['sidebar-1'] = [];
178+
update_option( 'sidebars_widgets', $w );
179+
"""
180+
When I run `wp eval-file widget-orphaned-reset.php`
170181

171182
And I run `wp sidebar list --inactive --fields=id --format=ids`
172183
Then STDOUT should be:

features/widget.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Feature: Manage widgets in WordPress sidebar
1414
And I run `wp widget add search sidebar-2 --title="Quick Search"`
1515
And I run `wp widget add text sidebar-3 --title="Text"`
1616

17+
@skip-windows
1718
Scenario: Widget CRUD
1819
When I run `wp widget list sidebar-1 --fields=name,id,position`
1920
Then STDOUT should be a table containing rows:
@@ -55,6 +56,7 @@ Feature: Manage widgets in WordPress sidebar
5556
| text | text-2 | 3 |
5657

5758
When I run `wp widget list wp_inactive_widgets --fields=name,id,position`
59+
# TODO: Investigate why calendar is at position 7 on Windows.
5860
Then STDOUT should be a table containing rows:
5961
| name | id | position |
6062
| text | text-1 | 1 |

0 commit comments

Comments
 (0)