Initial commit: Runware-powered content generator foundation

Laravel app with a cost-tracked Runware.ai integration (image, video,
text generation), a hard monthly EUR budget cap with live USD/EUR FX
conversion, and a locally-maintained model/pricing table since
Runware's model-search API doesn't expose pricing.
This commit is contained in:
2026-09-23 15:59:05 +03:00
commit 79320950e7
78 changed files with 14452 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace Tests\Feature;
use App\Models\RunwareModel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class RunwareModelDefaultTest extends TestCase
{
use RefreshDatabase;
public function test_cheapest_active_model_is_marked_default(): void
{
$expensive = RunwareModel::create([
'modality' => 'image', 'air_id' => 'a:expensive@1', 'label' => 'Expensive',
'unit' => 'per_image', 'price_usd' => 0.05, 'active' => true,
]);
RunwareModel::recomputeDefault('image');
$this->assertTrue($expensive->fresh()->is_default);
$cheap = RunwareModel::create([
'modality' => 'image', 'air_id' => 'a:cheap@1', 'label' => 'Cheap',
'unit' => 'per_image', 'price_usd' => 0.01, 'active' => true,
]);
RunwareModel::recomputeDefault('image');
$this->assertFalse($expensive->fresh()->is_default);
$this->assertTrue($cheap->fresh()->is_default);
$this->assertSame($cheap->air_id, RunwareModel::defaultFor('image')->air_id);
}
public function test_inactive_models_are_never_default(): void
{
$inactiveCheap = RunwareModel::create([
'modality' => 'video', 'air_id' => 'v:cheap@1', 'label' => 'Cheap but off',
'unit' => 'per_second', 'price_usd' => 0.001, 'active' => false,
]);
$active = RunwareModel::create([
'modality' => 'video', 'air_id' => 'v:active@1', 'label' => 'Active',
'unit' => 'per_second', 'price_usd' => 0.05, 'active' => true,
]);
RunwareModel::recomputeDefault('video');
$this->assertFalse($inactiveCheap->fresh()->is_default);
$this->assertTrue($active->fresh()->is_default);
}
}