CostsTest.php
1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace Tests\Unit;
use App\Models\Account;
use App\Models\Tokens;
use App\Models\User;
use App\Service\Contract\API;
use App\Service\Costs;
use App\Service\Limits;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Date;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class CostsTest extends TestCase
{
use RefreshDatabase;
private $costs;
private $request;
protected function setUp(): void
{
parent::setUp();
$this->costs = new Costs();
$this->request = \App\Service\Requests\APIRequest::getInstance(API::YANDEX);
}
public function testGetCostCall(){
$this->request->setService('AdExtensions');
$this->request->setMethod('add');
$limit = $this->costs->getCostCall($this->request);
$this->assertEquals($limit, 5);
$this->request->setService('AdGroups');
$this->request->setMethod('update');
$limit = $this->costs->getCostCall($this->request);
$this->assertEquals($limit, 20);
$this->request->setService('Keywords');
$this->request->setMethod('get');
$limit = $this->costs->getCostCall($this->request);
$this->assertEquals($limit, 15);
}
public function testGetCostObject(){
$this->request->setService('Keywords');
$this->request->setMethod('get');
$this->request->setParams(['FieldNames' => []]);
$limit = $this->costs->getCostObject($this->request);
$this->assertEquals($limit, 1/2000);
$this->request->setService('Keywords');
$this->request->setMethod('get');
$this->request->setParams(['FieldNames' => ['Productivity']]);
$limit = $this->costs->getCostObject($this->request);
$this->assertEquals($limit, 3/2000);
$this->request->setService('SmartAdTargets');
$this->request->setMethod('get');
$limit = $this->costs->getCostObject($this->request);
$this->assertEquals($limit, 1);
}
}