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 efdf1d86
authored
May 19, 2021
by
Евгений
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Улучшение #19461
Страница настройки целевых аккаунтов.
1 parent
1712c1bf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
0 deletions
database/factories/CampaingFactory.php
database/factories/DictionaryFactory.php
tests/Feature/CityTest.php
database/factories/CampaingFactory.php
View file @
efdf1d8
...
...
@@ -6,5 +6,6 @@ use Faker\Generator as Faker;
$factory
->
define
(
App\Models\Campaigns
::
class
,
function
(
Faker
$faker
)
{
return
[
'name'
=>
$faker
->
name
,
'external_id'
=>
$faker
->
randomNumber
()
];
});
database/factories/DictionaryFactory.php
View file @
efdf1d8
...
...
@@ -6,5 +6,6 @@ use Faker\Generator as Faker;
$factory
->
define
(
App\Models\Dictionary
::
class
,
function
(
Faker
$faker
)
{
return
[
'name'
=>
$faker
->
name
,
'region_id'
=>
$faker
->
unique
()
->
randomNumber
()
];
});
tests/Feature/CityTest.php
0 → 100644
View file @
efdf1d8
<?php
namespace
Tests\Feature
;
use
App\Models\Account
;
use
App\Models\Campaigns
;
use
App\Models\Dictionary
;
use
App\Models\Tokens
;
use
App\Models\User
;
use
App\Models\Organization
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Tests\TestCase
;
class
CityTest
extends
TestCase
{
use
RefreshDatabase
;
private
$token
;
private
$token_main
;
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
,
]);
$this
->
token
=
factory
(
Tokens
::
class
)
->
create
([
'created_by'
=>
$this
->
user
->
getKey
()
]);
$this
->
token_main
=
factory
(
Tokens
::
class
)
->
create
([
'type'
=>
Tokens
::
MAIN
,
]);
factory
(
Campaigns
::
class
,
2
)
->
create
([
'manage'
=>
true
,
'token'
=>
$this
->
token_main
->
getKey
(),
]);
factory
(
Campaigns
::
class
,
2
)
->
create
([
'manage'
=>
false
,
'token'
=>
$this
->
token_main
->
getKey
(),
]);
factory
(
Dictionary
::
class
,
10
)
->
create
([
'type'
=>
Dictionary
::
CITY
,
]);
}
public
function
test_add_city
(){
$ids
=
Dictionary
::
all
()
->
pluck
(
'id'
);
$this
->
actingAs
(
$this
->
user
)
->
post
(
route
(
'token.city.store'
,
[
'token'
=>
$this
->
token
->
id
,
'city'
=>
$ids
[
0
]
]))
->
assertStatus
(
302
);
$this
->
token
->
load
(
'cities.campaigns'
);
$this
->
assertEquals
(
$this
->
token
->
cities
->
count
(),
1
);
foreach
(
$this
->
token
->
cities
as
$city
){
$this
->
assertEquals
(
$city
->
campaigns
->
count
(),
2
);
}
$this
->
actingAs
(
$this
->
user
)
->
post
(
route
(
'token.city.store'
,
[
'token'
=>
$this
->
token
->
id
,
'city'
=>
$ids
[
1
]
]))
->
assertStatus
(
302
);
$this
->
token
->
load
(
'cities.campaigns'
);
$this
->
assertEquals
(
$this
->
token
->
cities
->
count
(),
2
);
foreach
(
$this
->
token
->
cities
as
$city
){
$this
->
assertEquals
(
$city
->
campaigns
->
count
(),
2
);
}
$this
->
actingAs
(
$this
->
user
)
->
post
(
route
(
'token.city.store'
,
[
'token'
=>
$this
->
token
->
id
,
'city'
=>
$ids
[
2
]
]))
->
assertStatus
(
302
);
$this
->
token
->
load
(
'cities.campaigns'
);
$this
->
assertEquals
(
$this
->
token
->
cities
->
count
(),
3
);
foreach
(
$this
->
token
->
cities
as
$city
){
$this
->
assertEquals
(
$city
->
campaigns
->
count
(),
2
);
}
}
}
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