Changeset 42381
- Timestamp:
- 12/09/2017 11:08:24 PM (7 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/class-basic-object.php
r38444 r42381 7 7 * @since 4.7.0 8 8 */ 9 10 trigger_error( __FILE__ . ' is deprecated since version 5.0.0 with no alternative available.' ); 9 11 10 12 /** -
trunk/tests/phpunit/includes/class-basic-subclass.php
r38444 r42381 8 8 */ 9 9 10 trigger_error( __FILE__ . ' is deprecated since version 5.0.0 with no alternative available.' ); 11 10 12 /** 11 13 * Class used to test accessing methods and properties. -
trunk/tests/phpunit/includes/functions.php
r42343 r42381 1 1 <?php 2 3 require_once dirname( __FILE__ ) . '/class-basic-object.php';4 require_once dirname( __FILE__ ) . '/class-basic-subclass.php';5 2 6 3 /** -
trunk/tests/phpunit/tests/basic.php
r42343 r42381 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 }41 42 // two tests for a lame bug in PHPUnit that broke the $GLOBALS reference43 function test_globals() {44 global $test_foo;45 $test_foo = array( 'foo', 'bar', 'baz' );46 47 function test_globals_foo() {48 unset( $GLOBALS['test_foo'][1] );49 }50 51 test_globals_foo();52 53 $this->assertEquals(54 $test_foo, array(55 0 => 'foo',56 2 => 'baz',57 )58 );59 $this->assertEquals( $test_foo, $GLOBALS['test_foo'] );60 }61 62 function test_globals_bar() {63 global $test_bar;64 $test_bar = array( 'a', 'b', 'c' );65 $this->assertEquals( $test_bar, $GLOBALS['test_bar'] );66 40 } 67 41 … … 111 85 $this->assertEquals( $expected, mask_input_value( $in ) ); 112 86 } 113 114 /**115 * @ticket 17884116 */117 function test_setting_nonexistent_arrays() {118 $page = 1;119 $field = 'settings';120 121 $empty_array[ $page ][ $field ] = 'foo';122 123 // Assertion not strictly needed; we mainly want to show that a notice is not thrown.124 unset( $empty_array[ $page ]['bar']['baz'] );125 $this->assertFalse( isset( $empty_array[ $page ]['bar']['baz'] ) );126 }127 128 function test_magic_getter() {129 $basic = new Basic_Object();130 131 $this->assertEquals( 'bar', $basic->foo );132 }133 134 function test_subclass_magic_getter() {135 $basic = new Basic_Subclass();136 137 $this->assertEquals( 'bar', $basic->foo );138 }139 140 function test_call_method() {141 $basic = new Basic_Object();142 143 $this->assertEquals( 'maybe', $basic->callMe() );144 }145 146 function test_subclass_call_method() {147 $basic = new Basic_Subclass();148 149 $this->assertEquals( 'maybe', $basic->callMe() );150 }151 152 function test_subclass_isset() {153 $basic = new Basic_Subclass();154 155 $this->assertTrue( isset( $basic->foo ) );156 }157 158 function test_subclass_unset() {159 $basic = new Basic_Subclass();160 161 unset( $basic->foo );162 163 $this->assertFalse( isset( $basic->foo ) );164 }165 166 function test_switch_order() {167 $return = $this->_switch_order_helper( 1 );168 $this->assertEquals( 'match', $return );169 }170 171 function _switch_order_helper( $var ) {172 $return = 'no match';173 switch ( $var ) {174 default:175 break;176 case 1:177 $return = 'match';178 break;179 }180 181 return $return;182 }183 87 }
Note: See TracChangeset
for help on using the changeset viewer.