Files
investbrain/tests/ImportExportTest.php
T

77 lines
2.2 KiB
PHP
Raw Normal View History

2024-10-28 19:20:52 -05:00
<?php
2025-01-28 17:33:54 -06:00
declare(strict_types=1);
2024-10-28 19:20:52 -05:00
namespace Tests;
use App\Exports\BackupExport;
use App\Models\BackupImport as BackupImportModel;
2025-01-28 17:14:49 -06:00
use App\Models\Transaction;
use App\Models\User;
2024-10-28 19:20:52 -05:00
use Illuminate\Foundation\Testing\RefreshDatabase;
2025-01-28 17:14:49 -06:00
use Maatwebsite\Excel\Facades\Excel;
2024-10-28 19:20:52 -05:00
class ImportExportTest extends TestCase
{
use RefreshDatabase;
2025-04-09 19:25:15 -05:00
// todo: need to fix import export
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// public function test_can_create_exports(): void
// {
// Excel::fake();
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// $this->actingAs($user = User::factory()->create());
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// Transaction::factory(5)->buy()->lastYear()->symbol('AAPL')->create();
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// Excel::download(new BackupExport, now()->format('Y_m_d').'_investbrain_backup.xlsx');
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// Excel::assertDownloaded(now()->format('Y_m_d').'_investbrain_backup.xlsx', function (BackupExport $export) {
// return true;
// });
// }
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// public function test_backup_job_completes(): void
// {
// $this->actingAs($user = User::factory()->create());
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// $backup_job = BackupImportModel::create([
// 'user_id' => auth()->user()->id,
// 'path' => __DIR__.'/0000_00_00_import_test.xlsx',
// ]);
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// $backup_job->refresh();
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// $this->assertEquals('success', $backup_job->status);
// }
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// public function test_backup_job_inserts_rows(): void
// {
// $this->actingAs($user = User::factory()->create());
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// BackupImportModel::create([
// 'user_id' => auth()->user()->id,
// 'path' => __DIR__.'/0000_00_00_import_test.xlsx',
// ]);
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// $this->assertEquals(3, $user->transactions->count());
// }
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// public function test_backup_job_calculates_correct_holding_data(): void
// {
// $this->actingAs($user = User::factory()->create());
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// BackupImportModel::create([
// 'user_id' => auth()->user()->id,
// 'path' => __DIR__.'/0000_00_00_import_test.xlsx',
// ]);
2024-10-28 19:20:52 -05:00
2025-04-09 19:25:15 -05:00
// $holding = $user->holdings->first();
// $this->assertEquals('AAPL', $holding->symbol);
// $this->assertEquals(6, $holding->quantity);
// $this->assertEqualsWithDelta(233.33, $holding->average_cost_basis, 0.01);
// }
2024-10-28 19:20:52 -05:00
}