diff --git a/app/Entities/Subscriptions/Subscription.php b/app/Entities/Subscriptions/Subscription.php index 90eee3f..62968fb 100755 --- a/app/Entities/Subscriptions/Subscription.php +++ b/app/Entities/Subscriptions/Subscription.php @@ -19,7 +19,7 @@ class Subscription extends Model public function vendor() { - return $this->belongsTo('App\Entities\Partners\Customer'); + return $this->belongsTo('App\Entities\Partners\Vendor'); } public function status() diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index b6148a0..fb82c06 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -1,7 +1,7 @@ define(Subscription::class, function (Faker\Generator $faker) { 'due_date' => $startDate->addYears(1)->format('Y-m-d'), 'remark' => $faker->paragraph, 'vendor_id' => function () { - return factory(Customer::class)->create()->id; + return factory(Vendor::class)->create()->id; }, ]; }); diff --git a/tests/Feature/ManageSubscriptionsTest.php b/tests/Feature/ManageSubscriptionsTest.php index e7c5bfd..cc95566 100644 --- a/tests/Feature/ManageSubscriptionsTest.php +++ b/tests/Feature/ManageSubscriptionsTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature; use App\Entities\Partners\Customer; +use App\Entities\Partners\Vendor; use App\Entities\Projects\Project; use App\Entities\Subscriptions\Subscription; use Tests\TestCase; @@ -13,7 +14,7 @@ class ManageSubscriptionsTest extends TestCase public function admin_can_entry_subscription() { $user = $this->adminUserSigningIn(); - $vendor = factory(Customer::class)->create(['owner_id' => $user->agency->id]); + $vendor = factory(Vendor::class)->create(['owner_id' => $user->agency->id]); $customer = factory(Customer::class)->create(['owner_id' => $user->agency->id]); $project = factory(Project::class)->create(['owner_id' => $user->agency->id, 'customer_id' => $customer->id]); @@ -52,7 +53,7 @@ class ManageSubscriptionsTest extends TestCase { $eppCode = str_random(10); $user = $this->adminUserSigningIn(); - $vendor = factory(Customer::class)->create(['owner_id' => $user->agency->id]); + $vendor = factory(Vendor::class)->create(['owner_id' => $user->agency->id]); $customer = factory(Customer::class)->create(['owner_id' => $user->agency->id]); $project = factory(Project::class)->create(['owner_id' => $user->agency->id, 'customer_id' => $customer->id]); diff --git a/tests/Unit/Models/SubscriptionTest.php b/tests/Unit/Models/SubscriptionTest.php index f80d37c..05f3dfd 100644 --- a/tests/Unit/Models/SubscriptionTest.php +++ b/tests/Unit/Models/SubscriptionTest.php @@ -2,7 +2,7 @@ namespace Tests\Unit\Models; -use App\Entities\Partners\Customer; +use App\Entities\Partners\Vendor; use App\Entities\Projects\Project; use App\Entities\Subscriptions\Subscription; use Tests\TestCase as TestCase; @@ -27,6 +27,9 @@ class SubscriptionTest extends TestCase public function it_has_vendor_relation() { $subscription = factory(Subscription::class)->create(); - $this->assertTrue($subscription->vendor instanceof Customer); + $this->assertTrue( + $subscription->vendor instanceof Vendor, + 'A subscription must belongs to a App\Entities\Partners\Vendor model as it\'s vendor.' + ); } }