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/templateLoader.php
David Cavins 1d4093475a Pass extra args to template loading files.
Starting in WordPress 5.5, the template loading
functions will now allow additional arguments to be
passed through to the matched template file using a
new $args parameter.

This changeset passes an extra argument through
the BuddyPress template loading wrapper functions
to the underlying WordPress functions.

Props imath.

Fixes #8350.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@12726 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2020-09-19 18:19:45 +00:00

42 lines
979 B
PHP

<?php
/**
* @group core
* @group core-template-loader
*/
class BP_Tests_Template_Loader_Functions extends BP_UnitTestCase {
public function setUp() {
if ( version_compare( bp_get_major_wp_version(), '5.5', '<' ) ) {
$this->markTestSkipped(
'Passing variables in template parts was introduced in WordPress 5.5'
);
}
add_filter( 'bp_get_template_stack', array( $this, 'template_stack'), 10, 1 );
parent::setUp();
}
public function tearDown() {
remove_filter( 'bp_get_template_stack', array( $this, 'template_stack'), 10, 1 );
parent::tearDown();
}
public function template_stack( $stack = array() ) {
return array_merge(
array(
dirname( dirname( dirname( __FILE__ ) ) ) . '/assets/templates/',
)
);
}
/**
* @group bp_buffer_template_part
*/
public function test_bp_buffer_template_part() {
$buffer = bp_buffer_template_part( 'index', null, false, array( 'test' => 1 ) );
$this->assertTrue( 2 === (int) $buffer );
}
}