diff --git a/app/Entities/Payments/Payment.php b/app/Entities/Payments/Payment.php index 68443ea..ecc42b9 100755 --- a/app/Entities/Payments/Payment.php +++ b/app/Entities/Payments/Payment.php @@ -6,7 +6,6 @@ use App\Entities\Partners\Customer; use App\Entities\Partners\Vendor; use App\Entities\Payments\PaymentPresenter; use App\Entities\Projects\Project; -use App\Entities\Users\User; use Illuminate\Database\Eloquent\Model; use Laracasts\Presenter\PresentableTrait; @@ -25,7 +24,7 @@ class Payment extends Model public function customer() { - return $this->belongsTo(User::class, 'customer_id'); + return $this->belongsTo(Customer::class, 'customer_id'); } public function partner() diff --git a/database/factories/PaymentFactory.php b/database/factories/PaymentFactory.php index 4e9ff11..9c04037 100644 --- a/database/factories/PaymentFactory.php +++ b/database/factories/PaymentFactory.php @@ -1,7 +1,6 @@ define(Payment::class, function (Faker $faker) { 'owner_id' => function () { return factory(User::class)->create()->id; }, - 'partner_id' => function () { + 'customer_id' => function () { return factory(Customer::class)->create()->id; }, ]; }); - -$factory->defineAs(Payment::class, 'income', 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; - }, - 'partner_id' => function () { - return factory(Customer::class)->create()->id; - }, - ]; -}); - -$factory->defineAs(Payment::class, 'expanse', function (Faker $faker) { - return [ - 'project_id' => function () { - return factory(Project::class)->create()->id; - }, - 'amount' => 10000, - 'in_out' => 2, - '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; - }, - 'partner_id' => function () { - return factory(Vendor::class)->create()->id; - }, - ]; -}); diff --git a/tests/Unit/Models/PaymentTest.php b/tests/Unit/Models/PaymentTest.php index cae270a..8b7e6da 100644 --- a/tests/Unit/Models/PaymentTest.php +++ b/tests/Unit/Models/PaymentTest.php @@ -3,19 +3,15 @@ namespace Tests\Unit\Models; use App\Entities\Partners\Customer; -use App\Entities\Partners\Vendor; use App\Entities\Payments\Payment; use Tests\TestCase; class PaymentTest extends TestCase { /** @test */ - public function it_has_partner_relation() + public function it_has_customer_relation() { - $payment = factory(Payment::class, 'income')->create(['in_out' => 1]); - $this->assertTrue($payment->partner instanceof Customer); - - $payment = factory(Payment::class, 'expanse')->create(['in_out' => 0]); - $this->assertTrue($payment->partner instanceof Vendor); + $payment = factory(Payment::class)->create(); + $this->assertTrue($payment->customer instanceof Customer); } }