Changeset 36366 for trunk/tests/phpunit/tests/theme/getAllowedFilters.php
- Timestamp:
- 01/20/2016 06:28:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/getAllowedFilters.php
r36350 r36366 1 1 <?php 2 if ( is_multisite() ) : 2 3 /** 3 4 * Tests specific to the filtering of `WP_Theme::get_allowed()` and related functions. 4 5 * 5 6 * @group themes 7 * @group multisite 6 8 */ 7 9 class Tests_WP_Theme_Get_Allowed_Filters extends WP_UnitTestCase { … … 10 12 */ 11 13 protected $default_allowed; 14 15 protected $filter_network_allowed_themes_args; 16 17 public function test_network_allowed_themes_filter_sends_blog_id() { 18 $blog_id = 1; 19 20 add_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10, 2 ); 21 WP_Theme::get_allowed( $blog_id ); 22 remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ) ); 23 24 $this->assertEquals( 2, count( $this->filter_network_allowed_themes_args ) ); 25 $this->assertEquals( $blog_id, $this->filter_network_allowed_themes_args[1] ); 26 } 12 27 13 28 /** … … 28 43 } 29 44 45 /** 46 * Test the `network_allowed_themes` filter, which filters allowed themes on the network and provides `$blog_id`. 47 */ 48 public function test_wp_theme_get_allowed_with_network_allowed_themes_filter() { 49 $blog_id = 1; 50 51 $this->default_allowed = WP_Theme::get_allowed( $blog_id ); 52 53 add_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10, 2 ); 54 $allowed = WP_Theme::get_allowed( $blog_id ); 55 remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ), 10 ); 56 57 $expected = $this->default_allowed + array( 'network-allowed-theme' => true ); 58 59 $this->assertEquals( $expected, $allowed ); 60 } 61 62 /** 63 * Test the `site_allowed_themes` filter, which filters allowed themes for a site and provides `$blog_id`. 64 */ 65 public function test_wp_theme_get_allowed_with_site_allowed_themes_filter() { 66 $blog_id = 1; 67 68 $this->default_allowed = WP_Theme::get_allowed( $blog_id ); 69 70 add_filter( 'site_allowed_themes', array( $this, 'filter_site_allowed_themes' ), 10, 2 ); 71 $allowed = WP_Theme::get_allowed( $blog_id ); 72 remove_filter( 'site_allowed_themes', array( $this, 'filter_site_allowed_themes' ), 10 ); 73 74 $expected = $this->default_allowed + array( 'site-allowed-theme' => true ); 75 76 $this->assertEquals( $expected, $allowed ); 77 } 78 30 79 public function filter_allowed_themes( $allowed_themes ) { 31 80 $allowed_themes['allow-on-network'] = true; … … 33 82 return $allowed_themes; 34 83 } 84 85 public function filter_network_allowed_themes( $allowed_themes, $blog_id ) { 86 $this->filter_network_allowed_themes_args = func_get_args(); 87 88 $allowed_themes['network-allowed-theme'] = true; 89 90 return $allowed_themes; 91 } 92 93 public function filter_site_allowed_themes( $allowed_themes, $blog_id ) { 94 $allowed_themes['site-allowed-theme'] = true; 95 96 return $allowed_themes; 97 } 35 98 } 99 endif;
Note: See TracChangeset
for help on using the changeset viewer.