[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @group xprofile 5 */ 6 class BP_Tests_XProfile_Filters extends BP_UnitTestCase { 7 /** 8 * @group xprofilemeta 9 * @group bp_xprofile_filter_meta_query 10 */ 11 public function test_bp_xprofile_filter_meta_query_select() { 12 global $wpdb; 13 14 // update_meta_cache 15 $q = "SELECT xprofile_group_id, meta_key, meta_value FROM {$wpdb->xprofile_groupmeta} WHERE xprofile_group_id IN (1,2,3) ORDER BY xprofile_group_id ASC"; 16 $this->assertSame( "SELECT object_id AS xprofile_group_id, meta_key, meta_value FROM {$wpdb->xprofile_groupmeta} WHERE object_type = 'group' AND object_id IN (1,2,3) ORDER BY object_id ASC", bp_xprofile_filter_meta_query( $q ) ); 17 18 // add_metadata 19 $q = "SELECT COUNT(*) FROM {$wpdb->xprofile_groupmeta} WHERE meta_key = 'foo' AND xprofile_group_id = 5"; 20 $this->assertSame( "SELECT COUNT(*) FROM {$wpdb->xprofile_groupmeta} WHERE object_type = 'group' AND meta_key = 'foo' AND object_id = 5", bp_xprofile_filter_meta_query( $q ) ); 21 22 // delete_metadata 23 $q = "SELECT meta_id FROM {$wpdb->xprofile_groupmeta} WHERE meta_key = 'foo' AND xprofile_group_id = 5 AND meta_value = 'bar'"; 24 $this->assertSame( "SELECT meta_id FROM {$wpdb->xprofile_groupmeta} WHERE object_type = 'group' AND meta_key = 'foo' AND object_id = 5 AND meta_value = 'bar'", bp_xprofile_filter_meta_query( $q ) ); 25 } 26 27 /** 28 * @group xprofilemeta 29 * @group bp_xprofile_filter_meta_query 30 */ 31 public function test_bp_xprofile_filter_meta_query_insert() { 32 global $wpdb; 33 $q = "INSERT INTO `{$wpdb->xprofile_groupmeta}` (`xprofile_group_id`,`meta_key`,`meta_value`) VALUES (3,'foo','bar')"; 34 $this->assertSame( "INSERT INTO `{$wpdb->xprofile_groupmeta}` (`object_type`,`object_id`,`meta_key`,`meta_value`) VALUES ('group',3,'foo','bar')", bp_xprofile_filter_meta_query( $q ) ); 35 } 36 37 /** 38 * @group xprofilemeta 39 * @group bp_xprofile_filter_meta_query 40 */ 41 public function test_bp_xprofile_filter_meta_query_update() { 42 global $wpdb; 43 44 $q = "UPDATE `{$wpdb->xprofile_groupmeta}` SET meta_value = 'bar' WHERE xprofile_group_id = 3 AND meta_key = 'foo'"; 45 $this->assertSame( "UPDATE `{$wpdb->xprofile_groupmeta}` SET meta_value = 'bar' WHERE object_type = 'group' AND object_id = 3 AND meta_key = 'foo'", bp_xprofile_filter_meta_query( $q ) ); 46 } 47 48 /** 49 * @group xprofilemeta 50 * @group bp_xprofile_filter_meta_query 51 */ 52 public function test_bp_xprofile_filter_meta_query_delete() { 53 global $wpdb; 54 $q = "DELETE FROM {$wpdb->xprofile_groupmeta} WHERE xprofile_group_id IN(1,2,3)"; 55 $this->assertSame( "DELETE FROM {$wpdb->xprofile_groupmeta} WHERE object_type = 'group' AND object_id IN(1,2,3)", bp_xprofile_filter_meta_query( $q ) ); 56 } 57 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 22 01:00:56 2024 | Cross-referenced by PHPXref 0.7.1 |