Making WordPress.org


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

Handbooks, Init: Add get_handbook() for obtaining a handbook based on post type.

File:
1 edited

Legend:

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

    r10761 r10765  
    7070
    7171    /*
     72     * get_handbook()
     73     */
     74
     75    public function test_get_handbook_for_invalid_handbook() {
     76        $this->assertFalse( WPorg_Handbook_Init::get_handbook( 'nonexistent-handbook' ) );
     77    }
     78
     79    public function test_get_handbook() {
     80        $handbook = WPorg_Handbook_Init::get_handbook( 'handbook' );
     81
     82        $this->assertTrue( is_a( $handbook, 'WPorg_Handbook' ) );
     83        $this->assertEquals( 'handbook', $handbook->post_type );
     84    }
     85
     86    public function test_get_handbook_when_multiple_handbooks_present() {
     87        reinit_handbooks( [ 'plugins-handbook', 'themes-handbook' ], 'post_types' );
     88
     89        $handbook = WPorg_Handbook_Init::get_handbook( 'plugins-handbook' );
     90
     91        $this->assertTrue( is_a( $handbook, 'WPorg_Handbook' ) );
     92        $this->assertEquals( 'plugins-handbook', $handbook->post_type );
     93    }
     94
     95    /*
    7296     * get_post_types()
    7397     */
Note: See TracChangeset for help on using the changeset viewer.