Changeset 52010 for trunk/tests/phpunit/tests/meta.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/meta.php
r51568 r52010 7 7 protected $updated_mids = array(); 8 8 9 function set_up() {9 public function set_up() { 10 10 parent::set_up(); 11 11 $this->author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); … … 14 14 } 15 15 16 function _meta_sanitize_cb( $meta_value, $meta_key, $meta_type ) {16 public function meta_sanitize_cb( $meta_value, $meta_key, $meta_type ) { 17 17 return 'sanitized'; 18 18 } 19 19 20 function test_sanitize_meta() {20 public function test_sanitize_meta() { 21 21 $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); 22 22 $this->assertSame( 'unsanitized', $meta ); 23 23 24 register_meta( 'post', 'some_meta', array( $this, ' _meta_sanitize_cb' ) );24 register_meta( 'post', 'some_meta', array( $this, 'meta_sanitize_cb' ) ); 25 25 $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); 26 26 $this->assertSame( 'sanitized', $meta ); 27 27 } 28 28 29 function test_delete_metadata_by_mid() {29 public function test_delete_metadata_by_mid() { 30 30 // Let's try and delete a non-existing ID, non existing meta. 31 31 $this->assertFalse( delete_metadata_by_mid( 'user', 0 ) ); … … 42 42 } 43 43 44 function test_update_metadata_by_mid() {44 public function test_update_metadata_by_mid() { 45 45 // Setup. 46 46 $meta = get_metadata_by_mid( 'user', $this->meta_id ); … … 105 105 } 106 106 107 function test_metadata_exists() {107 public function test_metadata_exists() { 108 108 $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'foobarbaz' ) ); 109 109 $this->assertTrue( metadata_exists( 'user', $this->author->ID, 'meta_key' ) ); … … 115 115 * @ticket 22746 116 116 */ 117 function test_metadata_exists_with_filter() {117 public function test_metadata_exists_with_filter() { 118 118 // Let's see if it returns the correct value when adding a filter. 119 119 add_filter( 'get_user_metadata', '__return_zero' ); … … 126 126 * @ticket 18158 127 127 */ 128 function test_user_metadata_not_exists() {128 public function test_user_metadata_not_exists() { 129 129 $u = get_users( 130 130 array( … … 199 199 } 200 200 201 function test_metadata_slashes() {201 public function test_metadata_slashes() { 202 202 $key = __FUNCTION__; 203 203 $value = 'Test\\singleslash'; … … 232 232 * @ticket 16814 233 233 */ 234 function test_meta_type_cast() {234 public function test_meta_type_cast() { 235 235 $post_id1 = self::factory()->post->create(); 236 236 add_post_meta( $post_id1, 'num_as_longtext', 123 ); … … 302 302 } 303 303 304 function test_meta_cache_order_asc() {304 public function test_meta_cache_order_asc() { 305 305 $post_id = self::factory()->post->create(); 306 306 $colors = array( 'red', 'blue', 'yellow', 'green' ); … … 322 322 * @ticket 28315 323 323 */ 324 function test_non_numeric_object_id() {324 public function test_non_numeric_object_id() { 325 325 $this->assertFalse( add_metadata( 'user', array( 1 ), 'meta_key', 'meta_value' ) ); 326 326 $this->assertFalse( update_metadata( 'user', array( 1 ), 'meta_key', 'meta_new_value' ) ); … … 333 333 * @ticket 28315 334 334 */ 335 function test_non_numeric_meta_id() {335 public function test_non_numeric_meta_id() { 336 336 $this->assertFalse( get_metadata_by_mid( 'user', array( 1 ) ) ); 337 337 $this->assertFalse( update_metadata_by_mid( 'user', array( 1 ), 'meta_new_value' ) ); … … 342 342 * @ticket 37746 343 343 */ 344 function test_negative_meta_id() {344 public function test_negative_meta_id() { 345 345 $negative_mid = $this->meta_id * -1; 346 346 … … 354 354 * @ticket 37746 355 355 */ 356 function test_floating_meta_id() {356 public function test_floating_meta_id() { 357 357 $floating_mid = $this->meta_id + 0.1337; 358 358 … … 366 366 * @ticket 37746 367 367 */ 368 function test_string_point_zero_meta_id() {368 public function test_string_point_zero_meta_id() { 369 369 $meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value_2' ); 370 370
Note: See TracChangeset
for help on using the changeset viewer.