[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/tests/phpunit/testcases/tests_routes/ -> test_route_api.php (source)

   1  <?php
   2  
   3  class GP_Test_Projects_API extends GP_UnitTestCase_Route {
   4    var $route_class = 'GP_Route_Project';
   5  
   6    function setUp() {
   7      parent::setUp();
   8      $this->set = $this->factory->translation_set->create_with_project_and_locale();
   9      $this->route->api = true;
  10    }
  11  
  12    function test_api_projects_list_count() {
  13      $this->route->index();
  14      $response = $this->api_response();
  15  
  16      $this->assertEquals( count( GP::$project->all() ), count( $response ) );
  17    }
  18  
  19    function test_api_projects_list_contains_expected_project() {
  20      $this->route->index();
  21      $response = $this->api_response();
  22      $first_project = reset( $response );
  23  
  24      $this->assertEquals( $this->set->project->id, $first_project->id );
  25      $this->assertEquals( $this->set->project->name, $first_project->name );
  26    }
  27  
  28    function test_api_project_has_translation_sets() {
  29      $this->route->single($this->set->project->path);
  30      $response = $this->api_response();
  31  
  32      $this->assertObjectHasAttribute( 'translation_sets', $response );
  33      $this->assertFalse( empty( $response->translation_sets ) );
  34    }
  35  
  36    function test_api_project_translation_set_exposes_keys_with_counts() {
  37      $this->route->single($this->set->project->path);
  38      $response = $this->api_response();
  39  
  40      $first_set = reset( $response->translation_sets );
  41  
  42      $this->assertObjectHasAttribute( 'current_count', $first_set );
  43      $this->assertObjectHasAttribute( 'untranslated_count', $first_set );
  44      $this->assertObjectHasAttribute( 'waiting_count', $first_set );
  45    }
  46  }


Generated: Tue Nov 12 01:01:58 2019 Cross-referenced by PHPXref 0.7.1