Themes: Add initial tests for the allowed_themes filter.

We'll be adjusting the placement of this filter and adding two other related filters, so we should make sure it continues to work as expected after the change.

See #28436.


git-svn-id: https://develop.svn.wordpress.org/trunk@36350 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jeremy Felt 2016-01-19 23:57:46 +00:00
parent b9e62671f6
commit 18d9640a5a

View File

@ -0,0 +1,35 @@
<?php
/**
* Tests specific to the filtering of `WP_Theme::get_allowed()` and related functions.
*
* @group themes
*/
class Tests_WP_Theme_Get_Allowed_Filters extends WP_UnitTestCase {
/**
* @array List of themes allowed before filters are applied.
*/
protected $default_allowed;
/**
* Test the `allowed_themes` filter, which filters themes allowed on a network.
*/
public function test_wp_theme_get_allowed_with_allowed_themes_filter() {
$blog_id = 1;
$this->default_allowed = WP_Theme::get_allowed( $blog_id );
add_filter( 'allowed_themes', array( $this, 'filter_allowed_themes' ), 10 );
$allowed = WP_Theme::get_allowed( $blog_id );
remove_filter( 'allowed_themes', array( $this, 'filter_allowed_themes' ), 10 );
$expected = $this->default_allowed + array( 'allow-on-network' => true );
$this->assertEquals( $expected, $allowed );
}
public function filter_allowed_themes( $allowed_themes ) {
$allowed_themes['allow-on-network'] = true;
return $allowed_themes;
}
}