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);
 }
Ejemplo n.º 2
0
 function testFileWithMaliciousNote()
 {
     $file = test_file_path('xliff/file-with-notes-and-malicious-code.xliff');
     $content = file_get_contents($file);
     $xliff_obj = new Xliff_Parser();
     $xliff = $xliff_obj->Xliff2Array($content);
     $this->assertEquals("<script>alert('This is malicious code');</script>", $xliff['files'][3]['trans-units'][1]['notes'][0]['raw-content']);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 function testIgnoresReferenceFiles()
 {
     $this->params = array('project_name' => 'foo', 'target_lang' => 'it', 'source_lang' => 'en');
     $this->files[] = test_file_path('zip-with-reference-files.zip');
     $response = $this->makeRequest();
     $response = json_decode($response['body']);
     $this->assertEquals('Success', $response->message);
     $this->assertEquals('OK', $response->status);
     $this->assertNotNull($response->id_project);
     $this->assertNotNull($response->project_pass);
     $this->assertNotNull($response->analyze_url);
     $filesDao = new Files_FileDao(Database::obtain());
     $files = $filesDao->getByProjectId($response->id_project);
     $this->assertEquals(1, count($files));
     $this->assertEquals('zip-with-reference-files.zip___SEP___amex-test.docx.xlf', $files[0]['filename']);
 }
Ejemplo n.º 5
0
function integrationCreateTestProject($options = array())
{
    $test = new CurlTest();
    if (key_exists('headers', $options)) {
        $test->headers = $options['headers'];
    }
    $test->path = '/api/new';
    $test->method = 'POST';
    $test->params = array('project_name' => 'foo', 'target_lang' => 'it', 'source_lang' => 'en');
    if (key_exists('files', $options)) {
        $test->files = $options['files'];
    } else {
        $test->files[] = test_file_path('xliff/amex-test.docx.xlf');
    }
    $response = $test->getResponse();
    return json_decode($response['body']);
}