4 changed files with 115 additions and 75 deletions
-
11app/Entities/Payments/Payment.php
-
21database/factories/ModelFactory.php
-
46database/factories/PaymentFactory.php
-
12tests/Unit/Models/PaymentTest.php
@ -0,0 +1,46 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use App\Entities\Partners\Vendor; |
||||
|
use App\Entities\Payments\Payment; |
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Entities\Users\User; |
||||
|
use Faker\Generator as Faker; |
||||
|
|
||||
|
$factory->define(Payment::class, function (Faker $faker) { |
||||
|
|
||||
|
return [ |
||||
|
'project_id' => function () { |
||||
|
return factory(Project::class)->create()->id; |
||||
|
}, |
||||
|
'amount' => 10000, |
||||
|
'in_out' => 1, |
||||
|
'type_id' => rand(1, 3), |
||||
|
'date' => $faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'), |
||||
|
'description' => $faker->paragraph, |
||||
|
'owner_id' => function () { |
||||
|
return factory(User::class)->create()->id; |
||||
|
}, |
||||
|
'customer_id' => function () { |
||||
|
return factory(Customer::class)->create()->id; |
||||
|
}, |
||||
|
]; |
||||
|
}); |
||||
|
|
||||
|
$factory->state(Payment::class, 'income', function (Faker $faker) { |
||||
|
return [ |
||||
|
'in_out' => 1, |
||||
|
'customer_id' => function () { |
||||
|
return factory(Customer::class)->create()->id; |
||||
|
}, |
||||
|
]; |
||||
|
}); |
||||
|
|
||||
|
$factory->state(Payment::class, 'expanse', function (Faker $faker) { |
||||
|
return [ |
||||
|
'in_out' => 2, |
||||
|
'customer_id' => function () { |
||||
|
return factory(Vendor::class)->create()->id; |
||||
|
}, |
||||
|
]; |
||||
|
}); |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue