-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestApiTest.php
More file actions
47 lines (35 loc) · 1.37 KB
/
RestApiTest.php
File metadata and controls
47 lines (35 loc) · 1.37 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
<?php
define('BASE_DIR', realpath(__DIR__));
require_once (BASE_DIR . '/../vendor/autoload.php');
class RestApiTest extends PHPUnit_Framework_TestCase
{
protected $site_base_url = "http://localhost";
protected $url;
protected $client;
protected function setUp()
{
$this->client = new GuzzleHttp\Client();
$this->url = $this->site_base_url . '/vagas/busca';
}
public function testGet_ValidInput_Texto()
{
$response = $this->client->request('GET', $this->url . '/texto/norte/asc', []);
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody(), true);
$this->assertArrayHasKey('title', $data["data"][0]);
$this->assertArrayHasKey('description', $data["data"][0]);
$this->assertArrayHasKey('cidade', $data["data"][0]);
$this->assertEquals(1200, $data["data"][0]['salario']);
}
public function testGet_ValidInput_Cidade()
{
$response = $this->client->request('GET', $this->url . '/cidade/joinville/asc', []);
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody(), true);
$this->assertArrayHasKey('title', $data["data"][0]);
$this->assertArrayHasKey('description', $data["data"][0]);
$this->assertArrayHasKey('cidade', $data["data"][0]);
$this->assertArrayHasKey('salario', $data["data"][0]);
$this->assertEquals("Joinville", $data["data"][0]['cidade'][0]);
}
}