Skip to content

Commit

Permalink
Merge branch 'master' into test/controller-test-case-invariance
Browse files Browse the repository at this point in the history
  • Loading branch information
Camwyn committed Apr 10, 2024
2 parents d395ff2 + 4bb1809 commit 7ced16b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 31 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tribe-common",
"version": "5.2.4",
"version": "5.2.5",
"repository": "git@github.com:the-events-calendar/tribe-common.git",
"_resourcepath": "src/resources",
"_domainPath": "lang",
Expand Down
6 changes: 6 additions & 0 deletions readme.txt
Expand Up @@ -4,6 +4,12 @@

* Fix - Ensure set up and tear down methods of the `Controller_Test_Case` will work independently of the PHPUnit version.

= [5.2.5] 2024-04-09 =

* Tweak - Improve compatibility with some theme styling re: calendar buttons. [TEC-5047]
* Tweak - Rename the `Controller_Test_Case` `setUp` and `tearDown` methods and annotate them with `@before` and `@after` annotations to improve PHPUnit version cross-compat.
* Language - 0 new strings added, 0 updated, 1 fuzzied, and 0 obsoleted.

= [5.2.4] 2024-03-20 =

* Fix - Resolves a PHP 8.2 deprecation error on `Date_Utils` - `PHP Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /.../wp-content/plugins/the-events-calendar/common/src/Tribe/Date_Utils.php on line 256`. [ECP-1620]
Expand Down
2 changes: 1 addition & 1 deletion src/Tribe/Main.php
Expand Up @@ -18,7 +18,7 @@ class Tribe__Main {
const OPTIONNAME = 'tribe_events_calendar_options';
const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options';
const FEED_URL = 'https://theeventscalendar.com/feed/';
const VERSION = '5.2.4';
const VERSION = '5.2.5';

protected $plugin_context;
protected $plugin_context_class;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/postcss/utilities
Submodule utilities updated 0 files
60 changes: 35 additions & 25 deletions tests/_support/Provider/Controller_Test_Case.php
Expand Up @@ -97,9 +97,13 @@ protected function set_up_controller_test_case(): void {
$test_services = clone $original_services;

// From now on calls to the Service Locator (the `tribe` function) will be redirected to a test Service Locator.
uopz_set_return( 'tribe', static function ( $key = null ) use ( $test_services ) {
return $key ? $test_services->get( $key ) : $test_services;
}, true );
uopz_set_return(
'tribe',
static function ( $key = null ) use ( $test_services ) {
return $key ? $test_services->get( $key ) : $test_services;
},
true
);
// Redirect calls to init the container too.
uopz_set_return( Container::class, 'init', $test_services );
$this->test_services = $test_services;
Expand Down Expand Up @@ -163,8 +167,6 @@ protected function tear_down_controller_test_case(): void {
$this->_backup_hooks();

$this->original_controller = null;

parent::tearDown();
}

/**
Expand All @@ -185,24 +187,28 @@ protected function make_controller( string $controller_class = null ): Controlle
// From now on, ingest all logging.
global $wp_filter;
$wp_filter['tribe_log'] = new WP_Hook(); // phpcs:ignore
add_action( 'tribe_log', function ( $level, $message, $context ) {
if ( isset( $context['controller'] ) && $context['controller'] === $this->controller_class ) {
// Log the controller logs.
$this->controller_logs[] = [
add_action(
'tribe_log',
function ( $level, $message, $context ) {
if ( isset( $context['controller'] ) && $context['controller'] === $this->controller_class ) {
// Log the controller logs.
$this->controller_logs[] = [
'level' => $level,
'message' => $message,
'context' => $context,
];
}

// Log everything.
$this->logs[] = [
'level' => $level,
'message' => $message,
'context' => $context,
];
}

// Log everything.
$this->logs[] = [
'level' => $level,
'message' => $message,
'context' => $context,
];

}, 10, 3 );
},
10,
3
);

// Due to the previous unset, the container will build this as a prototype.
$controller = $this->test_services->make( $controller_class );
Expand Down Expand Up @@ -317,13 +323,17 @@ protected function unregister_all_controller_instances( Controller $original_con
// Here we use the controller to let use know what filters it would hook to by
// intercepting the `add_filter` function.
$hooked = [];
uopz_set_return( 'add_filter', function ( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) use ( &$hooked ) {
if ( ! ( is_array( $function_to_add ) && $function_to_add[0] instanceof Controller ) ) {
return false;
}
uopz_set_return(
'add_filter',
function ( $tag, $function_to_add, $priority = 10 ) use ( &$hooked ) {
if ( ! ( is_array( $function_to_add ) && $function_to_add[0] instanceof Controller ) ) {
return false;
}

$hooked[] = [ $tag, $priority ];
}, true );
$hooked[] = [ $tag, $priority ];
},
true
);
// The controller will also flag itself as registered in the Service Locator.
$original_controller->register();
// No need to mock add_filter anymore.
Expand Down
2 changes: 1 addition & 1 deletion tribe-common.php
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Tribe Common
* Description: An event settings framework for managing shared options
* Version: 5.2.4
* Version: 5.2.5
* Author: The Events Calendar
* Author URI: http://evnt.is/1x
* Text Domain: tribe-common
Expand Down

0 comments on commit 7ced16b

Please sign in to comment.