function testReturnsNonCompletedProject()
 {
     $this->setValidProjectWithAllTranslatedSegments();
     // get project chunks
     $chunksDao = new Chunks_ChunkDao(Database::obtain());
     $chunks = $chunksDao->getByProjectID($this->test_data->project->id_project);
     $this->assertEquals(1, count($chunks));
     $chunk = $chunks[0];
     // split job in two
     $splitTest = new CurlTest();
     $params = array('action' => 'splitJob', 'exec' => 'apply', 'project_id' => $this->test_data->project->id_project, 'project_pass' => $this->test_data->project->project_pass, 'job_id' => $chunk->id, 'job_pass' => $chunk->password, 'num_split' => 2, 'split_values' => array('5', '1'));
     $splitTest->params = $params;
     $splitTest->method = 'POST';
     $response = $splitTest->getResponse();
     $chunks = $chunksDao->getByProjectID($this->test_data->project->id_project);
     $this->assertEquals(2, count($chunks));
     $first_chunk = $chunks[0];
     $second_chunk = $chunks[1];
     integrationSetChunkAsComplete(array('params' => array('id_job' => $first_chunk->id, 'password' => $first_chunk->password)));
     $test = new CurlTest();
     $test->path = '/api/v2/project-completion-status/' . $this->test_data->project->id_project;
     $test->method = 'GET';
     $test->headers = $this->test_data->headers;
     $response = $test->getResponse();
     $expected = array('project_status' => array('id' => $this->test_data->project->id_project, 'completed' => false, 'chunks' => array(array('id' => $second_chunk->id, 'password' => $second_chunk->password))));
     $this->assertEquals(json_encode($expected), $response['body']);
 }
Esempio n. 2
0
function integrationSetSegmentsTranslated($project_id)
{
    $chunksDao = new Chunks_ChunkDao(Database::obtain());
    $chunks = $chunksDao->getByProjectID($project_id);
    foreach ($chunks as $chunk) {
        $segments = $chunk->getSegments();
        foreach ($segments as $segment) {
            integrationSetTranslation(array('id_segment' => $segment->id, 'id_job' => $chunk->id, 'password' => $chunk->password, 'status' => 'translated'));
        }
    }
    return $chunks;
}
Esempio n. 3
0
 function testStatusOnTranslated()
 {
     $project = integrationCreateTestProject();
     $this->params = array('id_project' => $project->id_project, 'project_pass' => $project->project_pass);
     $chunksDao = new Chunks_ChunkDao(Database::obtain());
     $chunks = $chunksDao->getByProjectID($project->id_project);
     $this->assertTrue(count($chunks) == 1);
     foreach ($chunks as $chunk) {
         $segments = $chunk->getSegments();
         foreach ($segments as $segment) {
             integrationSetTranslation(array('id_segment' => $segment->id, 'id_job' => $chunk->id, 'password' => $chunk->password, 'status' => 'translated'));
         }
     }
     foreach ($chunks as $chunk) {
         $translations = $chunk->getTranslations();
         $this->assertEquals(3, count($translations));
         foreach ($translations as $translation) {
             $this->assertEquals('TRANSLATED', $translation->status);
         }
     }
     // iterate all segments and setTranslations
     $request = $this->makeRequest();
     $response = json_decode($request['body']);
 }
Esempio n. 4
0
 public function getChunks()
 {
     $dao = new Chunks_ChunkDao(Database::obtain());
     return $dao->getByProjectID($this->id);
 }