forked from monicahq/monica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchTest.php
120 lines (92 loc) · 4.16 KB
/
SearchTest.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class SearchTest extends TestCase
{
use DatabaseTransactions;
/** @test */
public function testSearchContactsReturnsCollection()
{
$contact = factory('App\Contact')->make();
$searchResults = $contact->search($contact->first_name, $contact->account_id);
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $searchResults);
}
/** @test */
public function testSearchContactsThroughFirstNameAndResultContainsContact()
{
$contact = factory('App\Contact')->create(['first_name' => 'FirstName']);
$searchResults = $contact->search($contact->first_name, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughMiddleNameAndResultContainsContact()
{
$contact = factory('App\Contact')->create(['middle_name' => 'MiddleName']);
$searchResults = $contact->search($contact->middle_name, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughLastNameAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['last_name' => 'LastName']);
$searchResults = $contact->search($contact->last_name, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughEmailAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['email' => 'email@email.com']);
$searchResults = $contact->search($contact->email, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughStreetAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['street' => 'Street']);
$searchResults = $contact->search($contact->street, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughPostalCodeAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['postal_code' => '33080']);
$searchResults = $contact->search($contact->postal_code, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughProvinceAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['province' => 'Province']);
$searchResults = $contact->search($contact->province, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughFoodPreferencesAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['food_preferencies' => 'Food Preference']);
$searchResults = $contact->search($contact->food_preferencies, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughJobAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['job' => 'Job']);
$searchResults = $contact->search($contact->job, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testSearchContactsThroughCompanyAndResultContainsContact()
{
$contact = factory(\App\Contact::class)->create(['company' => 'Company']);
$searchResults = $contact->search($contact->company, $contact->account_id);
$this->assertTrue($searchResults->contains($contact));
}
/** @test */
public function testFailingSearchContacts()
{
$contact = factory(\App\Contact::class)->create(['first_name' => 'TestShouldFail']);
$searchResults = $contact->search('TestWillSucceed', $contact->account_id);
$this->assertFalse($searchResults->contains($contact));
}
}