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 affa6a78
authored
Jul 06, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.veeble.ru/pismenov/yourroomads
2 parents
9029a151
ec648ed6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
tests/Unit/AddAdGroupTest.php
tests/Unit/AddAdGroupTest.php
View file @
affa6a7
...
@@ -7,11 +7,13 @@ use App\Models\Account;
...
@@ -7,11 +7,13 @@ use App\Models\Account;
use
App\Models\AdGroup
;
use
App\Models\AdGroup
;
use
App\Models\Campaigns
;
use
App\Models\Campaigns
;
use
App\Models\Dictionary
;
use
App\Models\Dictionary
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Models\User
;
use
App\Models\User
;
use
App\Models\Variable
;
use
App\Models\Variable
;
use
App\Service\Contract\API
;
use
App\Service\Contract\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Queue
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
use
Tests\TestCase
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
...
@@ -56,7 +58,7 @@ class AddAdGroupTest extends TestCase
...
@@ -56,7 +58,7 @@ class AddAdGroupTest extends TestCase
'token'
=>
$this
->
token_main
->
getKey
(),
'token'
=>
$this
->
token_main
->
getKey
(),
]);
]);
$this
->
campaign
=
factory
(
AdGroup
::
class
)
->
create
([
$this
->
adGroups
=
factory
(
AdGroup
::
class
)
->
create
([
'external_id'
=>
1
,
'external_id'
=>
1
,
'campaign_id'
=>
$this
->
campaign
->
getKey
(),
'campaign_id'
=>
$this
->
campaign
->
getKey
(),
'campaign_external_id'
=>
$this
->
campaign
->
external_id
,
'campaign_external_id'
=>
$this
->
campaign
->
external_id
,
...
@@ -69,7 +71,8 @@ class AddAdGroupTest extends TestCase
...
@@ -69,7 +71,8 @@ class AddAdGroupTest extends TestCase
$this
->
request
=
APIRequest
::
getInstance
(
API
::
YANDEX
)
$this
->
request
=
APIRequest
::
getInstance
(
API
::
YANDEX
)
->
setToken
(
$this
->
token
)
->
setToken
(
$this
->
token
)
->
getRequest
(
'Campaigns'
,
'add'
);
->
getRequest
(
'AdGroups'
,
'add'
);
$this
->
actingAs
(
$this
->
user
)
$this
->
actingAs
(
$this
->
user
)
->
post
(
route
(
'token.city.store'
,
[
->
post
(
route
(
'token.city.store'
,
[
...
@@ -124,4 +127,37 @@ class AddAdGroupTest extends TestCase
...
@@ -124,4 +127,37 @@ class AddAdGroupTest extends TestCase
$this
->
assertNotNull
(
1
,
$this
->
dictionary
->
campaigns
->
first
()
->
pivot
->
external_upload_at
);
$this
->
assertNotNull
(
1
,
$this
->
dictionary
->
campaigns
->
first
()
->
pivot
->
external_upload_at
);
}
}
public
function
testSlice
(){
//создаем пустые группы
for
(
$i
=
2
;
$i
<
1010
;
$i
++
){
$adGroup
=
factory
(
AdGroup
::
class
)
->
create
([
'external_id'
=>
$i
,
'campaign_id'
=>
$this
->
campaign
->
getKey
(),
'campaign_external_id'
=>
$this
->
campaign
->
external_id
,
]);
}
//грузим группы которых по какой то причне нет в целевых.
DB
::
insert
(
"
INSERT INTO goal_ad_groups(ad_group_id, dictionary_campaign_external_id, dictionary_campaign_id, name, negative_keywords, created_at, updated_at)
SELECT a.id, dc.external_id, dc.id, a.name, a.negative_keywords, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
FROM ad_groups a
INNER JOIN campaigns c on a.campaign_id = c.id
INNER JOIN dictionary_campaigns dc on c.id = dc.campaign_id
LEFT JOIN goal_ad_groups gag on a.id = gag.ad_group_id AND gag.dictionary_campaign_id=dc.id
WHERE gag.ad_group_id is null
"
);
Queue
::
fake
();
$goal
=
GoalAdGroup
::
all
();
$this
->
request
->
call
([
'goalAdGroups'
=>
$goal
,
]);
$this
->
assertCount
(
1009
,
$goal
);
$maxObjects
=
1000
;
if
(
$request
=
$this
->
request
->
slice
(
$maxObjects
))
{
$this
->
assertCount
(
1000
,
$this
->
request
->
getParams
()[
'AdGroups'
]);
$this
->
assertCount
(
9
,
$request
->
getParams
()[
'AdGroups'
]);
}
}
}
}
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