-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
ContactShowBlankViewHelperTest.php
66 lines (56 loc) · 1.7 KB
/
ContactShowBlankViewHelperTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Tests\Unit\Domains\Contact\ManageContact\Web\ViewHelpers;
use App\Domains\Contact\ManageContact\Web\ViewHelpers\ContactShowBlankViewHelper;
use App\Models\Contact;
use App\Models\Template;
use App\Models\User;
use App\Models\Vault;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use function env;
class ContactShowBlankViewHelperTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function it_gets_the_data_needed_for_the_view(): void
{
$vault = Vault::factory()->create();
$contact = Contact::factory()->create([
'vault_id' => $vault->id,
]);
$user = User::factory()->create();
$this->be($user);
$template = Template::factory()->create([
'account_id' => $vault->account_id,
]);
$array = ContactShowBlankViewHelper::data($contact);
$this->assertEquals(
3,
count($array)
);
$this->assertArrayHasKey('templates', $array);
$this->assertArrayHasKey('contact', $array);
$this->assertArrayHasKey('url', $array);
$this->assertEquals(
[
0 => [
'id' => $template->id,
'name' => $template->name,
],
],
$array['templates']->toArray()
);
$this->assertEquals(
[
'name' => $contact->name,
],
$array['contact']
);
$this->assertEquals(
[
'update' => env('APP_URL').'/vaults/'.$vault->id.'/contacts/'.$contact->id.'/template',
],
$array['url']
);
}
}