Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5bf7c4be
authored
Apr 09, 2019
by
Linus Juhlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Contacts Feature test
1 parent
ce9913e2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
tests/Feature/ContactsTest.php
tests/Feature/ContactsTest.php
0 → 100644
View file @
5bf7c4b
<?php
namespace
Tests\Feature
;
use
App\User
;
use
App\Account
;
use
App\Contact
;
use
Tests\TestCase
;
use
Illuminate\Foundation\Testing\WithFaker
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
class
ContactsTest
extends
TestCase
{
use
RefreshDatabase
;
protected
function
setUp
()
:
void
{
parent
::
setUp
();
$account
=
Account
::
create
([
'name'
=>
'Acme Corporation'
]);
$this
->
user
=
factory
(
User
::
class
)
->
create
([
'account_id'
=>
$account
->
id
,
'first_name'
=>
'John'
,
'last_name'
=>
'Doe'
,
'email'
=>
'johndoe@example.com'
,
'owner'
=>
true
,
]);
}
public
function
test_can_view_contacts
()
{
$this
->
user
->
account
->
contacts
()
->
saveMany
(
factory
(
Contact
::
class
,
5
)
->
make
()
);
$this
->
actingAs
(
$this
->
user
)
->
get
(
'/contacts'
)
->
assertStatus
(
200
)
->
assertPropCount
(
'contacts.data'
,
5
)
->
assertPropValue
(
'contacts.data'
,
function
(
$contacts
)
{
$this
->
assertEquals
(
[
'id'
,
'name'
,
'phone'
,
'city'
,
'deleted_at'
,
'organization'
],
array_keys
(
$contacts
[
0
])
);
});
}
public
function
test_can_search_for_contacts
()
{
$this
->
user
->
account
->
contacts
()
->
saveMany
(
factory
(
contact
::
class
,
5
)
->
make
()
)
->
first
()
->
update
([
'first_name'
=>
'Greg'
,
'last_name'
=>
'Andersson'
]);
$this
->
actingAs
(
$this
->
user
)
->
get
(
'/contacts?search=Greg'
)
->
assertStatus
(
200
)
->
assertPropValue
(
'filters.search'
,
'Greg'
)
->
assertPropCount
(
'contacts.data'
,
1
)
->
assertPropValue
(
'contacts.data'
,
function
(
$contacts
)
{
$this
->
assertEquals
(
'Greg Andersson'
,
$contacts
[
0
][
'name'
]);
});
}
public
function
test_cannot_view_deleted_contacts
()
{
$this
->
user
->
account
->
contacts
()
->
saveMany
(
factory
(
contact
::
class
,
5
)
->
make
()
)
->
first
()
->
delete
();
$this
->
actingAs
(
$this
->
user
)
->
get
(
'/contacts'
)
->
assertStatus
(
200
)
->
assertPropCount
(
'contacts.data'
,
4
);
}
public
function
test_can_filter_to_view_deleted_contacts
()
{
$this
->
user
->
account
->
contacts
()
->
saveMany
(
factory
(
contact
::
class
,
5
)
->
make
()
)
->
first
()
->
delete
();
$this
->
actingAs
(
$this
->
user
)
->
get
(
'/contacts?trashed=with'
)
->
assertStatus
(
200
)
->
assertPropValue
(
'filters.trashed'
,
'with'
)
->
assertPropCount
(
'contacts.data'
,
5
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment