some vibe tests
better than none
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\AccountClass;
|
||||
use App\AccountType;
|
||||
use App\Booking;
|
||||
use App\IOType;
|
||||
use App\SubBooking;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingAmountsTest extends TestCase
|
||||
{
|
||||
public function test_split_booking_uses_account_signs_and_preserves_unsigned_total()
|
||||
{
|
||||
$income = $this->line(125.50, 1);
|
||||
$expense = $this->line(25.25, -1);
|
||||
$booking = new Booking;
|
||||
$booking->setRelation('subBookings', new Collection([$income, $expense]));
|
||||
|
||||
$this->assertEquals(125.50, $income->signedAmount());
|
||||
$this->assertEquals(-25.25, $expense->signedAmount());
|
||||
$this->assertEquals(150.75, $booking->amount());
|
||||
$this->assertEquals(100.25, $booking->signedAmount());
|
||||
$this->assertFalse($booking->isSimple());
|
||||
$this->assertNull($booking->accountType());
|
||||
$this->assertNull($booking->project());
|
||||
$this->assertNull($booking->personTarget());
|
||||
}
|
||||
|
||||
protected function line($amount, $factor)
|
||||
{
|
||||
$io = (new IOType)->forceFill(['factor' => $factor]);
|
||||
$class = (new AccountClass)->setRelation('ioType', $io);
|
||||
$account = (new AccountType)->setRelation('accountClass', $class);
|
||||
|
||||
return (new SubBooking)->forceFill(['amount' => $amount])->setRelation('accountType', $account);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user