fix: add missing WordPress function stubs to unit tests
- ContentAnalyzerTest: pass Cost_Tracker as 2nd constructor arg - IdeaScorerTest: stub get_option for topic_exclusions - CostTrackerTest: stub get_option for monthly_budget_usd - OpenRouterPricingTest: stub get_transient with cached model data - OpenRouterProviderTest: stub get_option for API key + get_transient Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,40 @@
|
||||
namespace PRAutoBlogger\Tests\Providers;
|
||||
|
||||
use PRAutoBlogger\Tests\BaseTestCase;
|
||||
use Brain\Monkey\Functions;
|
||||
|
||||
class OpenRouterPricingTest extends BaseTestCase {
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
// OpenRouterPricing::get_available_models() calls get_transient() to check cache.
|
||||
// Return a valid cached model list so it doesn't try to make HTTP calls.
|
||||
Functions\when( 'get_transient' )->alias(
|
||||
function ( string $key ) {
|
||||
if ( 'prautoblogger_openrouter_models' === $key ) {
|
||||
return [
|
||||
[
|
||||
'id' => 'google/gemini-2.0-flash-001',
|
||||
'name' => 'Gemini 2.0 Flash',
|
||||
'context_length' => 32768,
|
||||
'pricing' => [ 'prompt' => 0.10, 'completion' => 0.40 ],
|
||||
],
|
||||
[
|
||||
'id' => 'anthropic/claude-sonnet-4',
|
||||
'name' => 'Claude Sonnet 4',
|
||||
'context_length' => 200000,
|
||||
'pricing' => [ 'prompt' => 3.00, 'completion' => 15.00 ],
|
||||
],
|
||||
];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
Functions\when( 'set_transient' )->justReturn( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Pricing can be instantiated.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user