public function status() { // TODO: move this in to a json presenter class $uncompleted = Projects_ProjectDao::uncompletedChunksByProjectId($this->request->id_project); $is_completed = count($uncompleted) == 0; $id_project = $this->request->id_project; $response = array(); $response = array('id' => $id_project); try { if ($is_completed) { $jobs = $this->validator->getProject()->getJobs(); $response['jobs'] = array(); foreach ($jobs as $job) { $response['jobs'][] = array('id' => $job->id, 'password' => $job->password, 'download_url' => INIT::$HTTPHOST . "/?action=downloadFile" . "&id_job=" . $job->id . "&password=" . $job->password); } $response['completed'] = true; } else { $response['completed'] = false; $response['chunks'] = array(); foreach ($uncompleted as $chunk) { $response['chunks'][] = array('id' => $chunk->id, 'password' => $chunk->password); } } $this->response->json(array('project_status' => $response)); } catch (Exception $e) { Log::doLog($e->getMessage()); // TODO handle 500 response code here } }
function testNoteIsAssignedToAllMrkInTransUnit() { $options = array('files' => array(test_file_path('xliff/sdlxliff-with-mrk-and-note.xlf.sdlxliff'))); $body = integrationCreateTestProject($options); $this->assertNotNull($body->id_project); $this->assertNotNull($body->project_pass); // ensure one job is created $project = Projects_ProjectDao::findById($body->id_project); $jobs = $project->getJobs(); // expect one job is created $this->assertEquals(1, count($project->getJobs())); $chunks = $jobs[0]->getChunks(); $segments = $chunks[0]->getSegments(); // expect one segment per mrk $this->assertEquals(2, count($segments)); // expect the correct notes count $this->assertEquals(1, count($segments[0]->getNotes())); $this->assertEquals(1, count($segments[1]->getNotes())); // expect the same note text $notes_segment_one = $segments[0]->getNotes(); $notes_segment_two = $segments[1]->getNotes(); $this->assertEquals('Test note', $notes_segment_one[0]->note); $this->assertEquals('Test note', $notes_segment_two[0]->note); // expect the internal_id is saved appropriately $this->assertEquals($notes_segment_one[0]->internal_id, $notes_segment_two[0]->internal_id); }
function tests_missing_auth_sets_project_to_translated_user() { $this->params = array('project_name' => 'foo', 'target_lang' => 'it', 'source_lang' => 'en'); $this->files[] = test_file_path('xliff/amex-test.docx.xlf'); $response = $this->getResponse(); $body = json_decode($response['body']); $project = Projects_ProjectDao::findById($body->id_project); $this->assertEquals($project->id_customer, ProjectManager::TRANSLATED_USER); }
public function validate() { $this->project = Projects_ProjectDao::findById($this->id_project); if ($this->project == false) { return false; } if (!$this->validateFeatureEnabled()) { return false; } return $this->inProjectScope(); }
function testsCallOnValidProject() { $this->setValidProjectWithAllTranslatedSegments(); $project = Projects_ProjectDao::findById($this->test_data->project->id_project); foreach ($this->test_data->chunks as $chunk) { integrationSetChunkAsComplete(array('params' => array('id_job' => $chunk->id, 'password' => $chunk->password))); } $project = Projects_ProjectDao::findById($this->test_data->project->id_project); $expected_jobs = array(); foreach ($project->getJobs() as $job) { $expected_jobs[] = array('id' => $job->id, 'password' => $job->password, 'download_url' => "http://localhost/?action=downloadFile&id_job={$job->id}&password={$job->password}"); } $expected = array('project_status' => array('id' => $this->test_data->project->id_project, 'jobs' => $expected_jobs, 'completed' => true)); $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(); $this->assertEquals(json_encode($expected), $response['body']); }
public static function isProjectCompleted(Projects_ProjectStruct $proj) { $uncompletedChunksByProjectId = Projects_ProjectDao::uncompletedChunksByProjectId($proj->id); return $uncompletedChunksByProjectId == false; }
public function getProject() { return Projects_ProjectDao::findById($this->id_project); }