From 1a1994b20fcb4b46c4518ba18068d25d07696d38 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 30 May 2014 17:31:51 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/basic.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/phpunit/tests/basic.php b/tests/phpunit/tests/basic.php index dfea75d64c..06cf909c0c 100644 --- a/tests/phpunit/tests/basic.php +++ b/tests/phpunit/tests/basic.php @@ -159,4 +159,22 @@ EOF; $this->assertFalse( isset( $basic->foo ) ); } + + function test_switch_order() { + $return = $this->_switch_order_helper( 1 ); + $this->assertEquals( 'match', $return ); + } + + function _switch_order_helper( $var ) { + $return = 'no match'; + switch ( $var ) { + default: + break; + case 1: + $return = 'match'; + break; + } + + return $return; + } }