mirror of
https://github.com/buddypress/buddypress.git
synced 2026-07-22 20:56:55 +08:00
Using these polyfills let us use PHPUnit v9.x for our tests and add PHP 8.1 to our testing matrix. Some additional edits to our PHP unit tests suite were needed: - Stop using PHPunit deprecated functions. - Rename some `BP_UnitTestCase` methods to use Yoast's polyfills. - Edit the PHP Unit test GH action and also run this action on pull requests. - Update some composer dependencies, remove the one about `phpunit/phpunit:^7.5` and add a new composer script to use PHPUnit v9.x. Props renatonascalves, rafiahmedd Closes https://github.com/buddypress/buddypress/pull/13 Fixes #8649 git-svn-id: https://buddypress.svn.wordpress.org/trunk@13314 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
42 lines
983 B
PHP
42 lines
983 B
PHP
<?php
|
|
|
|
/**
|
|
* @group core
|
|
* @group core-template-loader
|
|
*/
|
|
class BP_Tests_Template_Loader_Functions extends BP_UnitTestCase {
|
|
|
|
public function set_up() {
|
|
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::set_up();
|
|
}
|
|
|
|
public function tear_down() {
|
|
remove_filter( 'bp_get_template_stack', array( $this, 'template_stack'), 10, 1 );
|
|
|
|
parent::tear_down();
|
|
}
|
|
|
|
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 );
|
|
}
|
|
}
|