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 e08d6e9e
authored
Jun 01, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.veeble.ru/pismenov/yourroomads
2 parents
fa439cb4
1806c85b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
app/Service/Requests/Direct/GetCampaigns.php
tests/Unit/LimitsTest.php
app/Service/Requests/Direct/GetCampaigns.php
View file @
e08d6e9
...
@@ -86,4 +86,12 @@ class GetCampaigns extends DirectRequest
...
@@ -86,4 +86,12 @@ class GetCampaigns extends DirectRequest
}
}
$this
->
setParams
(
$params
);
$this
->
setParams
(
$params
);
}
}
function
getObjectsCount
(){
$params
=
$this
->
getParams
();
if
(
isset
(
$params
[
'SelectionCriteria'
][
'Ids'
])
&&
count
(
$params
[
'SelectionCriteria'
][
'Ids'
])
<
self
::
MAX_COUNT
){
return
count
(
$params
[
'SelectionCriteria'
][
'Ids'
]);
}
return
self
::
MAX_COUNT
;
}
}
}
tests/Unit/LimitsTest.php
View file @
e08d6e9
...
@@ -8,8 +8,10 @@ use App\Models\User;
...
@@ -8,8 +8,10 @@ use App\Models\User;
use
App\Service\Contract\API
;
use
App\Service\Contract\API
;
use
App\Service\HeaderLimits
;
use
App\Service\HeaderLimits
;
use
App\Service\Limits
;
use
App\Service\Limits
;
use
App\Service\Requests\DirectRequest
;
use
Illuminate\Database\Eloquent\ModelNotFoundException
;
use
Illuminate\Database\Eloquent\ModelNotFoundException
;
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
use
Tests\TestCase
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
use
Illuminate\Foundation\Testing\RefreshDatabase
;
...
@@ -119,7 +121,8 @@ class LimitsTest extends TestCase
...
@@ -119,7 +121,8 @@ class LimitsTest extends TestCase
public
function
testCountObjectsLimit
()
public
function
testCountObjectsLimit
()
{
{
$request
=
\App\Service\Requests\APIRequest
::
getInstance
(
API
::
YANDEX
);
$request
=
\App\Service\Requests\APIRequest
::
getInstance
(
API
::
YANDEX
)
->
setToken
(
$this
->
token
);
$request
->
setService
(
'AdExtensions'
);
$request
->
setService
(
'AdExtensions'
);
$request
->
setMethod
(
'add'
);
$request
->
setMethod
(
'add'
);
...
@@ -143,12 +146,32 @@ class LimitsTest extends TestCase
...
@@ -143,12 +146,32 @@ class LimitsTest extends TestCase
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$request
);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$request
);
$this
->
assertEquals
(
$objects
,
4000
);
$this
->
assertEquals
(
$objects
,
4000
);
$request
->
setService
(
'Campaigns'
);
$request
->
setMethod
(
'update'
);
Queue
::
fake
();
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'get'
);
$this
->
token
->
limit
=
191
;
$this
->
token
->
limit
=
191
;
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$request
);
$requestCmpgn
->
call
();
$this
->
assertEquals
(
$objects
,
60
);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
181
);
$this
->
token
->
limit
=
DirectRequest
::
MAX_COUNT
+
100
;
$requestCmpgn
->
call
();
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
DirectRequest
::
MAX_COUNT
);
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'update'
);
$this
->
token
->
limit
=
191
;
$requestCmpgn
->
call
([
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForExternalNeedUpdated
]);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
0
);
$requestCmpgn
->
setParams
([
'Campaigns'
=>
[
1
,
2
,
3
]
]);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
3
);
}
}
public
function
testDoRezervNoLimit
()
public
function
testDoRezervNoLimit
()
...
...
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