Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix display relationship without a ofContact property #2598

Merged
merged 5 commits into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update tests
  • Loading branch information
asbiin committed Apr 14, 2019
commit 9b1ae2e85bd870427551329ca51c279468107c55
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Enhancements:

Fixes:

* Fix display relationship without a ofContact property
* Fix register request validate
* Fix relationship create
* Fix display relationship without a ofContact property

RELEASED VERSIONS:

Expand Down
77 changes: 77 additions & 0 deletions tests/Feature/RelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ class RelationshipTest extends FeatureTestCase
{
use DatabaseTransactions, WithFaker;

public function test_create_a_relationship()
{
$user = $this->signIn();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);

$response = $this->get('/people/'.$contact->hashID().'/relationships/create');

$response->assertStatus(200);

$response->assertSee('This person is...');
}

public function test_user_can_add_a_relationship()
{
$user = $this->signIn();
Expand All @@ -35,6 +49,8 @@ public function test_user_can_add_a_relationship()

$response = $this->post('/people/'.$contact->hashID().'/relationships', $params);

$response->assertStatus(302);

$this->assertDatabaseHas('relationships', [
'account_id' => $user->account_id,
'contact_is' => $contact->id,
Expand Down Expand Up @@ -68,6 +84,8 @@ public function test_user_can_add_a_relationship_new_user_birthdate_unknown()

$response = $this->post('/people/'.$contact->hashID().'/relationships', $params);

$response->assertStatus(302);

$this->assertDatabaseHas('contacts', [
'account_id' => $user->account_id,
'first_name' => 'Arnold',
Expand Down Expand Up @@ -107,6 +125,8 @@ public function test_user_can_add_a_relationship_new_user_partial()

$response = $this->post('/people/'.$contact->hashID().'/relationships', $params);

$response->assertStatus(302);

$this->assertDatabaseHas('contacts', [
'account_id' => $user->account_id,
'first_name' => 'Arnold',
Expand Down Expand Up @@ -147,6 +167,8 @@ public function test_user_can_add_a_relationship_new_user_birthdate_known()

$response = $this->post('/people/'.$contact->hashID().'/relationships', $params);

$response->assertStatus(302);

$this->assertDatabaseHas('contacts', [
'account_id' => $user->account_id,
'first_name' => 'Arnold',
Expand All @@ -167,6 +189,30 @@ public function test_user_can_add_a_relationship_new_user_birthdate_known()
]);
}

public function test_edit_a_relationship()
{
$user = $this->signIn();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$partner = factory(Contact::class)->create([
'account_id' => $user->account_id,
'first_name' => 'Homer',
'last_name' => 'Simpson',
]);
$relationship = factory(Relationship::class)->create([
'account_id' => $user->account_id,
'contact_is' => $contact->id,
'of_contact' => $partner->id,
]);

$response = $this->get('/people/'.$contact->hashID().'/relationships/'.$relationship->id.'/edit');

$response->assertStatus(200);

$response->assertSee('Homer Simpson is...');
}

public function test_user_can_update_a_relationship()
{
$user = $this->signIn();
Expand All @@ -192,6 +238,8 @@ public function test_user_can_update_a_relationship()

$response = $this->put('/people/'.$contact->hashID().'/relationships/'.$relationship->id, $params);

$response->assertStatus(302);

$this->assertDatabaseHas('relationships', [
'id' => $relationship->id,
'account_id' => $user->account_id,
Expand Down Expand Up @@ -232,6 +280,8 @@ public function test_user_can_update_a_relationship_partial_user()

$response = $this->put('/people/'.$contact->hashID().'/relationships/'.$relationship->id, $params);

$response->assertStatus(302);

$this->assertDatabaseHas('contacts', [
'account_id' => $user->account_id,
'first_name' => 'Arnold',
Expand All @@ -252,4 +302,31 @@ public function test_user_can_update_a_relationship_partial_user()
'relationship_type_id' => $relationshipType->id,
]);
}

public function test_user_can_destroy_a_relationship()
{
$user = $this->signIn();
$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$partner = factory(Contact::class)->create([
'account_id' => $user->account_id,
]);
$relationship = factory(Relationship::class)->create([
'account_id' => $user->account_id,
'contact_is' => $contact->id,
'of_contact' => $partner->id,
]);

$response = $this->delete('/people/'.$contact->hashID().'/relationships/'.$relationship->id);

$response->assertStatus(302);

$this->assertDatabaseMissing('relationships', [
'id' => $relationship->id,
'account_id' => $user->account_id,
'contact_is' => $contact->id,
'of_contact' => $partner->id,
]);
}
}