Skip to:
Content

BuddyPress.org

Changeset 13314


Ignore:
Timestamp:
08/13/2022 08:58:51 AM (2 years ago)
Author:
imath
Message:

Fully enjoy Yoast’s PHPUnit polyfills

Using these polyfills let us use PHPUnit v9.x for our tests and add PHP 8.1 to our testing matrix. Some additional edits to our PHP unit tests suite were needed:

  • Stop using PHPunit deprecated functions.
  • Rename some BP_UnitTestCase methods to use Yoast's polyfills.
  • Edit the PHP Unit test GH action and also run this action on pull requests.
  • Update some composer dependencies, remove the one about phpunit/phpunit:^7.5 and add a new composer script to use PHPUnit v9.x.

Props renatonascalves, rafiahmedd

Closes https://github.com/buddypress/buddypress/pull/13
Fixes #8649

Location:
trunk
Files:
60 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/unit-tests.yml

    r13297 r13314  
    22
    33on:
     4  pull_request:
    45  push:
    56    branches: [ master ]
     
    1213      fail-fast: false
    1314      matrix:
    14         php: ['7.4', '8.0']
     15        php: ['7.4', '8.0', '8.1']
    1516        wp_version: ['master']
    1617        include:
     
    5960          composer-options: "--ignore-platform-reqs"
    6061
    61       - name: Adjust wp-phpunit version
    62         run: if [ ${{ env.WP_VERSION }} == '5.7' ]; then composer require --dev "wp-phpunit/wp-phpunit:5.7"; fi
    63 
    6462      - name: Cache node modules
    6563        uses: actions/cache@v2
  • trunk/.gitignore

    r12712 r13314  
    11.DS_Store
    22phpunit.xml
     3.phpunit*
    34.idea
    45.cache
     
    1819src/vendor
    1920vendor
     21composer.lock
    2022
    2123node_modules
  • trunk/composer.json

    r13285 r13314  
    2727        "wiki": "https://codex.buddypress.org/"
    2828    },
     29    "config": {
     30        "allow-plugins": {
     31            "composer/installers": true,
     32            "dealerdirect/phpcodesniffer-composer-installer": true
     33        }
     34    },
    2935    "require": {
    3036        "composer/installers": "^1.10.0",
     
    3238    },
    3339    "require-dev": {
    34         "phpcompatibility/phpcompatibility-wp": "^2.1.0",
     40        "phpcompatibility/phpcompatibility-wp": "^2.1.3",
    3541        "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
    36         "squizlabs/php_codesniffer" : "^3.5.4",
    37         "wp-coding-standards/wpcs": "*",
     42        "squizlabs/php_codesniffer" : "^3.6.0",
     43        "wp-coding-standards/wpcs": "~2.3.0",
    3844        "wp-phpunit/wp-phpunit": "^6.0",
    39         "phpunit/phpunit": "^7.5",
    4045        "yoast/phpunit-polyfills": "^1.0.1"
     46    },
     47    "scripts": {
     48        "test": "@php ./vendor/phpunit/phpunit/phpunit"
    4149    }
    4250}
  • trunk/tests/phpunit/bootstrap.php

    r12712 r13314  
    11<?php
     2const WP_TESTS_PHPUNIT_POLYFILLS_PATH = __DIR__ . '/../../vendor/yoast/phpunit-polyfills';
    23
    34if ( defined( 'BP_USE_WP_ENV_TESTS' ) ) {
  • trunk/tests/phpunit/includes/testcase-emails.php

    r10539 r13314  
    44class BP_UnitTestCase_Emails extends BP_UnitTestCase {
    55
    6     public static function setUpBeforeClass() {
    7         parent::setUpBeforeClass();
     6    public static function set_up_before_class() {
     7        parent::set_up_before_class();
    88
    99        require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
     
    1616    }
    1717
    18     public static function tearDownAfterClass() {
     18    public static function tear_down_after_class() {
    1919        $emails = get_posts( array(
    2020            'fields'           => 'ids',
     
    3131        }
    3232
    33         parent::tearDownAfterClass();
     33        parent::tear_down_after_class();
    3434    }
    3535}
  • trunk/tests/phpunit/includes/testcase.php

    r13140 r13314  
    3131     * @since 3.0.0
    3232     */
    33     public static function setUpBeforeClass() {
     33    public static function set_up_before_class() {
    3434        global $wpdb;
    3535
     
    4949    }
    5050
    51     public function setUp() {
    52         parent::setUp();
     51    public function set_up() {
     52        parent::set_up();
    5353
    5454        /*
     
    7575    }
    7676
    77     public function tearDown() {
     77    public function tear_down() {
    7878        global $wpdb;
    7979
    8080        remove_action( 'bp_blogs_recorded_existing_blogs', array( $this, 'set_autocommit_flag' ) );
    8181
    82         parent::tearDown();
     82        parent::tear_down();
    8383
    8484        // If we detect that a COMMIT has been triggered during the test, clean up blog and user fixtures.
     
    116116        $deleted = parent::delete_user( $user_id );
    117117
    118         // When called in tearDownAfterClass(), BP's cleanup functions may no longer be hooked.
     118        // When called in tear_down_after_class(), BP's cleanup functions may no longer be hooked.
    119119        if ( bp_is_active( 'activity' ) ) {
    120120            bp_activity_remove_all_user_data( $user_id );
     
    126126    }
    127127
    128     function clean_up_global_scope() {
     128    public function clean_up_global_scope() {
    129129        buddypress()->bp_nav                = buddypress()->bp_options_nav = buddypress()->action_variables = buddypress()->canonical_stack = buddypress()->unfiltered_uri = $GLOBALS['bp_unfiltered_uri'] = array();
    130130        buddypress()->current_component     = buddypress()->current_item = buddypress()->current_action = buddypress()->current_member_type = '';
     
    181181    }
    182182
    183     function assertPreConditions() {
    184         parent::assertPreConditions();
     183    public function assert_pre_conditions() {
     184        parent::assert_pre_conditions();
    185185
    186186        // Reinit some of the globals that might have been cleared by BP_UnitTestCase::clean_up_global_scope().
     
    189189    }
    190190
    191     function go_to( $url ) {
     191    public function go_to( $url ) {
    192192        $GLOBALS['bp']->loggedin_user = NULL;
    193193        $GLOBALS['bp']->pages = bp_core_get_directory_pages();
  • trunk/tests/phpunit/testcases/activity/functions/bpActivityGetActions.php

    r11809 r13314  
    99    protected $reset_actions_sorted;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313        $bp = buddypress();
    1414
     
    2020    }
    2121
    22     public function tearDown() {
    23         parent::tearDown();
     22    public function tear_down() {
     23        parent::tear_down();
    2424        $bp = buddypress();
    2525
  • trunk/tests/phpunit/testcases/activity/functions/bpActivityGetActionsForContext.php

    r11356 r13314  
    55 */
    66class BP_Tests_Activity_Functions_BpActivityGetActionsForContext extends BP_UnitTestCase {
    7     public function setUp() {
    8         parent::setUp();
     7    public function set_up() {
     8        parent::set_up();
    99
    1010        $bp = buddypress();
     
    1717    }
    1818
    19     public function tearDown() {
     19    public function tear_down() {
    2020        $bp = buddypress();
    2121
     
    2828        }
    2929
    30         parent::tearDown();
     30        parent::tear_down();
    3131    }
    3232
  • trunk/tests/phpunit/testcases/activity/notifications.php

    r12222 r13314  
    1212    protected $a2;
    1313
    14     public function setUp() {
    15         parent::setUp();
     14    public function set_up() {
     15        parent::set_up();
    1616        $this->current_user = get_current_user_id();
    1717        $this->u1 = self::factory()->user->create();
     
    2323         * When updating an activity, the following filter is fired to prevent sending more than one
    2424         * notification. Once we've reached this filter all at_mentions tests fails so we need to
    25          * temporarly remove it and restore it in $this->tearDown()
     25         * temporarly remove it and restore it in $this->tear_down()
    2626         */
    2727        remove_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
    2828    }
    2929
    30     public function tearDown() {
     30    public function tear_down() {
    3131        $this->set_current_user( $this->current_user );
    32         parent::tearDown();
     32        parent::tear_down();
    3333
    3434        // Restore the filter
     
    310310        $multiple = 'You have 2 new mentions';
    311311
    312         $this->assertContains( $single, $format_tests['string_single'] );
    313         $this->assertContains( $single, $format_tests['array_single']['text'] );
    314         $this->assertContains( $multiple, $format_tests['string_multiple'] );
    315         $this->assertContains( $multiple, $format_tests['array_multiple']['text'] );
     312        $this->assertStringContainsString( $single, $format_tests['string_single'] );
     313        $this->assertStringContainsString( $single, $format_tests['array_single']['text'] );
     314        $this->assertStringContainsString( $multiple, $format_tests['string_multiple'] );
     315        $this->assertStringContainsString( $multiple, $format_tests['array_multiple']['text'] );
    316316
    317317        // Check filters
  • trunk/tests/phpunit/testcases/admin/functions.php

    r11763 r13314  
    66    protected $old_current_user = 0;
    77
    8     public function setUp() {
    9         parent::setUp();
     8    public function set_up() {
     9        parent::set_up();
    1010        $this->old_current_user = get_current_user_id();
    1111        $this->set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     
    2020    }
    2121
    22     public function tearDown() {
    23         parent::tearDown();
     22    public function tear_down() {
     23        parent::tear_down();
    2424        $this->set_current_user( $this->old_current_user );
    2525    }
  • trunk/tests/phpunit/testcases/blogs/filters.php

    r11737 r13314  
    88    protected $custom_post_types;
    99
    10     public function setUp() {
    11         parent::setUp();
     10    public function set_up() {
     11        parent::set_up();
    1212
    1313        $this->custom_post_types = array( 'using_old_filter' );
     
    2323    }
    2424
    25     function tearDown() {
    26         parent::tearDown();
     25    function tear_down() {
     26        parent::tear_down();
    2727
    2828        $bp = buddypress();
  • trunk/tests/phpunit/testcases/core/avatars.php

    r12760 r13314  
    328328        ) );
    329329
    330         $this->assertContains( 'mystery-man-50.jpg', $found );
     330        $this->assertStringContainsString( 'mystery-man-50.jpg', $found );
    331331    }
    332332
     
    344344        ) );
    345345
    346         $this->assertContains( 'mystery-man-50.jpg', $found );
     346        $this->assertStringContainsString( 'mystery-man-50.jpg', $found );
    347347    }
    348348
     
    361361        remove_filter( 'bp_core_avatar_thumb_width', array( $this, 'filter_thumb_width' ) );
    362362
    363         $this->assertContains( 'mystery-man.jpg', $found );
     363        $this->assertStringContainsString( 'mystery-man.jpg', $found );
    364364    }
    365365
  • trunk/tests/phpunit/testcases/core/caps.php

    r12740 r13314  
    99    protected $blog_id;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313
    1414        $this->reset_user_id = get_current_user_id();
     
    1919    }
    2020
    21     public function tearDown() {
    22         parent::tearDown();
     21    public function tear_down() {
     22        parent::tear_down();
    2323
    2424        $this->set_current_user( $this->reset_user_id );
  • trunk/tests/phpunit/testcases/core/class-bp-attachment.php

    r13175 r13314  
    1111    private $image_file;
    1212
    13     public function setUp() {
    14         parent::setUp();
     13    public function set_up() {
     14        parent::set_up();
    1515        add_filter( 'bp_attachment_upload_overrides',        array( $this, 'filter_overrides' ),       10, 1 );
    1616        add_filter( 'upload_dir',                            array( $this, 'filter_upload_dir' ),      20, 1 );
     
    2121    }
    2222
    23     public function tearDown() {
    24         parent::tearDown();
     23    public function tear_down() {
     24        parent::tear_down();
    2525        remove_filter( 'bp_attachment_upload_overrides',     array( $this, 'filter_overrides' ),       10 );
    2626        remove_filter( 'upload_dir',                         array( $this, 'filter_upload_dir' ),      20 );
  • trunk/tests/phpunit/testcases/core/class-bp-button.php

    r11737 r13314  
    187187        ) );
    188188
    189         $this->assertInternalType( 'int', strpos( $b->contents, '<section ' ) );
    190         $this->assertInternalType( 'int', strpos( $b->contents, 'class="section-class ' ) );
    191         $this->assertInternalType( 'int', strpos( $b->contents, 'id="section-id"' ) );
    192         $this->assertInternalType( 'int', strpos( $b->contents, 'data-parent="foo"' ) );
    193         $this->assertInternalType( 'int', strpos( $b->contents, '<button ' ) );
    194         $this->assertInternalType( 'int', strpos( $b->contents, 'autofocus="autofocus"' ) );
    195         $this->assertInternalType( 'int', strpos( $b->contents, 'type="submit"' ) );
    196         $this->assertInternalType( 'int', strpos( $b->contents, 'name="my-button"' ) );
     189        $this->assertIsInt( strpos( $b->contents, '<section ' ) );
     190        $this->assertIsInt( strpos( $b->contents, 'class="section-class ' ) );
     191        $this->assertIsInt( strpos( $b->contents, 'id="section-id"' ) );
     192        $this->assertIsInt( strpos( $b->contents, 'data-parent="foo"' ) );
     193        $this->assertIsInt( strpos( $b->contents, '<button ' ) );
     194        $this->assertIsInt( strpos( $b->contents, 'autofocus="autofocus"' ) );
     195        $this->assertIsInt( strpos( $b->contents, 'type="submit"' ) );
     196        $this->assertIsInt( strpos( $b->contents, 'name="my-button"' ) );
    197197    }
    198198
     
    216216        ) );
    217217
    218         $this->assertInternalType( 'int', strpos( $b->contents, '<section ' ) );
    219         $this->assertInternalType( 'int', strpos( $b->contents, 'class="section-class ' ) );
    220         $this->assertInternalType( 'int', strpos( $b->contents, 'id="section-id"' ) );
    221         $this->assertInternalType( 'int', strpos( $b->contents, 'href="http://example.com"' ) );
    222         $this->assertInternalType( 'int', strpos( $b->contents, 'class="link-class"' ) );
    223         $this->assertInternalType( 'int', strpos( $b->contents, 'id="link-id"' ) );
    224         $this->assertInternalType( 'int', strpos( $b->contents, 'rel="nofollow"' ) );
    225         $this->assertInternalType( 'int', strpos( $b->contents, 'title="link-title"' ) );
     218        $this->assertIsInt( strpos( $b->contents, '<section ' ) );
     219        $this->assertIsInt( strpos( $b->contents, 'class="section-class ' ) );
     220        $this->assertIsInt( strpos( $b->contents, 'id="section-id"' ) );
     221        $this->assertIsInt( strpos( $b->contents, 'href="http://example.com"' ) );
     222        $this->assertIsInt( strpos( $b->contents, 'class="link-class"' ) );
     223        $this->assertIsInt( strpos( $b->contents, 'id="link-id"' ) );
     224        $this->assertIsInt( strpos( $b->contents, 'rel="nofollow"' ) );
     225        $this->assertIsInt( strpos( $b->contents, 'title="link-title"' ) );
    226226    }
    227227
     
    242242        ) );
    243243
    244         $this->assertInternalType( 'int', strpos( $b->contents, '<button class="new-class"' ) );
     244        $this->assertIsInt( strpos( $b->contents, '<button class="new-class"' ) );
    245245    }
    246246
  • trunk/tests/phpunit/testcases/core/class-bp-component.php

    r12998 r13314  
    99 */
    1010class BP_Tests_BP_Component_TestCases extends BP_UnitTestCase {
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313
    1414        $bp = buddypress();
  • trunk/tests/phpunit/testcases/core/class-bp-email-recipient.php

    r11737 r13314  
    77    protected $u1;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->u1 = self::factory()->user->create( array(
  • trunk/tests/phpunit/testcases/core/class-bp-email.php

    r11789 r13314  
    88    protected $u2;
    99
    10     public function setUp() {
    11         parent::setUp();
     10    public function set_up() {
     11        parent::set_up();
    1212
    1313        $this->u1 = self::factory()->user->create( array(
  • trunk/tests/phpunit/testcases/core/class-bp-media-extractor.php

    r12840 r13314  
    5959        foreach ( array( 'has', 'embeds', 'images', 'links', 'mentions', 'shortcodes', 'audio' ) as $key ) {
    6060            $this->assertArrayHasKey( $key, $media );
    61             $this->assertInternalType( 'array', $media[ $key ] );
     61            $this->assertIsArray( $media[ $key ] );
    6262        }
    6363
    6464        foreach ( $media['has'] as $item ) {
    65             $this->assertInternalType( 'int', $item );
     65            $this->assertIsInt( $item );
    6666        }
    6767
    6868        foreach ( $media['links'] as $item ) {
    6969            $this->assertArrayHasKey( 'url', $item );
    70             $this->assertInternalType( 'string', $item['url'] );
     70            $this->assertIsString( $item['url'] );
    7171            $this->assertNotEmpty( $item['url'] );
    7272        }
     
    7474        foreach ( $media['mentions'] as $item ) {
    7575            $this->assertArrayHasKey( 'name', $item );
    76             $this->assertInternalType( 'string', $item['name'] );
     76            $this->assertIsString( $item['name'] );
    7777            $this->assertNotEmpty( $item['name'] );
    7878        }
     
    8080        foreach ( $media['images'] as $item ) {
    8181            $this->assertArrayHasKey( 'height', $item );
    82             $this->assertInternalType( 'int', $item['height'] );
     82            $this->assertIsInt( $item['height'] );
    8383
    8484            $this->assertArrayHasKey( 'width', $item );
    85             $this->assertInternalType( 'int', $item['width'] );
     85            $this->assertIsInt( $item['width'] );
    8686
    8787            $this->assertArrayHasKey( 'source', $item );
    88             $this->assertInternalType( 'string', $item['source'] );
     88            $this->assertIsString( $item['source'] );
    8989            $this->assertNotEmpty( $item['source'] );
    9090
    9191            $this->assertArrayHasKey( 'url', $item );
    92             $this->assertInternalType( 'string', $item['url'] );
     92            $this->assertIsString( $item['url'] );
    9393            $this->assertNotEmpty( $item['url'] );
    9494        }
     
    9696        foreach ( $media['shortcodes'] as $shortcode_type => $item ) {
    9797            $this->assertArrayHasKey( 'attributes', $item );
    98             $this->assertInternalType( 'array', $item['attributes'] );
     98            $this->assertIsArray( $item['attributes'] );
    9999
    100100            $this->assertArrayHasKey( 'content', $item );
    101             $this->assertInternalType( 'string', $item['content'] );
     101            $this->assertIsString( $item['content'] );
    102102
    103103            $this->assertArrayHasKey( 'type', $item );
    104             $this->assertInternalType( 'string', $item['type'] );
     104            $this->assertIsString( $item['type'] );
    105105
    106106            $this->assertArrayHasKey( 'original', $item );
    107             $this->assertInternalType( 'string', $item['original'] );
     107            $this->assertIsString( $item['original'] );
    108108        }
    109109
    110110        foreach ( $media['embeds'] as $item ) {
    111111            $this->assertArrayHasKey( 'url', $item );
    112             $this->assertInternalType( 'string', $item['url'] );
     112            $this->assertIsString( $item['url'] );
    113113            $this->assertNotEmpty( $item['url'] );
    114114        }
     
    116116        foreach ( $media['audio'] as $item ) {
    117117            $this->assertArrayHasKey( 'url', $item );
    118             $this->assertInternalType( 'string', $item['url'] );
     118            $this->assertIsString( $item['url'] );
    119119            $this->assertNotEmpty( $item['url'] );
    120120
    121121            $this->assertArrayHasKey( 'source', $item );
    122             $this->assertInternalType( 'string', $item['source'] );
     122            $this->assertIsString( $item['source'] );
    123123            $this->assertNotEmpty( $item['source'] );
    124124        }
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r13184 r13314  
    7575        ) );
    7676
    77         $this->assertContains( '0 = 1', $q->uid_clauses['where'] );
     77        $this->assertStringContainsString( '0 = 1', $q->uid_clauses['where'] );
    7878    }
    7979
     
    8686        ) );
    8787
    88         $this->assertNotContains( '0 = 1', $q->uid_clauses['where'] );
     88        $this->assertStringNotContainsString( '0 = 1', $q->uid_clauses['where'] );
    8989    }
    9090
  • trunk/tests/phpunit/testcases/core/class-bp-walker-nav-menu.php

    r12498 r13314  
    88    protected $user_id;
    99
    10     public function setUp() {
    11         parent::setUp();
     10    public function set_up() {
     11        parent::set_up();
    1212
    1313        $this->reset_user_id = get_current_user_id();
     
    1717    }
    1818
    19     public function tearDown() {
    20         parent::tearDown();
     19    public function tear_down() {
     20        parent::tear_down();
    2121        $this->set_current_user( $this->reset_user_id );
    2222    }
  • trunk/tests/phpunit/testcases/core/functions.php

    r13304 r13314  
    810810        $link_color = 'style="color: ' . esc_attr( $appearance['highlight_color'] ) . ';';
    811811        $result     = bp_email_add_link_color_to_template( $content, 'template', 'add-content' );
    812         $this->assertContains( $link_color, $result );
     812        $this->assertStringContainsString( $link_color, $result );
    813813
    814814        $content     = '<a href="http://example.com" style="display: block">example</a>';
    815815        $link_color .= 'display: block';
    816816        $result      = bp_email_add_link_color_to_template( $content, 'template', 'add-content' );
    817         $this->assertContains( $link_color, $result );
     817        $this->assertStringContainsString( $link_color, $result );
    818818    }
    819819
  • trunk/tests/phpunit/testcases/core/functions/bpGetRefererPath.php

    r9819 r13314  
    1010    private $http_referer = '';
    1111
    12     public function setUp() {
    13         parent::setUp();
     12    public function set_up() {
     13        parent::set_up();
    1414
    1515        $this->_wp_http_referer = '';
     
    2525    }
    2626
    27     public function tearDown() {
     27    public function tear_down() {
    2828        if ( isset( $_REQUEST['_wp_http_referer'] ) ) {
    2929            unset( $_REQUEST['_wp_http_referer'] );
     
    4242        }
    4343
    44         parent::tearDown();
     44        parent::tear_down();
    4545    }
    4646
  • trunk/tests/phpunit/testcases/core/functions/bpVerifyNonceRequest.php

    r11758 r13314  
    1111    private $request_uri = '';
    1212
    13     public function setUp() {
    14         parent::setUp();
     13    public function set_up() {
     14        parent::set_up();
    1515
    1616        if ( isset( $_SERVER['HTTP_HOST'] ) ) {
     
    2727    }
    2828
    29     public function tearDown() {
     29    public function tear_down() {
    3030        if ( '' !== $this->http_host ) {
    3131            $_SERVER['HTTP_HOST'] = $this->http_host;
     
    4040        }
    4141
    42         parent::tearDown();
     42        parent::tear_down();
    4343    }
    4444
  • trunk/tests/phpunit/testcases/core/nav/backCompat.php

    r11737 r13314  
    1111    protected $bp_options_nav;
    1212
    13     public function setUp() {
    14         parent::setUp();
     13    public function set_up() {
     14        parent::set_up();
    1515        $this->bp_nav = buddypress()->bp_nav;
    1616        $this->bp_options_nav = buddypress()->bp_options_nav;
    1717    }
    1818
    19     public function tearDown() {
     19    public function tear_down() {
    2020        buddypress()->bp_nav = $this->bp_nav;
    2121        buddypress()->bp_options_nav = $this->bp_options_nav;
    22         parent::tearDown();
     22        parent::tear_down();
    2323    }
    2424
  • trunk/tests/phpunit/testcases/core/suggestions-nonauth.php

    r11739 r13314  
    7676    }
    7777
    78     public static function tearDownAfterClass() {
     78    public static function tear_down_after_class() {
    7979        foreach ( self::$group_ids as $group_id ) {
    8080            groups_delete_group( $group_id );
  • trunk/tests/phpunit/testcases/core/suggestions.php

    r11739 r13314  
    9494    }
    9595
    96     public static function tearDownAfterClass() {
     96    public static function tear_down_after_class() {
    9797        foreach ( self::$group_ids as $group_id ) {
    9898            groups_delete_group( $group_id );
     
    110110    }
    111111
    112     public function setUp() {
    113         parent::setUp();
     112    public function set_up() {
     113        parent::set_up();
    114114        $this->set_current_user( self::$current_user );
    115115    }
    116116
    117     public function tearDown() {
    118         parent::tearDown();
     117    public function tear_down() {
     118        parent::tear_down();
    119119        $this->set_current_user( self::$old_user_id );
    120120    }
     
    392392
    393393        $this->assertFalse( is_wp_error( $suggestions ) );
    394         $this->assertInternalType( 'array', $suggestions );
     394        $this->assertIsArray( $suggestions );
    395395        $this->assertEmpty( $suggestions );
    396396    }
     
    403403
    404404        $this->assertFalse( is_wp_error( $suggestion ) );
    405         $this->assertInternalType( 'array', $suggestion );
     405        $this->assertIsArray( $suggestion );
    406406        $this->assertNotEmpty( $suggestion );
    407407
    408408        $suggestion = array_shift( $suggestion );
    409409
    410         $this->assertInternalType( 'object', $suggestion );
    411         $this->assertAttributeNotEmpty( 'image', $suggestion );
    412         $this->assertAttributeNotEmpty( 'ID', $suggestion );
    413         $this->assertAttributeNotEmpty( 'name', $suggestion );
     410        $this->assertIsObject( $suggestion );
     411        $this->assertNotEmpty( $suggestion->image );
     412        $this->assertNotEmpty( $suggestion->ID );
     413        $this->assertNotEmpty( $suggestion->name );
    414414    }
    415415
     
    421421
    422422        $this->assertFalse( is_wp_error( $suggestions ) );
    423         $this->assertInternalType( 'array', $suggestions );
     423        $this->assertIsArray( $suggestions );
    424424        $this->assertNotEmpty( $suggestions );
    425425
    426426        foreach ( $suggestions as $suggestion ) {
    427             $this->assertInternalType( 'object', $suggestion );
    428             $this->assertAttributeNotEmpty( 'image', $suggestion );
    429             $this->assertAttributeNotEmpty( 'ID', $suggestion );
    430             $this->assertAttributeNotEmpty( 'name', $suggestion );
     427            $this->assertIsObject( $suggestion );
     428            $this->assertNotEmpty( $suggestion->image );
     429            $this->assertNotEmpty( $suggestion->ID );
     430            $this->assertNotEmpty( $suggestion->name );
    431431        }
    432432    }
     
    458458
    459459        $this->assertFalse( is_wp_error( $suggestion ) );
    460         $this->assertInternalType( 'array', $suggestion );
     460        $this->assertIsArray( $suggestion );
    461461        $this->assertNotEmpty( $suggestion );
    462462
    463463        $suggestion = array_shift( $suggestion );
    464464
    465         $this->assertInternalType( 'object', $suggestion );
    466         $this->assertAttributeInternalType( 'string', 'image', $suggestion );
    467         $this->assertAttributeInternalType( 'string', 'ID', $suggestion );
    468         $this->assertAttributeInternalType( 'string', 'name', $suggestion );
     465        $this->assertIsObject( $suggestion );
     466        $this->assertIsString( $suggestion->image );
     467        $this->assertIsString( $suggestion->ID );
     468        $this->assertIsString( $suggestion->name );
    469469    }
    470470
  • trunk/tests/phpunit/testcases/core/templateLoader.php

    r12726 r13314  
    77class BP_Tests_Template_Loader_Functions extends BP_UnitTestCase {
    88
    9     public function setUp() {
     9    public function set_up() {
    1010        if ( version_compare( bp_get_major_wp_version(), '5.5', '<' ) ) {
    1111            $this->markTestSkipped(
     
    1616        add_filter( 'bp_get_template_stack', array( $this, 'template_stack'), 10, 1 );
    1717
    18         parent::setUp();
     18        parent::set_up();
    1919    }
    2020
    21     public function tearDown() {
     21    public function tear_down() {
    2222        remove_filter( 'bp_get_template_stack', array( $this, 'template_stack'), 10, 1 );
    2323
    24         parent::tearDown();
     24        parent::tear_down();
    2525    }
    2626
  • trunk/tests/phpunit/testcases/friends/functions.php

    r12605 r13314  
    1010    protected $filter_fired;
    1111
    12     public function setUp() {
    13         parent::setUp();
     12    public function set_up() {
     13        parent::set_up();
    1414        $this->filter_fired = '';
    1515    }
  • trunk/tests/phpunit/testcases/friends/notifications.php

    r11737 r13314  
    99    protected $friend;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313        $this->current_user = get_current_user_id();
    1414        $this->set_current_user( self::factory()->user->create() );
     
    1818    }
    1919
    20     public function tearDown() {
    21         parent::tearDown();
     20    public function tear_down() {
     21        parent::tear_down();
    2222        $this->set_current_user( $this->current_user );
    2323    }
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php

    r12741 r13314  
    14981498     */
    14991499    public function test_total_group_count_should_return_integer() {
    1500         $this->assertInternalType( 'int', BP_Groups_Member::total_group_count( 123 ) );
     1500        $this->assertIsInt( BP_Groups_Member::total_group_count( 123 ) );
    15011501    }
    15021502
  • trunk/tests/phpunit/testcases/groups/functions/bpGetUserGroups.php

    r12433 r13314  
    99    static $groups;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313        groups_remove_member( self::$user, self::$groups[2] );
    1414    }
     
    4141    }
    4242
    43     public static function tearDownAfterClass() {
     43    public static function tear_down_after_class() {
    4444        foreach ( self::$groups as $group ) {
    4545            groups_delete_group( $group );
     
    6363
    6464        foreach ( $found as $index => $f ) {
    65             $this->assertInternalType( 'int', $index );
    66             $this->assertInternalType( 'object', $f );
    67             $this->assertInternalType( 'int', $f->group_id );
     65            $this->assertIsInt( $index );
     66            $this->assertIsObject( $f );
     67            $this->assertIsInt( $f->group_id );
    6868            $this->assertSame( $index, $f->group_id );
    6969        }
  • trunk/tests/phpunit/testcases/groups/functions/get-group.php

    r13103 r13314  
    77class BP_Tests_Get_Groups_Param extends BP_UnitTestCase {
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        if ( isset( $GLOBALS['groups_template'] ) ) {
     
    1515    }
    1616
    17     public function tearDown() {
     17    public function tear_down() {
    1818        if ( $this->groups_template ) {
    1919            $GLOBALS['groups_template'] = $this->groups_template;
    2020        }
    2121
    22         parent::tearDown();
     22        parent::tear_down();
    2323    }
    2424
  • trunk/tests/phpunit/testcases/groups/functions/groupsIsUser.php

    r12433 r13314  
    3030    }
    3131
    32     public static function tearDownAfterClass() {
     32    public static function tear_down_after_class() {
    3333        foreach ( self::$groups as $group ) {
    3434            groups_delete_group( $group );
  • trunk/tests/phpunit/testcases/groups/functions/groupsTotalGroupsForUser.php

    r10445 r13314  
    1010     */
    1111    public function test_should_return_integer() {
    12         $this->assertInternalType( 'int', groups_total_groups_for_user( 123 ) );
     12        $this->assertIsInt( groups_total_groups_for_user( 123 ) );
    1313    }
    1414
     
    2323        wp_cache_set( 'bp_total_groups_for_user_123', '321', 'bp' );
    2424
    25         $this->assertInternalType( 'int', groups_total_groups_for_user( 123 ) );
     25        $this->assertIsInt( groups_total_groups_for_user( 123 ) );
    2626    }
    2727}
  • trunk/tests/phpunit/testcases/groups/notifications.php

    r12437 r13314  
    1111    protected $group;
    1212
    13     public function setUp() {
    14         parent::setUp();
     13    public function set_up() {
     14        parent::set_up();
    1515        $this->current_user = get_current_user_id();
    1616        $this->set_current_user( self::factory()->user->create() );
     
    2121    }
    2222
    23     public function tearDown() {
    24         parent::tearDown();
     23    public function tear_down() {
     24        parent::tear_down();
    2525        $this->set_current_user( $this->current_user );
    2626    }
  • trunk/tests/phpunit/testcases/groups/template.php

    r13097 r13314  
    66class BP_Tests_Groups_Template extends BP_UnitTestCase {
    77
    8     public function setUp() {
    9         parent::setUp();
     8    public function set_up() {
     9        parent::set_up();
    1010
    1111        if ( isset( $GLOBALS['groups_template'] ) ) {
     
    1414    }
    1515
    16     public function tearDown() {
     16    public function tear_down() {
    1717        if ( $this->groups_template ) {
    1818            $GLOBALS['groups_template'] = $this->groups_template;
    1919        }
    2020
    21         parent::tearDown();
     21        parent::tear_down();
    2222    }
    2323
  • trunk/tests/phpunit/testcases/groups/template/bpGroupStatusMessage.php

    r13085 r13314  
    99    private $groups_template = null;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313        $this->current_user = bp_loggedin_user_id();
    1414        $this->set_current_user( 0 );
     
    1919    }
    2020
    21     public function tearDown() {
     21    public function tear_down() {
    2222        $this->set_current_user( $this->current_user );
    2323        if ( $this->groups_template ) {
     
    2525        }
    2626
    27         parent::tearDown();
     27        parent::tear_down();
    2828    }
    2929
  • trunk/tests/phpunit/testcases/groups/template/group-is-visible.php

    r13097 r13314  
    77class BP_Tests_Groups_Template_Is_Visible extends BP_UnitTestCase {
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        if ( isset( $GLOBALS['groups_template'] ) ) {
     
    1515    }
    1616
    17     public function tearDown() {
     17    public function tear_down() {
    1818        if ( $this->groups_template ) {
    1919            $GLOBALS['groups_template'] = $this->groups_template;
    2020        }
    2121
    22         parent::tearDown();
     22        parent::tear_down();
    2323    }
    2424
  • trunk/tests/phpunit/testcases/groups/types.php

    r13309 r13314  
    88    protected static $u1 = null;
    99
    10     public function setUp() {
    11         parent::setUp();
     10    public function set_up() {
     11        parent::set_up();
    1212
    1313        buddypress()->groups->types = array();
     
    9393    public function test_groups_get_type_object_should_return_type_object() {
    9494        bp_groups_register_group_type( 'foo' );
    95         $this->assertInternalType( 'object', bp_groups_register_group_type( 'foo' ) );
     95        $this->assertIsObject( bp_groups_register_group_type( 'foo' ) );
    9696    }
    9797
  • trunk/tests/phpunit/testcases/members/class-bp-signup.php

    r13120 r13314  
    99    protected $signup_allowed;
    1010
    11     public function setUp() {
     11    public function set_up() {
    1212
    1313        if ( is_multisite() ) {
     
    1919        }
    2020
    21         parent::setUp();
    22     }
    23 
    24     public function tearDown() {
     21        parent::set_up();
     22    }
     23
     24    public function tear_down() {
    2525        if ( is_multisite() ) {
    2626            update_site_option( 'registration', $this->signup_allowed );
     
    2929        }
    3030
    31         parent::tearDown();
     31        parent::tear_down();
    3232    }
    3333
  • trunk/tests/phpunit/testcases/members/template/bpGetMemberClass.php

    r11737 r13314  
    2727        buddypress()->members->types = array();
    2828
    29         $this->assertContains( 'member-type-bar', $found );
    30         $this->assertNotContains( 'member-type-foo', $found );
     29        $this->assertStringContainsString( 'member-type-bar', $found );
     30        $this->assertStringNotContainsString( 'member-type-foo', $found );
    3131    }
    3232}
  • trunk/tests/phpunit/testcases/members/template/bpGetMemberTypeDirectoryPermalink.php

    r10459 r13314  
    66 */
    77class BP_Tests_Members_Template_BpGetMemberTypeDirectoryPermalink extends BP_UnitTestCase {
    8     public function setUp() {
    9         parent::setUp();
     8    public function set_up() {
     9        parent::set_up();
    1010
    1111        buddypress()->members->types = array();
     
    2424        remove_filter( 'bp_get_current_member_type', array( $this, 'fake_current_member_type' ) );
    2525
    26         $this->assertContains( '/type/foo/', $found );
     26        $this->assertStringContainsString( '/type/foo/', $found );
    2727    }
    2828
     
    4242        remove_filter( 'bp_get_current_member_type', array( $this, 'fake_current_member_type' ) );
    4343
    44         $this->assertContains( '/type/bar/', $found );
     44        $this->assertStringContainsString( '/type/bar/', $found );
    4545    }
    4646
  • trunk/tests/phpunit/testcases/members/types.php

    r13309 r13314  
    66 */
    77class BP_Tests_Members_Types extends BP_UnitTestCase {
    8     public function setUp() {
    9         parent::setUp();
     8    public function set_up() {
     9        parent::set_up();
    1010
    1111        buddypress()->members->types = array();
     
    1818
    1919    public function test_bp_register_member_type_should_return_type_object() {
    20         $this->assertInternalType( 'object', bp_register_member_type( 'foo' ) );
     20        $this->assertIsObject( bp_register_member_type( 'foo' ) );
    2121    }
    2222
     
    144144    public function test_bp_get_member_type_object_should_return_type_object() {
    145145        bp_register_member_type( 'foo' );
    146         $this->assertInternalType( 'object', bp_get_member_type_object( 'foo' ) );
     146        $this->assertIsObject( bp_get_member_type_object( 'foo' ) );
    147147    }
    148148
  • trunk/tests/phpunit/testcases/messages/class.bp-messages-notice.php

    r11737 r13314  
    88    protected $old_current_user = 0;
    99
    10     public function setUp() {
    11         parent::setUp();
     10    public function set_up() {
     11        parent::set_up();
    1212        $this->old_current_user = get_current_user_id();
    1313        $this->set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/messages/notifications.php

    r13112 r13314  
    99    protected $filter_fired;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313
    1414        $this->reset_user_id = get_current_user_id();
     
    1717    }
    1818
    19     public function tearDown() {
    20         parent::tearDown();
     19    public function tear_down() {
     20        parent::tear_down();
    2121
    2222        $this->set_current_user( $this->reset_user_id );
  • trunk/tests/phpunit/testcases/routing/activity.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->old_current_user = get_current_user_id();
     
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/routing/core.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->old_current_user = get_current_user_id();
     
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/routing/friends.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->old_current_user = get_current_user_id();
     
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/routing/groups.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        buddypress()->members->types = array();
     
    1515    }
    1616
    17     public function tearDown() {
    18         parent::tearDown();
     17    public function tear_down() {
     18        parent::tear_down();
    1919        $this->set_current_user( $this->old_current_user );
    2020    }
  • trunk/tests/phpunit/testcases/routing/members.php

    r12328 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        buddypress()->members->types = array();
     
    1515    }
    1616
    17     public function tearDown() {
     17    public function tear_down() {
    1818        $this->set_current_user( $this->old_current_user );
    19         parent::tearDown();
     19        parent::tear_down();
    2020    }
    2121
  • trunk/tests/phpunit/testcases/routing/messages.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->old_current_user = get_current_user_id();
     
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/routing/root-profiles.php

    r11737 r13314  
    99    protected $u;
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313
    1414        add_filter( 'bp_core_enable_root_profiles', '__return_true' );
     
    2323    }
    2424
    25     public function tearDown() {
    26         parent::tearDown();
     25    public function tear_down() {
     26        parent::tear_down();
    2727        $this->set_current_user( $this->old_current_user );
    2828        remove_filter( 'bp_core_enable_root_profiles', '__return_true' );
  • trunk/tests/phpunit/testcases/routing/settings.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->old_current_user = get_current_user_id();
     
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/routing/xprofile.php

    r11737 r13314  
    77    protected $old_current_user = 0;
    88
    9     public function setUp() {
    10         parent::setUp();
     9    public function set_up() {
     10        parent::set_up();
    1111
    1212        $this->old_current_user = get_current_user_id();
     
    1414    }
    1515
    16     public function tearDown() {
    17         parent::tearDown();
     16    public function tear_down() {
     17        parent::tear_down();
    1818        $this->set_current_user( $this->old_current_user );
    1919    }
  • trunk/tests/phpunit/testcases/xprofile/BP_XProfile_Field/member_types.php

    r11737 r13314  
    1111    protected $field;
    1212
    13     public function setUp() {
    14         parent::setUp();
     13    public function set_up() {
     14        parent::set_up();
    1515        bp_register_member_type( 'foo' );
    1616        bp_register_member_type( 'bar' );
     
    2121    }
    2222
    23     public function tearDown() {
     23    public function tear_down() {
    2424        buddypress()->members->types = array();
    25         parent::tearDown();
     25        parent::tear_down();
    2626    }
    2727
  • trunk/tests/phpunit/testcases/xprofile/activity.php

    r12851 r13314  
    1616    }
    1717
    18     public static function tearDownAfterClass() {
     18    public static function tear_down_after_class() {
    1919        $d = self::$updated_profile_data;
    2020
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field-type.php

    r12868 r13314  
    99class BP_Tests_XProfile_Field_Type extends BP_UnitTestCase {
    1010
    11     public function setUp() {
    12         parent::setUp();
     11    public function set_up() {
     12        parent::set_up();
    1313
    1414        add_filter( 'bp_xprofile_get_field_types', array( $this, 'get_field_types' ) );
    1515    }
    1616
    17     public function tearDown() {
    18         parent::tearDown();
     17    public function tear_down() {
     18        parent::tear_down();
    1919
    2020        remove_filter( 'bp_xprofile_get_field_types', array( $this, 'get_field_types' ) );
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-query.php

    r11737 r13314  
    1010    protected $users = array();
    1111
    12     public function tearDown() {
    13         parent::tearDown();
     12    public function tear_down() {
     13        parent::tear_down();
    1414        $this->group = '';
    1515        $this->fields = array();
  • trunk/tests/phpunit/testcases/xprofile/functions.php

    r13121 r13314  
    10561056        $regex = '#^Hello world this is a test; with, <a href="([^"]+)" rel="nofollow">some</a>, <a href="([^"]+)" rel="nofollow">words</a>$#i';
    10571057
    1058         $this->assertRegExp( $regex, $output );
     1058        $this->assertMatchesRegularExpression( $regex, $output );
    10591059        unset( $GLOBALS['field'] );
    10601060    }
     
    10721072        $regex = '#^Hello world this is a test with; <a href="([^"]+)" rel="nofollow">some</a>; <a href="([^"]+)" rel="nofollow">words</a>$#i';
    10731073
    1074         $this->assertRegExp( $regex, $output );
     1074        $this->assertMatchesRegularExpression( $regex, $output );
    10751075        unset( $GLOBALS['field'] );
    10761076    }
Note: See TracChangeset for help on using the changeset viewer.