Changeset 10765
- Timestamp:
- 03/04/2021 11:49:42 PM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook
- Files:
-
- 2 edited
-
inc/init.php (modified) (1 diff)
-
phpunit/tests/init.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/init.php
r10759 r10765 20 20 public static function get_handbook_objects() { 21 21 return self::$handbooks; 22 } 23 24 /** 25 * Returns a handbook of the given post type. 26 * 27 * @param string $post_type The handbook post type. 28 * @return WPorg_Handbook|false The handbook object, or false if no such 29 * handbook. 30 */ 31 public static function get_handbook( $post_type ) { 32 $handbooks = self::get_handbook_objects(); 33 return $handbooks[ $post_type ] ?? false; 22 34 } 23 35 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/phpunit/tests/init.php
r10761 r10765 70 70 71 71 /* 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 /* 72 96 * get_post_types() 73 97 */
Note: See TracChangeset
for help on using the changeset viewer.