Skip to content

Commit 1a1994b

Browse files
committed
Adds a unit test to demonstrate that the order of case and default in a switch statement does not matter.
See #27882. git-svn-id: https://develop.svn.wordpress.org/trunk@28631 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a0dbf00 commit 1a1994b

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/phpunit/tests/basic.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,22 @@ function test_subclass_unset() {
159159

160160
$this->assertFalse( isset( $basic->foo ) );
161161
}
162+
163+
function test_switch_order() {
164+
$return = $this->_switch_order_helper( 1 );
165+
$this->assertEquals( 'match', $return );
166+
}
167+
168+
function _switch_order_helper( $var ) {
169+
$return = 'no match';
170+
switch ( $var ) {
171+
default:
172+
break;
173+
case 1:
174+
$return = 'match';
175+
break;
176+
}
177+
178+
return $return;
179+
}
162180
}

0 commit comments

Comments
 (0)