Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/22/2021 03:16:06 AM (5 years ago)
Author:
espellcaste
Message:

Marking deprecated query classes, their methods, arguments as deprecated in the BP_Friends_Friendship and BP_Friends_Friendship classes.

Props imath

Fixes #8554 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php

    r12430 r13086  
    1616        }
    1717
     18        /**
     19         * @group __construct
     20         * @expectedDeprecated BP_Groups_Group::__construct
     21         */
     22        public function test_deprecated_arg() {
     23                $group = new BP_Groups_Group( 123456789, array( 'populate_extras' => true ) );
     24                $this->assertSame( 0, $group->id );
     25        }
     26
    1827        /** get() ************************************************************/
     28
     29        /**
     30         * @group get
     31         */
     32        public function test_get_group_id_with_slug() {
     33                $slug     = 'group-test';
     34                $g1       = self::factory()->group->create( array( 'slug' => $slug ) );
     35                $group_id = BP_Groups_Group::group_exists( $slug );
     36
     37                $this->assertSame( $g1, $group_id );
     38        }
     39
     40        /**
     41         * @group get
     42         */
     43        public function test_get_group_id_with_empty_slug() {
     44                $this->assertFalse( BP_Groups_Group::group_exists( '' ) );
     45        }
     46
     47        /**
     48         * @group get
     49         */
     50        public function test_get_group_id_from_slug_with_empty_slug() {
     51                $this->assertFalse( BP_Groups_Group::get_id_from_slug( '' ) );
     52        }
     53
     54        /**
     55         * @group get
     56         */
     57        public function test_get_group_id_from_slug() {
     58                $slug     = 'group-test';
     59                $g1       = self::factory()->group->create( array( 'slug' => $slug ) );
     60                $group_id = BP_Groups_Group::get_id_from_slug( $slug );
     61
     62                $this->assertSame( $g1, $group_id );
     63        }
     64
     65        /**
     66         * @group get
     67         * @expectedDeprecated BP_Groups_Group::group_exists
     68         */
     69        public function test_get_group_with_slug_with_deprecated_args() {
     70                $slug     = 'group-test';
     71                $g1       = self::factory()->group->create( array( 'slug' => $slug ) );
     72                $group_id = BP_Groups_Group::group_exists( $slug, 'random-name' );
     73
     74                $this->assertSame( $g1, $group_id );
     75        }
    1976
    2077        /**
     
    11441201
    11451202                $groups = BP_Groups_Group::search_groups( "'tis " );
    1146 
    1147                 $found = wp_list_pluck( $groups['groups'], 'group_id' );
     1203                $found  = wp_list_pluck( $groups['groups'], 'group_id' );
    11481204
    11491205                $this->assertEquals( array( $g1 ), $found );
     1206                $this->assertNotContains( $g2, $found );
     1207        }
     1208
     1209        /**
     1210         * @expectedDeprecated BP_Groups_Group::get_by_letter
     1211         */
     1212        public function test_get_by_letter_with_deprecated_arg() {
     1213                $g1 = self::factory()->group->create( array(
     1214                        'name'        => 'Awesome Cool Group',
     1215                        'description' => 'Neat',
     1216                ) );
     1217                $g2 = self::factory()->group->create();
     1218
     1219                $groups = BP_Groups_Group::get_by_letter( 'A', null, null, false );
     1220                $found  = wp_list_pluck( $groups['groups'], 'id' );
     1221
     1222                $this->assertEquals( array( $g1 ), $found );
     1223                $this->assertNotContains( $g2, $found );
    11501224        }
    11511225
    11521226        public function test_get_by_letter_typical_use() {
     1227                $g1 = self::factory()->group->create( array(
     1228                        'name'        => 'Awesome Cool Group',
     1229                        'description' => 'Neat',
     1230                ) );
     1231                $g2 = self::factory()->group->create();
     1232
     1233                $groups = BP_Groups_Group::get_by_letter( 'A' );
     1234                $found  = wp_list_pluck( $groups['groups'], 'id' );
     1235
     1236                $this->assertEquals( array( $g1 ), $found );
     1237                $this->assertNotContains( $g2, $found );
     1238        }
     1239
     1240        public function test_get_by_letter_with_exclude() {
    11531241                $g1 = self::factory()->group->create( array(
    11541242                        'name' => 'Awesome Cool Group',
     
    11561244                ) );
    11571245                $g2 = self::factory()->group->create( array(
    1158                         'name' => 'Babylon Kong',
    1159                         'description' => 'Awesome',
    1160                 ) );
    1161 
    1162                 $groups = BP_Groups_Group::get_by_letter( 'A' );
    1163 
    1164                 $found = wp_list_pluck( $groups['groups'], 'id' );
    1165 
    1166                 $this->assertEquals( array( $g1 ), $found );
    1167 
    1168         }
    1169 
    1170         public function test_get_by_letter_with_exclude() {
    1171                 $g1 = self::factory()->group->create( array(
    1172                         'name' => 'Awesome Cool Group',
    1173                         'description' => 'Neat',
    1174                 ) );
    1175                 $g2 = self::factory()->group->create( array(
    11761246                        'name' => 'Another Cool Group',
    11771247                        'description' => 'Awesome',
     
    11791249
    11801250                $groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1, 'stringthatshouldberemoved' ) );
    1181 
    1182                 $found = wp_list_pluck( $groups['groups'], 'id' );
     1251                $found  = wp_list_pluck( $groups['groups'], 'id' );
    11831252
    11841253                $this->assertEquals( array( $g2 ), $found );
     
    12101279        }
    12111280
     1281        /**
     1282         * @expectedDeprecated BP_Groups_Group::get_random
     1283         */
     1284        public function test_get_random_with_deprecated_arg() {
     1285                $g1 = self::factory()->group->create();
     1286                $g2 = self::factory()->group->create();
     1287
     1288                // There are only two groups, so excluding one should give us the other
     1289                $groups = BP_Groups_Group::get_random( null, null, 0, false, false, array( $g1, 'ignore this' ) );
     1290                $found  = wp_list_pluck( $groups['groups'], 'id' );
     1291
     1292                $this->assertEquals( array( $g2 ), $found );
     1293        }
     1294
    12121295        public function test_get_random_with_exclude() {
    12131296                $g1 = self::factory()->group->create();
     
    12321315                // Only one group will match, so the random part doesn't matter
    12331316                $groups = BP_Groups_Group::get_random( null, null, 0, 'daci' );
    1234 
    1235                 $found = wp_list_pluck( $groups['groups'], 'id' );
     1317                $found  = wp_list_pluck( $groups['groups'], 'id' );
    12361318
    12371319                $this->assertEquals( array( $g1 ), $found );
     1320                $this->assertNotContains( $g2, $found );
    12381321        }
    12391322
Note: See TracChangeset for help on using the changeset viewer.