Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/13/2022 08:58:51 AM (21 months 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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        }
Note: See TracChangeset for help on using the changeset viewer.