Adjust client factories to allow contacts to be created by default

This commit is contained in:
David Bomba 2020-07-28 18:28:29 +10:00
parent 872ce3a3bc
commit 46bb38a20c
4 changed files with 6 additions and 5 deletions

View File

@ -33,8 +33,8 @@ class ClientFactory
$client->client_hash = Str::random(40);
$client->settings = ClientSettings::defaults();
$client_contact = ClientContactFactory::create($company_id, $user_id);
$client->contacts->add($client_contact);
// $client_contact = ClientContactFactory::create($company_id, $user_id);
// $client->contacts->add($client_contact);
return $client;
}

View File

@ -30,6 +30,7 @@ class ClientContactRepository extends BaseRepository
} else {
$contacts = collect();
}
info(print_r($client->contacts->toArray(),1));
$client->contacts->pluck('id')->diff($contacts->pluck('id'))->each(function ($contact) {
ClientContact::destroy($contact);

View File

@ -78,7 +78,7 @@ class ClientRepository extends BaseRepository
$data['name'] = $client->present()->name();
}
info("{$client->present()->name} has a balance of {$client->balance} with a paid to date of {$client->paid_to_date}");
//info("{$client->present()->name} has a balance of {$client->balance} with a paid to date of {$client->paid_to_date}");
if (array_key_exists('documents', $data)) {
$this->saveDocuments($data['documents'], $client);

View File

@ -126,8 +126,8 @@ class FactoryCreationTest extends TestCase
$cliz->save();
$this->assertNotNull($cliz->contacts);
$this->assertEquals(1, $cliz->contacts->count());
$this->assertInternalType("int", $cliz->contacts->first()->id);
$this->assertEquals(0, $cliz->contacts->count());
$this->assertInternalType("int", $cliz->id);
}
/**