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 1eb18451
authored
Jun 02, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20207 Доработка изменения РК
1 parent
61172b1d
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
243 additions
and
108 deletions
app/Console/Commands/AdGroupsLoadUpdated.php
app/Console/Commands/CampaignsLoadUpdated.php
app/Models/Campaigns.php
app/Service/Requests/APIRequest.php
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/GetAdGroups.php
app/Service/Requests/Direct/ResumeCampaigns.php
app/Service/Requests/Direct/UpdateCampaigns.php
tests/Unit/ProcessCallSliceTest.php
app/Console/Commands/AdGroupsLoadUpdated.php
View file @
1eb1845
...
...
@@ -43,11 +43,7 @@ class AdGroupsLoadUpdated extends Command
public
function
handle
()
{
$token
=
Tokens
::
has
(
'campaignsAdGroupsForUpdatedSelf'
)
->
with
([
'campaignsAdGroupsForUpdatedSelf'
=>
function
(
HasManyThrough
$query
)
{
return
$query
->
limit
(
10
);
},
])
->
with
(
'campaignsAdGroupsForUpdatedSelf'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
first
();
...
...
app/Console/Commands/CampaignsLoadUpdated.php
View file @
1eb1845
...
...
@@ -47,7 +47,7 @@ class CampaignsLoadUpdated extends Command
*/
public
function
handle
()
{
$campaigns
=
Campaigns
::
forUpdatedSelf
()
->
limit
(
10
)
->
get
();
$campaigns
=
Campaigns
::
forUpdatedSelf
()
->
get
();
if
(
!
$campaigns
->
count
())
{
return
;
}
...
...
@@ -65,11 +65,7 @@ class CampaignsLoadUpdated extends Command
]);
$tokens
=
Tokens
::
has
(
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf'
)
->
with
([
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf'
=>
function
(
HasManyThrough
$query
)
{
return
$query
->
limit
(
10
);
},
])
->
with
(
'dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
...
...
app/Models/Campaigns.php
View file @
1eb1845
...
...
@@ -211,6 +211,82 @@ class Campaigns extends Model
});
}
public
function
getBiddingStrategyAttribute
(
$bidding_strategy
)
{
$bidding_strategy
=
json_decode
(
$bidding_strategy
,
true
);
if
(
!
$bidding_strategy
)
return
$bidding_strategy
;
if
(
!
isset
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
])
&&
$bidding_strategy
[
'Network'
][
'BiddingStrategyType'
]
===
'NETWORK_DEFAULT'
)
{
$bidding_strategy
[
'Network'
][
'NetworkDefault'
]
=
(
object
)[];
}
elseif
(
isset
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
][
'LimitPercent'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'WbMaximumClicks'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'WbMaximumClicks'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'WbMaximumClicks'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'WbMaximumConversionRate'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'AverageCpc'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'AverageCpc'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'AverageCpc'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'WeeklyClickPackage'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'WeeklyClickPackage'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'WeeklyClickPackage'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'AverageRoi'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'AverageRoi'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'PayForConversion'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'PayForConversion'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'PayForConversion'
][
'WeeklySpendLimit'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'WbMaximumClicks'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'WbMaximumClicks'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'WbMaximumClicks'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'WbMaximumConversionRate'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageCpc'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageCpc'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageCpc'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'WeeklySpendLimit'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'WeeklySpendLimit'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'Profitability'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'Profitability'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'PayForConversion'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'PayForConversion'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'PayForConversion'
][
'WeeklySpendLimit'
]);
}
return
$bidding_strategy
;
}
public
function
groups
()
{
return
$this
->
hasMany
(
AdGroup
::
class
,
'campaign_id'
);
...
...
app/Service/Requests/APIRequest.php
View file @
1eb1845
...
...
@@ -81,32 +81,22 @@ class APIRequest implements \App\Service\Contract\APIRequest
{
$params
=
$this
->
getParams
();
if
(
is_array
(
$key
))
{
$params_i
=
$params
;
for
(
$i
=
0
;
$i
<
count
(
$key
);
$i
++
)
{
$params_i
=
$params_i
[
$key
[
$i
]];
}
$params_by_key
=
$params_i
;
}
else
{
$params_by_key
=
$params
[
$key
];
}
$replication
=
clone
$this
;
$objects
=
$this
->
sliceArray
(
$params_by_key
,
0
,
$maxObjects
);
if
(
is_array
(
$key
))
{
$params
=
$this
->
changeInArray
(
$params
,
$
objects
,
$key
);
$params
=
$this
->
changeInArray
(
$params
,
$
key
,
$maxObjects
);
}
else
{
$params_by_key
=
$params
[
$key
];
$params
[
$key
]
=
$this
->
sliceArray
(
$params_by_key
,
$maxObjects
);
}
$replication
->
setParams
(
$params
);
if
(
is_array
(
$key
))
{
$params
=
$this
->
changeInArray
(
$
params
,
$objects
,
$key
);
$params
=
$this
->
changeInArray
(
$
this
->
getParams
(),
$key
,
0
,
$maxObjects
);
}
else
{
$params
[
$key
]
=
$this
->
sliceArray
(
$params_by_key
,
$maxObjects
);
$params_by_key
=
$params
[
$key
];
$params
[
$key
]
=
$this
->
sliceArray
(
$params_by_key
,
0
,
$maxObjects
);
}
$this
->
setParams
(
$params
);
...
...
@@ -119,12 +109,13 @@ class APIRequest implements \App\Service\Contract\APIRequest
return
array_values
(
array_slice
(
$params
,
$offset
,
$length
));
}
private
function
changeInArray
(
$params
,
$
objects
,
$key
)
private
function
changeInArray
(
$params
,
$
key
,
$offset
,
$maxObjects
=
null
)
{
$params_i
=
&
$params
;
for
(
$i
=
0
;
$i
<
count
(
$key
);
$i
++
)
{
$params_i
=
&
$params_i
[
$key
[
$i
]];
}
$objects
=
$this
->
sliceArray
(
$params_i
,
$offset
,
$maxObjects
);
$params_i
=
$objects
;
return
$params
;
}
...
...
app/Service/Requests/Direct/AddCampaigns.php
View file @
1eb1845
...
...
@@ -30,7 +30,8 @@ class AddCampaigns extends DirectRequest
dispatch
(
$process
)
->
onQueue
(
'limits'
);
}
public
function
getObjectsCount
(){
public
function
getObjectsCount
()
{
$params
=
$this
->
getParams
();
$cnt
=
count
(
$params
[
'Campaigns'
]);
...
...
@@ -41,10 +42,8 @@ class AddCampaigns extends DirectRequest
{
$splinter
=
$this
->
sliceByKey
(
$maxObjects
,
'Campaigns'
);
$dictionaryCampaigns_splinter
=
$this
->
dictionaryCampaigns
->
slice
(
$maxObjects
)
->
values
();
$splinter
->
putParams
([
'dictionaryCampaigns'
=>
$
dictionaryCampaigns_splinter
,
'dictionaryCampaigns'
=>
$
this
->
dictionaryCampaigns
->
slice
(
$maxObjects
)
->
values
()
,
'variables'
=>
$this
->
variables
,
]);
...
...
@@ -103,83 +102,11 @@ class AddCampaigns extends DirectRequest
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$dictionaryCampaign
);
$bidding_strategy
=
$dictionaryCampaign
->
campaign
->
bidding_strategy
;
if
(
$bidding_strategy
)
{
if
(
!
isset
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
])
&&
$bidding_strategy
[
'Network'
][
'BiddingStrategyType'
]
===
'NETWORK_DEFAULT'
)
{
$bidding_strategy
[
'Network'
][
'NetworkDefault'
]
=
(
object
)[];
}
elseif
(
isset
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
][
'LimitPercent'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'NetworkDefault'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'WbMaximumClicks'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'WbMaximumClicks'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'WbMaximumClicks'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'WbMaximumConversionRate'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'AverageCpc'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'AverageCpc'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'AverageCpc'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'WeeklyClickPackage'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'WeeklyClickPackage'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'WeeklyClickPackage'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'AverageRoi'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'AverageRoi'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Network'
][
'PayForConversion'
])
&&
is_null
(
$bidding_strategy
[
'Network'
][
'PayForConversion'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Network'
][
'PayForConversion'
][
'WeeklySpendLimit'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'WbMaximumClicks'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'WbMaximumClicks'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'WbMaximumClicks'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'WbMaximumConversionRate'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'WbMaximumConversionRate'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageCpc'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageCpc'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageCpc'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageCpa'
][
'WeeklySpendLimit'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'BidCeiling'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'BidCeiling'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'WeeklySpendLimit'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'Profitability'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'AverageRoi'
][
'Profitability'
]);
}
if
(
isset
(
$bidding_strategy
[
'Search'
][
'PayForConversion'
])
&&
is_null
(
$bidding_strategy
[
'Search'
][
'PayForConversion'
][
'WeeklySpendLimit'
]))
{
unset
(
$bidding_strategy
[
'Search'
][
'PayForConversion'
][
'WeeklySpendLimit'
]);
}
}
$data
=
[
'Name'
=>
StrReplaceByVariables
::
getInstance
(
$dictionaryCampaign
->
name
,
$list
)
->
get
(),
'StartDate'
=>
Carbon
::
now
()
->
format
(
'Y-m-d'
),
'TextCampaign'
=>
[
'BiddingStrategy'
=>
$bidding_strategy
,
'BiddingStrategy'
=>
$
dictionaryCampaign
->
campaign
->
bidding_strategy
,
],
];
...
...
app/Service/Requests/Direct/GetAdGroups.php
View file @
1eb1845
...
...
@@ -28,6 +28,11 @@ class GetAdGroups extends DirectRequest
$external_ids
=
[];
if
(
!
isset
(
$response
[
'result'
][
'AdGroups'
]))
{
Log
::
debug
(
$response
);
return
;
}
foreach
(
$response
[
'result'
][
'AdGroups'
]
as
$ad_group
)
{
if
(
isset
(
$external_ids
[
$ad_group
[
'CampaignId'
]]))
{
continue
;
...
...
app/Service/Requests/Direct/ResumeCampaigns.php
View file @
1eb1845
...
...
@@ -20,7 +20,8 @@ class ResumeCampaigns extends DirectRequest
dispatch
(
$process
)
->
onQueue
(
'limits'
);
}
public
function
getObjectsCount
(){
public
function
getObjectsCount
()
{
$params
=
$this
->
getParams
();
$cnt
=
count
(
$params
[
'SelectionCriteria'
][
'Ids'
]);
...
...
app/Service/Requests/Direct/UpdateCampaigns.php
View file @
1eb1845
...
...
@@ -74,11 +74,8 @@ class UpdateCampaigns extends DirectRequest
$data
=
[
'Id'
=>
$dictionaryCampaign
->
external_id
,
'Name'
=>
StrReplaceByVariables
::
getInstance
(
$dictionaryCampaign
->
name
,
$list
)
->
get
(),
'StartDate'
=>
Carbon
::
now
()
->
format
(
'Y-m-d'
),
'TextCampaign'
=>
[
'BiddingStrategy'
=>
$dictionaryCampaign
->
campaign
->
bidding_strategy
,
'RelevantKeywords'
=>
$dictionaryCampaign
->
campaign
->
relevant_keywords
,
'AttributionModel'
=>
$dictionaryCampaign
->
campaign
->
attribution_model
,
],
];
...
...
@@ -112,6 +109,14 @@ class UpdateCampaigns extends DirectRequest
];
}
if
(
$dictionaryCampaign
->
campaign
->
relevant_keywords
)
{
$data
[
'TextCampaign'
][
'RelevantKeywords'
]
=
$dictionaryCampaign
->
campaign
->
relevant_keywords
;
}
if
(
$dictionaryCampaign
->
campaign
->
attribution_model
)
{
$data
[
'TextCampaign'
][
'AttributionModel'
]
=
$dictionaryCampaign
->
campaign
->
attribution_model
;
}
if
(
$dictionaryCampaign
->
campaign
->
settings
&&
count
(
$dictionaryCampaign
->
campaign
->
settings
))
{
$settingsAllow
=
Campaigns
::
getSettingOptionsAllow
();
...
...
tests/Unit/ProcessCallSliceTest.php
0 → 100644
View file @
1eb1845
<?php
namespace
Tests\Unit
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Account
;
use
App\Models\Campaigns
;
use
App\Models\Dictionary
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Tokens
;
use
App\Models\User
;
use
App\Models\Variable
;
use
App\Service\Contract\API
;
use
App\Service\Limits
;
use
App\Service\Requests\APIRequest
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
class
ProcessCallSliceTest
extends
TestCase
{
use
RefreshDatabase
;
private
$request
;
private
$request_resume
;
private
$params
;
private
$user
;
private
$token
;
private
$token_main
;
private
$campaign
;
private
$dictionaries
;
private
$dictionaries_count
=
14
;
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
([
'limit'
=>
20
,
'created_by'
=>
$this
->
user
->
getKey
()
]);
$this
->
token_main
=
factory
(
Tokens
::
class
)
->
create
([
'type'
=>
Tokens
::
MAIN
,
]);
$this
->
campaign
=
factory
(
Campaigns
::
class
)
->
create
([
'manage'
=>
true
,
'token'
=>
$this
->
token_main
->
getKey
(),
]);
$this
->
dictionaries
=
factory
(
Dictionary
::
class
,
$this
->
dictionaries_count
)
->
create
([
'token_id'
=>
$this
->
token
->
getKey
(),
'type'
=>
Dictionary
::
CITY
,
]);
$this
->
request
=
APIRequest
::
getInstance
(
API
::
YANDEX
)
->
setToken
(
$this
->
token
)
->
getRequest
(
'campaigns'
,
'add'
);
$this
->
campaign
->
dictionaries
()
->
syncWithoutDetaching
(
$this
->
dictionaries
->
keyBy
(
Campaigns
::
getModel
()
->
getKeyName
())
->
transform
(
function
(
Dictionary
$dictionary
)
{
return
DictionaryCampaign
::
copyPropertyInCampaign
(
$this
->
campaign
);
})
->
all
()
);
$this
->
assertEquals
(
$this
->
dictionaries_count
,
$this
->
campaign
->
dictionaries
()
->
count
());
$this
->
assertEquals
(
$this
->
dictionaries_count
,
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
->
count
());
$this
->
params
=
[
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
,
'variables'
=>
Variable
::
all
(),
];
$this
->
request_resume
=
APIRequest
::
getInstance
(
API
::
YANDEX
)
->
setToken
(
$this
->
token
)
->
getRequest
(
'Campaigns'
,
'resume'
);
}
public
function
testCallApi
()
{
Queue
::
fake
();
Queue
::
assertNothingPushed
();
$this
->
request
->
call
(
$this
->
params
);
$this
->
request_resume
->
call
([
'ids'
=>
range
(
0
,
$this
->
dictionaries_count
-
1
)
]);
Queue
::
assertPushed
(
ProcessCallLimitedAPI
::
class
);
$limits
=
Limits
::
getInstance
(
$this
->
request
->
getToken
());
$maxObjects
=
$limits
->
countObjectsLimit
(
$this
->
request
);
$this
->
assertEquals
(
true
,
$maxObjects
and
$maxObjects
!==
$limits
::
NAN
&&
$this
->
request
->
getObjectsCount
()
>
$maxObjects
);
$requestR
=
$this
->
request
->
slice
(
$maxObjects
);
$this
->
assertEquals
(
true
,
!!
$requestR
);
$this
->
assertEquals
(
2
,
$this
->
request
->
getObjectsCount
());
$this
->
assertEquals
(
$this
->
dictionaries_count
-
2
,
count
(
$requestR
->
getParams
()[
'Campaigns'
]));
$limits
=
Limits
::
getInstance
(
$this
->
request_resume
->
getToken
());
$maxObjects
=
$limits
->
countObjectsLimit
(
$this
->
request_resume
);
$this
->
assertEquals
(
true
,
$maxObjects
and
$maxObjects
!==
$limits
::
NAN
&&
$this
->
request_resume
->
getObjectsCount
()
>
$maxObjects
);
$requestR
=
$this
->
request_resume
->
slice
(
$maxObjects
);
$this
->
assertEquals
(
true
,
!!
$requestR
);
$this
->
assertEquals
(
2
,
$this
->
request_resume
->
getObjectsCount
());
$this
->
assertEquals
(
$this
->
dictionaries_count
-
2
,
count
(
$requestR
->
getParams
()[
'SelectionCriteria'
][
'Ids'
]));
}
public
function
testHandleApi
()
{
}
}
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