create([]); $relationship = factory(Relationship::class)->create([ 'account_id' => $account->id, ]); $this->assertTrue($relationship->account()->exists()); } public function test_it_belongs_to_a_contact() { $contact = factory(Contact::class)->create([]); $relationship = factory(Relationship::class)->create([ 'contact_is' => $contact->id, ]); $this->assertTrue($relationship->contactIs()->exists()); } public function test_it_belongs_to_another_contact() { $contact = factory(Contact::class)->create([]); $relationship = factory(Relationship::class)->create([ 'of_contact' => $contact->id, ]); $this->assertTrue($relationship->ofContact()->exists()); } public function test_it_belongs_to_a_relationship_type() { $account = factory(Account::class)->create([]); $relationshipType = factory(RelationshipType::class)->create([ 'account_id' => $account->id, ]); $relationship = factory(Relationship::class)->create([ 'account_id' => $account->id, 'relationship_type_id' => $relationshipType->id, ]); $this->assertTrue($relationship->relationshipType()->exists()); } public function test_it_belongs_to_a_contact_through_with_contact_field() { $contact = factory(Contact::class)->create([]); $relationship = factory(Relationship::class)->create([ 'of_contact' => $contact->id, ]); $this->assertTrue($relationship->ofContact()->exists()); } }