Making WordPress.org


Ignore:
Timestamp:
03/04/2021 11:27:47 PM (5 years ago)
Author:
coffee2code
Message:

Handbooks, Unit tests: Minor refactors to prevent PHP errors when things aren't working as expected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/init.php

    r10760 r10761  
    4444    public function test_get_handbook_objects_default() {
    4545        $handbooks = WPorg_Handbook_Init::get_handbook_objects();
     46        $first_handbook = reset( $handbooks );
    4647
    4748        $this->assertIsArray( $handbooks );
    4849        $this->assertCount( 1, $handbooks );
    49         $this->assertInstanceOf( 'WPorg_Handbook', $handbooks[0] );
    50         $this->assertEquals( 'handbook', $handbooks[0]->post_type );
     50        $this->assertInstanceOf( 'WPorg_Handbook', $first_handbook );
     51        $this->assertEquals( 'handbook', $first_handbook->post_type );
    5152    }
    5253
     
    5859        $this->assertIsArray( $handbooks );
    5960        $this->assertCount( 2, $handbooks );
    60         $this->assertInstanceOf( 'WPorg_Handbook', $handbooks[0] );
    61         $this->assertEquals( 'plugins-handbook', $handbooks[0]->post_type );
    62         $this->assertInstanceOf( 'WPorg_Handbook', $handbooks[1] );
    63         $this->assertEquals( 'themes-handbook', $handbooks[1]->post_type );
     61
     62        $first_handbook = reset( $handbooks );
     63        $this->assertInstanceOf( 'WPorg_Handbook', $first_handbook );
     64        $this->assertEquals( 'plugins-handbook', $first_handbook->post_type );
     65
     66        $second_handbook = next( $handbooks );
     67        $this->assertInstanceOf( 'WPorg_Handbook', $second_handbook );
     68        $this->assertEquals( 'themes-handbook', $second_handbook->post_type );
    6469    }
    6570
     
    7580        reinit_handbooks( [ 'plugins', 'themes' ], 'post_types' );
    7681
    77         $this->assertEquals( ['plugins', 'themes'], WPorg_Handbook_Init::get_post_types() );
     82        // Note: The automatic appending of '-handbook' is for back-compat.
     83        $this->assertEquals( ['plugins-handbook', 'themes-handbook'], WPorg_Handbook_Init::get_post_types() );
    7884    }
    7985
Note: See TracChangeset for help on using the changeset viewer.