forked from GlotPress/GlotPress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_route_api.php
46 lines (35 loc) · 1.48 KB
/
test_route_api.php
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
<?php
class GP_Test_Projects_API extends GP_UnitTestCase_Route {
var $route_class = 'GP_Route_Project';
function setUp(): void {
parent::setUp();
$this->set = $this->factory->translation_set->create_with_project_and_locale();
$this->route->api = true;
}
function test_api_projects_list_count() {
$this->route->index();
$response = $this->api_response();
$this->assertEquals( count( GP::$project->all() ), count( $response ) );
}
function test_api_projects_list_contains_expected_project() {
$this->route->index();
$response = $this->api_response();
$first_project = reset( $response );
$this->assertEquals( $this->set->project->id, $first_project->id );
$this->assertEquals( $this->set->project->name, $first_project->name );
}
function test_api_project_has_translation_sets() {
$this->route->single($this->set->project->path);
$response = $this->api_response();
$this->assertObjectHasAttribute( 'translation_sets', $response );
$this->assertFalse( empty( $response->translation_sets ) );
}
function test_api_project_translation_set_exposes_keys_with_counts() {
$this->route->single($this->set->project->path);
$response = $this->api_response();
$first_set = reset( $response->translation_sets );
$this->assertObjectHasAttribute( 'current_count', $first_set );
$this->assertObjectHasAttribute( 'untranslated_count', $first_set );
$this->assertObjectHasAttribute( 'waiting_count', $first_set );
}
}