Add unit test suite: 54 tests across models, core, and providers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,64 +2,24 @@
|
||||
/**
|
||||
* PHPUnit bootstrap for PRAutoBlogger unit tests.
|
||||
*
|
||||
* Uses Brain Monkey to mock WordPress functions so tests run without
|
||||
* a full WordPress installation. Only loads the classes under test.
|
||||
* Loads Brain\Monkey for WordPress function mocking,
|
||||
* then requires the source files under test.
|
||||
*
|
||||
* @see https://brain-wp.github.io/BrainMonkey/
|
||||
* @package PRAutoBlogger\Tests
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
require_once dirname( __DIR__ ) . '/vendor/autoload.php';
|
||||
|
||||
// Composer autoloader for Brain Monkey and test dependencies.
|
||||
$autoloader = __DIR__ . '/../vendor/autoload.php';
|
||||
if ( ! file_exists( $autoloader ) ) {
|
||||
echo "Run 'composer install' before running tests.\n";
|
||||
exit( 1 );
|
||||
}
|
||||
require_once $autoloader;
|
||||
// Brain\Monkey sets up Patchwork & function stubs.
|
||||
\Brain\Monkey\setUp();
|
||||
|
||||
// Define WordPress constants that plugin code expects.
|
||||
// Define WordPress constants that source files expect.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
define( 'ABSPATH', '/tmp/fake-wp/' );
|
||||
define( 'ABSPATH', '/tmp/wordpress/' );
|
||||
}
|
||||
if ( ! defined( 'DAY_IN_SECONDS' ) ) {
|
||||
define( 'DAY_IN_SECONDS', 86400 );
|
||||
if ( ! defined( 'PRAB_VERSION' ) ) {
|
||||
define( 'PRAB_VERSION', '1.0.0-test' );
|
||||
}
|
||||
if ( ! defined( 'HOUR_IN_SECONDS' ) ) {
|
||||
define( 'HOUR_IN_SECONDS', 3600 );
|
||||
if ( ! defined( 'PRAB_PLUGIN_DIR' ) ) {
|
||||
define( 'PRAB_PLUGIN_DIR', dirname( __DIR__ ) . '/' );
|
||||
}
|
||||
|
||||
// PRAutoBlogger constants from the main plugin file.
|
||||
if ( ! defined( 'PRAUTOBLOGGER_VERSION' ) ) {
|
||||
define( 'PRAUTOBLOGGER_VERSION', '0.1.0' );
|
||||
}
|
||||
if ( ! defined( 'PRAUTOBLOGGER_MAX_RETRIES' ) ) {
|
||||
define( 'PRAUTOBLOGGER_MAX_RETRIES', 3 );
|
||||
}
|
||||
if ( ! defined( 'PRAUTOBLOGGER_RETRY_BASE_DELAY_SECONDS' ) ) {
|
||||
define( 'PRAUTOBLOGGER_RETRY_BASE_DELAY_SECONDS', 2 );
|
||||
}
|
||||
if ( ! defined( 'PRAUTOBLOGGER_DEFAULT_ANALYSIS_MODEL' ) ) {
|
||||
define( 'PRAUTOBLOGGER_DEFAULT_ANALYSIS_MODEL', 'anthropic/claude-3.5-haiku' );
|
||||
}
|
||||
if ( ! defined( 'PRAUTOBLOGGER_DEFAULT_WRITING_MODEL' ) ) {
|
||||
define( 'PRAUTOBLOGGER_DEFAULT_WRITING_MODEL', 'anthropic/claude-sonnet-4' );
|
||||
}
|
||||
if ( ! defined( 'PRAUTOBLOGGER_DEFAULT_EDITOR_MODEL' ) ) {
|
||||
define( 'PRAUTOBLOGGER_DEFAULT_EDITOR_MODEL', 'anthropic/claude-sonnet-4' );
|
||||
}
|
||||
|
||||
// Load plugin class files (no autoloader in tests — explicit includes).
|
||||
$includes_dir = dirname( __DIR__ ) . '/includes';
|
||||
|
||||
// Models (no WP dependencies, safe to load).
|
||||
require_once $includes_dir . '/models/class-generation-log.php';
|
||||
require_once $includes_dir . '/models/class-content-score.php';
|
||||
require_once $includes_dir . '/models/class-source-data.php';
|
||||
require_once $includes_dir . '/models/class-analysis-result.php';
|
||||
require_once $includes_dir . '/models/class-article-idea.php';
|
||||
require_once $includes_dir . '/models/class-editorial-review.php';
|
||||
require_once $includes_dir . '/models/class-content-request.php';
|
||||
|
||||
// Providers (loaded on demand in tests since they need WP mocks).
|
||||
// Core classes (loaded on demand in tests since they need WP mocks).
|
||||
|
||||
Reference in New Issue
Block a user