-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
133 lines (119 loc) · 3.61 KB
/
bootstrap.php
File metadata and controls
133 lines (119 loc) · 3.61 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* PHPUnit Bootstrap File
*
* This file initializes the testing environment for the Beer Slurper plugin.
* It defines necessary constants, loads Composer dependencies, and bootstraps
* WorDBless for running tests with real WordPress functions.
*
* @package Kraft\Beer_Slurper\Tests
*/
/*
* Composer autoloader validation and loading.
*
* Verifies that Composer dependencies have been installed before proceeding.
* Throws an exception if the autoloader is missing.
*/
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
throw new PHPUnit\Framework\Exception(
'ERROR' . PHP_EOL . PHP_EOL .
'You must use Composer to install the test suite\'s dependencies!' . PHP_EOL
);
}
require_once __DIR__ . '/vendor/autoload.php';
/*
* Define testing mode constant.
*
* This suppresses debug logging during tests to keep output clean.
*/
if ( ! defined( 'BEER_SLURPER_TESTING' ) ) {
define( 'BEER_SLURPER_TESTING', true );
}
/**
* Logging helper function for tests.
*
* Defined here in bootstrap so it's available before plugin files are loaded.
* In production, this function is defined in beer-slurper.php.
*/
if ( ! function_exists( 'beer_slurper_log' ) ) {
function beer_slurper_log( $message ) {
if ( defined( 'BEER_SLURPER_TESTING' ) && BEER_SLURPER_TESTING ) {
return;
}
error_log( $message );
}
}
/*
* Define ABSPATH before loading WorDBless.
* WorDBless expects WordPress to be in vendor/wordpress directory.
*/
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/wordpress/' );
}
/*
* WorDBless initialization.
*
* Loads WordPress core functions for testing with SQLite database.
* This enables full database functionality including Action Scheduler.
*/
\WorDBless\Load::load( 'sqlite' );
/*
* Enable term meta support.
*
* WordPress checks db_version to determine if term meta is supported (added in WP 4.4).
* WorDBless doesn't set this option, so WordPress disables term meta operations.
* We set it to a modern WP version to enable full term meta functionality.
*/
if ( ! get_option( 'db_version' ) ) {
update_option( 'db_version', 58975 );
}
/*
* Project directory constant.
*
* Defines the path to the includes directory for loading project files.
*/
if ( ! defined( 'PROJECT' ) ) {
define( 'PROJECT', __DIR__ . '/includes/' );
}
/*
* Beer Slurper directory constant.
*
* Defines the root path of the Beer Slurper plugin.
*/
if ( ! defined( 'BEER_SLURPER_DIR' ) ) {
define( 'BEER_SLURPER_DIR', __DIR__ . '/' );
}
/*
* Plugin path constants.
*/
if ( ! defined( 'BEER_SLURPER_PATH' ) ) {
define( 'BEER_SLURPER_PATH', __DIR__ . '/beer-slurper.php' );
}
if ( ! defined( 'BEER_SLURPER_INC' ) ) {
define( 'BEER_SLURPER_INC', __DIR__ . '/includes/' );
}
// Load plugin constants needed for tests
// Note: BEER_SLURPER_PATH and BEER_SLURPER_INC are already defined above
if ( ! defined( 'BEER_SLURPER_CPT' ) ) {
define( 'BEER_SLURPER_CPT', 'beerlog_beer' );
}
if ( ! defined( 'BEER_SLURPER_TAX_STYLE' ) ) {
define( 'BEER_SLURPER_TAX_STYLE', 'beerlog_style' );
}
if ( ! defined( 'BEER_SLURPER_TAX_BREWERY' ) ) {
define( 'BEER_SLURPER_TAX_BREWERY', 'beerlog_brewery' );
}
if ( ! defined( 'BEER_SLURPER_TAX_VENUE' ) ) {
define( 'BEER_SLURPER_TAX_VENUE', 'beerlog_venue' );
}
if ( ! defined( 'BEER_SLURPER_TAX_BADGE' ) ) {
define( 'BEER_SLURPER_TAX_BADGE', 'beerlog_badge' );
}
if ( ! defined( 'BEER_SLURPER_TAX_COMPANION' ) ) {
define( 'BEER_SLURPER_TAX_COMPANION', 'beerlog_companion' );
}
/*
* Load shared HTTP helpers before other files that depend on them.
*/
require_once __DIR__ . '/includes/functions/http.php';
require_once __DIR__ . '/tests/phpunit/test-tools/TestCase.php';