Changeset 42343 for trunk/tests/phpunit/tests/basic.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/basic.php
r40614 r42343 19 19 20 20 function test_package_json() { 21 $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' );22 $package_json = json_decode( $package_json, true );21 $package_json = file_get_contents( dirname( ABSPATH ) . '/package.json' ); 22 $package_json = json_decode( $package_json, true ); 23 23 list( $version ) = explode( '-', $GLOBALS['wp_version'] ); 24 24 // package.json uses x.y.z, so fill cleaned $wp_version for .0 releases … … 38 38 $node = $package_json['engines']['node']; 39 39 $this->assertRegExp( '~^=?\d+\.\d+\.\d+$~', $node, "package.json's node version cannot be a range." ); 40 40 } 41 41 42 42 // two tests for a lame bug in PHPUnit that broke the $GLOBALS reference 43 43 function test_globals() { 44 44 global $test_foo; 45 $test_foo = array( 'foo', 'bar', 'baz');45 $test_foo = array( 'foo', 'bar', 'baz' ); 46 46 47 47 function test_globals_foo() { 48 unset( $GLOBALS['test_foo'][1]);48 unset( $GLOBALS['test_foo'][1] ); 49 49 } 50 50 51 51 test_globals_foo(); 52 52 53 $this->assertEquals($test_foo, array(0=>'foo', 2=>'baz')); 54 $this->assertEquals($test_foo, $GLOBALS['test_foo']); 53 $this->assertEquals( 54 $test_foo, array( 55 0 => 'foo', 56 2 => 'baz', 57 ) 58 ); 59 $this->assertEquals( $test_foo, $GLOBALS['test_foo'] ); 55 60 } 56 61 57 62 function test_globals_bar() { 58 63 global $test_bar; 59 $test_bar = array( 'a', 'b', 'c');60 $this->assertEquals( $test_bar, $GLOBALS['test_bar']);64 $test_bar = array( 'a', 'b', 'c' ); 65 $this->assertEquals( $test_bar, $GLOBALS['test_bar'] ); 61 66 } 62 67 … … 64 69 65 70 function test_strip_ws() { 66 $this->assertEquals( '', strip_ws(''));67 $this->assertEquals( 'foo', strip_ws('foo'));68 $this->assertEquals( '', strip_ws("\r\n\t \n\r\t"));71 $this->assertEquals( '', strip_ws( '' ) ); 72 $this->assertEquals( 'foo', strip_ws( 'foo' ) ); 73 $this->assertEquals( '', strip_ws( "\r\n\t \n\r\t" ) ); 69 74 70 75 $in = "asdf\n"; … … 84 89 $expected .= "asdf\n"; 85 90 $expected .= "foo bar\n"; 86 $expected .= "foo";91 $expected .= 'foo'; 87 92 88 $this->assertEquals( $expected, strip_ws($in));93 $this->assertEquals( $expected, strip_ws( $in ) ); 89 94 90 95 } … … 104 109 <ol id="authors"><form action="?import=wordpress&step=2&id=" method="post"><input type="hidden" name="_wpnonce" value="***" /><input type="hidden" name="_wp_http_referer" value="wp-test.php" /><li>Current author: <strong>Alex Shiels</strong><br />Create user <input type="text" value="Alex Shiels" name="user[]" maxlength="30"> <br /> or map to existing<select name="userselect[0]"> 105 110 EOF; 106 $this->assertEquals( $expected, mask_input_value($in));111 $this->assertEquals( $expected, mask_input_value( $in ) ); 107 112 } 108 113 … … 111 116 */ 112 117 function test_setting_nonexistent_arrays() { 113 $page = 1;118 $page = 1; 114 119 $field = 'settings'; 115 120 116 $empty_array[ $page][$field] = 'foo';121 $empty_array[ $page ][ $field ] = 'foo'; 117 122 118 123 // Assertion not strictly needed; we mainly want to show that a notice is not thrown. 119 unset( $empty_array[ $page]['bar']['baz'] );124 unset( $empty_array[ $page ]['bar']['baz'] ); 120 125 $this->assertFalse( isset( $empty_array[ $page ]['bar']['baz'] ) ); 121 126 } … … 167 172 $return = 'no match'; 168 173 switch ( $var ) { 169 default:170 break;171 case 1:172 $return = 'match';173 break;174 default: 175 break; 176 case 1: 177 $return = 'match'; 178 break; 174 179 } 175 180
Note: See TracChangeset
for help on using the changeset viewer.