upskill-event-manager/wordpress-dev/vendor/yoast/wp-test-utils/src/BrainMonkey/YoastTestCase.php
bengizmo cdef12ee80 feat(events): Implement fallback logic and UI for Create/Modify Event page
- Refactored fallback submission logic in `class-event-handler.php` to remove `wp_die`/`exit` calls and use redirects for error handling, enabling proper unit testing.
- Implemented meta-data saving (dates, venue, organizer) in the fallback logic using `update_post_meta`.
- Updated unit tests (`test-event-management.php`) to remove `markTestIncomplete` calls related to handler errors and uncommented meta assertions. Unit tests for fallback logic now pass.
- Added Instructions section and Return to Dashboard button to the event form shortcode (`display_event_form_shortcode`).
- Applied basic theme styling classes (`ast-container`, `notice`, `ast-button`) to the event form.
- Updated `docs/implementation_plan.md` to reflect completion of tasks 4.1-4.5 and set focus to Task 5.

Refs: Task 4.1, 4.2, 4.3, 4.4, 4.5
2025-04-01 11:46:24 -03:00

71 lines
1.8 KiB
PHP

<?php
namespace Yoast\WPTestUtils\BrainMonkey;
use Brain\Monkey;
/**
* Test case for the Yoast plugins for use with a BrainMonkey based test suite.
*/
abstract class YoastTestCase extends TestCase {
/**
* Sets up test fixtures and function stubs.
*
* @return void
*/
protected function set_up() {
parent::set_up();
/*
* Create select additional function stubs.
* Null makes it so the function returns its first argument.
*/
Monkey\Functions\stubs(
[
// Passing "null" makes the function return it's first argument.
'get_bloginfo' => static function( $show ) {
switch ( $show ) {
case 'charset':
return 'UTF-8';
case 'language':
return 'English';
}
return $show;
},
'is_multisite' => static function() {
if ( \defined( 'WP_TESTS_MULTISITE' ) ) {
return (bool) \WP_TESTS_MULTISITE;
}
return false;
},
'mysql2date' => static function( $format, $date ) {
return $date;
},
'number_format_i18n' => null,
'sanitize_text_field' => null,
'site_url' => 'https://www.example.org',
'wp_kses_post' => null,
'wp_parse_args' => static function ( $args, $defaults ) {
return \array_merge( $defaults, $args );
},
'wp_strip_all_tags' => static function( $text, $remove_breaks = false ) {
$text = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $text );
$text = \strip_tags( $text );
if ( $remove_breaks ) {
$text = \preg_replace( '/[\r\n\t ]+/', ' ', $text );
}
return \trim( $text );
},
'wp_slash' => null,
'wp_unslash' => static function( $value ) {
return \is_string( $value ) ? \stripslashes( $value ) : $value;
},
]
);
}
}