1
0
Fork 0
mirror of https://github.com/buddypress/buddypress.git synced 2026-07-22 20:56:55 +08:00
buddypress/tests/phpunit/testcases/core/themeCompatibility.php
Mathieu Viet 3a1f663e19 Introduce theme support check for specific component features
Some of the feature we'll soon introduce like the Block based activity post form will need standalone BP themes to do some adjustments to their code to support them.

Once done, they'll need to opt-in for these features using the WordPress `add_theme_support()` function. The first argument for this function remains `buddypress`. Supporting BP component specific features will need to use a second argument: an associative array keyed by BP Component IDs. For instance, it will be `array( 'activity' => array( 'block-editor' ) )` when a theme support the future Block based activity post form.

In BuddyPress code, we'll then be able for example to use the following kind of check `bp_current_theme_supports( array( 'activity' => 'block-editor' ) )` to be sure the theme fully support the feature.

Props espellcaste

See #8319
Closes https://github.com/buddypress/buddypress/pull/301



git-svn-id: https://buddypress.svn.wordpress.org/trunk@13912 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2024-06-08 06:09:24 +00:00

58 lines
1.7 KiB
PHP

<?php
/**
* @group core
* @group core-theme-compatibility
* @group bp_current_theme_supports
*/
class BP_Tests_Theme_Compatibility_Functions extends BP_UnitTestCase {
public function test_bp_current_theme_doesnot_support() {
$this->assertFalse( bp_current_theme_supports() );
}
public function test_bp_current_theme_does_support_buddypress() {
add_theme_support( 'buddypress' );
$this->assertTrue( bp_current_theme_supports() );
}
public function test_bp_current_theme_doesnot_support_buddypress_feature() {
add_theme_support( 'buddypress' );
$this->assertFalse( bp_current_theme_supports( array( 'activity' => 'feature' ) ) );
}
public function test_bp_current_theme_does_support_buddypress_feature() {
add_theme_support(
'buddypress',
array(
'activity' => array( 'feature1', 'feature2' ),
)
);
$this->assertTrue( bp_current_theme_supports( array( 'activity' => 'feature1' ) ) );
$this->assertFalse( bp_current_theme_supports( array( 'activity' => 'feature3' ) ) );
$this->assertFalse( bp_current_theme_supports( array( 'notifications' => '' ) ) );
$this->assertTrue( bp_current_theme_supports() );
}
/**
* @expectedIncorrectUsage bp_current_theme_supports
*/
public function test_bp_current_theme_support_incorrect_usage() {
add_theme_support(
'buddypress',
array(
'activity' => array( 'feature1', 'feature2' ),
'notifications' => array( 'feature3' ),
)
);
$this->assertFalse( bp_current_theme_supports( array( 'activity' => array( 'feature1', 'feature2' ) ) ) );
$this->assertFalse(
bp_current_theme_supports(
array(
'activity' => 'feature1',
'notifications' => 'feature3',
)
)
);
}
}