-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
68 lines (56 loc) · 1.85 KB
/
Copy pathbootstrap.php
File metadata and controls
68 lines (56 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* PHPUnit bootstrap for unit tests.
*
* @package wpRigel\Pollify\Tests
*/
require dirname( __DIR__ ) . '/vendor/autoload.php';
// Minimal WP constants required by plugin classes.
defined( 'ABSPATH' ) || define( 'ABSPATH', '/tmp/' );
defined( 'WPINC' ) || define( 'WPINC', 'wp-includes' );
// Stub WP_Error so tests can assert on return types without a WP bootstrap.
if ( ! class_exists( 'WP_Error' ) ) {
class WP_Error { // phpcs:ignore
public string $code;
public string $message;
public mixed $data;
public function __construct( string $code = '', string $message = '', mixed $data = '' ) {
$this->code = $code;
$this->message = $message;
$this->data = $data;
}
public function get_error_code(): string {
return $this->code;
}
public function get_error_message(): string {
return $this->message;
}
public function get_error_data(): mixed {
return $this->data;
}
}
}
// Pure utility stubs — deterministic, never mocked per-test via Brain\Monkey.
// WP_Error must be defined above before is_wp_error() references it.
if ( ! function_exists( 'wp_unslash' ) ) {
function wp_unslash( $value ) {
return is_array( $value )
? array_map( 'wp_unslash', $value )
: stripslashes( (string) $value );
}
}
if ( ! function_exists( 'wp_json_encode' ) ) {
function wp_json_encode( $data, $options = 0, $depth = 512 ) {
return json_encode( $data, $options, $depth );
}
}
if ( ! function_exists( 'is_wp_error' ) ) {
function is_wp_error( $thing ) {
return $thing instanceof WP_Error;
}
}
// Constants required by helpers/functions.php.
defined( 'POLLIFY_FILTER_SANITIZE_STRING' ) || define( 'POLLIFY_FILTER_SANITIZE_STRING', 999 );
defined( 'POLLIFY_PATH' ) || define( 'POLLIFY_PATH', dirname( __DIR__ ) );
// Load helper functions (not PSR-4 autoloaded).
require dirname( __DIR__ ) . '/includes/helpers/functions.php';