56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\PianoRateizzazione;
|
|
use App\Models\RipartizioneSpese;
|
|
use App\Models\Stabile;
|
|
use App\Models\User;
|
|
use App\Models\VoceSpesa;
|
|
use App\Models\TabellaMillesimale;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class PianoRateizzazioneTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
public function test_piano_rateizzazione_creation()
|
|
{
|
|
$user = User::factory()->create();
|
|
$stabile = Stabile::factory()->create();
|
|
|
|
$piano = PianoRateizzazione::create([
|
|
'stabile_id' => $stabile->id,
|
|
'descrizione' => 'Piano test',
|
|
'importo_totale' => 1000.00,
|
|
'numero_rate' => 5,
|
|
'data_prima_rata' => now()->addMonth(),
|
|
'creato_da' => $user->id,
|
|
]);
|
|
|
|
$this->assertInstanceOf(PianoRateizzazione::class, $piano);
|
|
$this->assertEquals(1000.00, $piano->importo_totale);
|
|
$this->assertEquals(5, $piano->numero_rate);
|
|
$this->assertNotNull($piano->codice_piano);
|
|
$this->assertTrue(strlen($piano->codice_piano) === 8);
|
|
}
|
|
|
|
public function test_piano_rateizzazione_generate_code()
|
|
{
|
|
$codice1 = PianoRateizzazione::generaCodicePiano();
|
|
$codice2 = PianoRateizzazione::generaCodicePiano();
|
|
|
|
$this->assertNotEquals($codice1, $codice2);
|
|
$this->assertTrue(strlen($codice1) === 8);
|
|
$this->assertTrue(strlen($codice2) === 8);
|
|
$this->assertStringStartsWith('PR', $codice1);
|
|
$this->assertStringStartsWith('PR', $codice2);
|
|
}
|
|
}
|