Example #1
0
 /**
  * Runs the test.
  */
 public function test()
 {
     $path = DIR_FILES . '/mail/logo.gif';
     $name = 'logo.gif';
     $mimeType = 'image/gif';
     $attachment = new FileAttachment($path, $name, $mimeType);
     $this->assertEquals(file_get_contents($path), $attachment->getContent());
     $this->assertEquals($name, $attachment->getName());
     $this->assertEquals($mimeType, $attachment->getMimeType());
     $this->assertEquals(\Jyxo\Mail\Email\Attachment::DISPOSITION_ATTACHMENT, $attachment->getDisposition());
     $this->assertFalse($attachment->isInline());
     $this->assertEquals('', $attachment->getCid());
     $this->assertEquals('', $attachment->getEncoding());
 }
 public function executeImportRestApiMerge(sfWebRequest $request)
 {
     $qa_generic = sfConfig::get("app_table_qa_generic");
     $qa_core = sfConfig::get("app_table_qa_core");
     // Retrieve test session id to update
     $testSessionId = $request->getParameter("id");
     // Retrieve $_GET
     $get_params['auth_token'] = $request->getGetParameter("auth_token");
     // Check if id parameter is empty
     if (empty($testSessionId)) {
         echo "{\"ok\":\"0\",\"errors\":{\"Parameters error\":\"Missing test session id parameter\"}}\n";
         exit;
     }
     // Check if auth_token parameter is empty
     if (empty($get_params['auth_token'])) {
         echo "{\"ok\":\"0\",\"errors\":{\"Parameters error\":\"Missing auth_token parameter\"}}\n";
         exit;
     }
     // Check authorized token exists, and retrieve user_id
     $sfGuardUserProfileObject = Doctrine_Core::getTable("sfGuardUserProfile")->findOneByToken($get_params['auth_token']);
     if (empty($sfGuardUserProfileObject)) {
         echo "{\"ok\":\"0\",\"errors\":{\"auth_token\":\"Authorized token is not valid\"}}\n";
         exit;
     }
     $user_id = $sfGuardUserProfileObject->getUserId();
     // Customize database connection to begin a transactionnal query
     $conn = Doctrine_Manager::getInstance()->getConnection("qa_generic");
     $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, FALSE);
     $conn->beginTransaction();
     // Update test_session table
     $testSession = Doctrine_Core::getTable("TestSession")->findOneById($testSessionId);
     $testSession->setUpdatedAt(date("Y-m-d H:i:s"));
     $testSession->save($conn);
     // Retrieve table_name_test_session_id from table_name
     $tableName = Doctrine_Core::getTable("TableName")->findOneByName("test_session");
     $tableNameTestSessionId = $tableName->getId();
     // Get file attachments id into an array
     $fileAttachmentIdList = array();
     $fileAttachments = Doctrine_Query::create()->select('*')->from('FileAttachment')->where('table_entry_id = ?', $testSessionId)->andWhere('table_name_id = ?', $tableNameTestSessionId)->execute();
     foreach ($fileAttachments as $fileAttachment) {
         $fileAttachmentIdList[] = $fileAttachment->getId();
     }
     // Concatenate directory path
     $dir_path = sfConfig::get('sf_upload_dir') . "/testsession_" . $testSessionId;
     $fileAttachmentResultIds = array();
     $similarFileFound = false;
     // Get all files sent
     $files = $request->getFiles();
     // Check if there is any report file to import
     if (empty($files)) {
         $conn->rollback();
         $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
         echo "{\"ok\":\"0\",\"errors\":\"Missing report file\"}\n";
         exit;
     }
     // Import each report file and register attachment files
     $report_file_found = false;
     foreach ($files as $key => $file) {
         $reportType = false;
         $fileName = $file['name'];
         $fileSize = $file['size'];
         $fileType = $file['type'];
         $fileError = $file['error'];
         $fileChecksum = sha1_file($file["tmp_name"]);
         $fileAttachmentResult = Doctrine_Query::create()->select('*')->from('FileAttachment')->where('table_entry_id = ?', $testSessionId)->andWhere('table_name_id = ?', $tableNameTestSessionId)->andWhere('checksum = ?', $fileChecksum)->execute();
         if (!empty($fileAttachmentResult[0])) {
             $fileAttachmentResultIds[] = $fileAttachmentResult[0]->getId();
             $similarFileFound = true;
         }
         // Check file error and file size
         if (!$fileError and $fileSize <= sfConfig::get('app_max_file_size', '10000000')) {
             if (!is_dir($dir_path)) {
                 mkdir($dir_path, 0777, true);
             }
             $dest_path = $dir_path . "/" . $fileName;
             $idx = 0;
             while (is_file($dest_path)) {
                 $idx++;
                 $dest_path = $dir_path . "/" . "(" . $idx . ")" . $fileName;
             }
             // Move file to uploads directory
             move_uploaded_file($file['tmp_name'], $dest_path);
             if ($idx == 0) {
                 $web_path = "/uploads" . "/testsession_" . $testSessionId . "/" . $fileName;
             } else {
                 $web_path = "/uploads" . "/testsession_" . $testSessionId . "/" . "(" . $idx . ")" . $fileName;
             }
             $fileAttachment = new FileAttachment();
             $fileAttachment->setName($fileName);
             $fileAttachment->setUserId($user_id);
             $fileAttachment->setUploadedAt(date("Y-m-d H:i:s"));
             $fileAttachment->setFilename($fileName);
             $fileAttachment->setFileSize($fileSize);
             $fileAttachment->setFileMimeType($fileType);
             $fileAttachment->setLink($web_path);
             $fileAttachment->setChecksum($fileChecksum);
             $fileAttachment->setTableNameId($tableNameTestSessionId);
             $fileAttachment->setTableEntryId($testSessionId);
             if ((preg_match("#\\.xml\$#i", $fileName) | preg_match("#\\.csv\$#i", $fileName)) & !preg_match("#attachment.?[0-9]*#i", $key)) {
                 $report_file_found = true;
                 $reportType = true;
                 $fileAttachment->setCategory(1);
             } else {
                 if (preg_match("#attachment.?[0-9]*#i", $key)) {
                     $fileAttachment->setCategory(2);
                 } else {
                     $conn->rollback();
                     $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
                     echo "{\"ok\":\"0\",\"errors\":\"Only upload files with the extension .xml or .csv\"}\n";
                     exit;
                 }
             }
             $fileAttachment->save($conn);
             // If it is an XML or CSV file, parse it and fill qa_generic database
             if ($reportType) {
                 if ($err_code = Import::file($dest_path, $testSessionId, $configurationId, $conn, true)) {
                     // Delete new files
                     $fileAttachments = Doctrine_Query::create()->select('*')->from('FileAttachment')->where('table_entry_id = ?', $testSessionId)->andWhere('table_name_id = ?', $tableNameTestSessionId)->andWhereNotIn('id', $fileAttachmentIdList)->execute();
                     foreach ($fileAttachments as $fileAttachment) {
                         unlink(sfConfig::get('sf_web_dir') . $fileAttachment->getLink());
                     }
                     $error_message = Import::getImportErrorMessage($err_code);
                     $conn->rollback();
                     $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
                     echo "{\"ok\":\"0\",\"errors\":\"File " . $fileName . " is not valid = " . $error_message . "\"}\n";
                     exit;
                 }
             }
         } else {
             // Delete new files
             $fileAttachments = Doctrine_Query::create()->select('*')->from('FileAttachment')->where('table_entry_id = ?', $testSessionId)->andWhere('table_name_id = ?', $tableNameTestSessionId)->andWhereNotIn('id', $fileAttachmentIdList)->execute();
             foreach ($fileAttachments as $fileAttachment) {
                 unlink(sfConfig::get('sf_web_dir') . $fileAttachment->getLink());
             }
             $conn->rollback();
             $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
             echo "{\"ok\":\"0\",\"errors\":\"File " . $fileName . " exceed maximum size\"}\n";
             exit;
         }
     }
     // If only attachment files have been found, cancel the new test session
     if (!$report_file_found) {
         $conn->rollback();
         $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
         echo "{\"ok\":\"0\",\"errors\":\"Missing report file\"}\n";
         exit;
     }
     if ($similarFileFound) {
         // Delete similar files and attachment entries
         $fileAttachments = Doctrine_Query::create()->select('*')->from('FileAttachment')->where('table_entry_id = ?', $testSessionId)->andWhere('table_name_id = ?', $tableNameTestSessionId)->andWhereIn('id', $fileAttachmentResultIds)->execute();
         foreach ($fileAttachments as $fileAttachment) {
             unlink(sfConfig::get('sf_web_dir') . $fileAttachment->getLink());
             $fileAttachment->delete($conn);
         }
     }
     $conn->commit();
     $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
     // Retrieve project name_slug, product name_slug, test environment name_slug and image name_slug
     $query = "SELECT i.name_slug image_name_slug, te.name_slug test_environment_name_slug, p.name_slug project_name_slug, pt.name_slug product_name_slug\n\t\t\t\t\tFROM " . $qa_generic . ".test_session ts\n\t\t\t\t\tJOIN " . $qa_generic . ".configuration c ON c.id = ts.configuration_id\n\t\t\t\t\tJOIN " . $qa_generic . ".image i ON i.id = c.image_id\n\t\t\t\t\tJOIN " . $qa_generic . ".test_environment te ON te.id = c.test_environment_id\n\t\t\t\t\tJOIN " . $qa_generic . ".project_to_product ptp ON ptp.id = c.project_to_product_id\n\t\t\t\t\tJOIN " . $qa_generic . ".project p ON p.id = ptp.project_id\n\t\t\t\t\tJOIN " . $qa_core . ".product_type pt ON pt.id = ptp.product_id\n\t\t\t\t\tWHERE ts.id = " . $testSessionId;
     $configInfo = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
     $projectNameSlug = $configInfo['project_name_slug'];
     $productNameSlug = $configInfo['product_name_slug'];
     $testEnvironmentNameSlug = $configInfo['test_environment_name_slug'];
     $imageNameSlug = $configInfo['image_name_slug'];
     // Return datas to CATS
     $url_to_return = $request->getUriPrefix() . $this->generateUrl("test_session", array('project' => $projectNameSlug, 'product' => $productNameSlug, 'environment' => $testEnvironmentNameSlug, 'image' => $imageNameSlug, 'id' => $testSessionId));
     echo "{\"ok\":\"1\",\"url\":\"" . $url_to_return . "\"}\n";
     // Return is done (with echo) so make sure nothing else will be sent
     exit;
 }
function CreateTestAnnots($doc)
{
    $ew = new ElementWriter();
    $eb = new ElementBuilder();
    $first_page = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $doc->PagePushBack($first_page);
    $ew->Begin($first_page, ElementWriter::e_overlay, false);
    // begin writing to this page
    $ew->End();
    // save changes to the current page
    //
    // Test of a free text annotation.
    //
    $txtannot = FreeText::Create($doc->GetSDFDoc(), new Rect(10.0, 400.0, 160.0, 570.0));
    $txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." . "\n\nAha!\n\nAnd there was much rejoicing!");
    $txtannot->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 1.0, 10.0, 20.0), true);
    $txtannot->SetQuaddingFormat(0);
    $first_page->AnnotPushBack($txtannot);
    $txtannot->RefreshAppearance();
    $txtannot = FreeText::Create($doc->GetSDFDoc(), new Rect(100.0, 100.0, 350.0, 500.0));
    $txtannot->SetContentRect(new Rect(200.0, 200.0, 350.0, 500.0));
    $txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." . "\n\nAha!\n\nAnd there was much rejoicing!");
    $txtannot->SetCalloutLinePoints(new Point(200.0, 300.0), new Point(150.0, 290.0), new Point(110.0, 110.0));
    $txtannot->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 1.0, 10.0, 20.0), true);
    $txtannot->SetEndingStyle(LineAnnot::e_ClosedArrow);
    $txtannot->SetColor(new ColorPt(0.0, 1.0, 0.0));
    $txtannot->SetQuaddingFormat(1);
    $first_page->AnnotPushBack($txtannot);
    $txtannot->RefreshAppearance();
    $txtannot = FreeText::Create($doc->GetSDFDoc(), new Rect(400.0, 10.0, 550.0, 400.0));
    $txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." . "\n\nAha!\n\nAnd there was much rejoicing!");
    $txtannot->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 1.0, 10.0, 20.0), true);
    $txtannot->SetColor(new ColorPt(0.0, 0.0, 1.0));
    $txtannot->SetOpacity(0.2);
    $txtannot->SetQuaddingFormat(2);
    $first_page->AnnotPushBack($txtannot);
    $txtannot->RefreshAppearance();
    $page = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $doc->PagePushBack($page);
    $ew->Begin($page, ElementWriter::e_overlay, false);
    // begin writing to this page
    $eb->Reset();
    // Reset the GState to default
    $ew->End();
    // save changes to the current page
    //Create a Line annotation...
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(250.0, 250.0, 400.0, 400.0));
    $line->SetStartPoint(new Point(350.0, 270.0));
    $line->SetEndPoint(new Point(260.0, 370.0));
    $line->SetStartStyle(LineAnnot::e_Square);
    $line->SetEndStyle(LineAnnot::e_Circle);
    $line->SetColor(new ColorPt(0.3, 0.5, 0.0), 3);
    $line->SetContents("Dashed Captioned");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->SetBorderStyle(new BorderStyle(BorderStyle::e_dashed, 2.0, 0.0, 0.0, array(2.0, 2.0)));
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(347.0, 377.0, 600.0, 600.0));
    $line->SetStartPoint(new Point(385.0, 410.0));
    $line->SetEndPoint(new Point(540.0, 555.0));
    $line->SetStartStyle(LineAnnot::e_Circle);
    $line->SetEndStyle(LineAnnot::e_OpenArrow);
    $line->SetColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $line->SetInteriorColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $line->SetContents("Inline Caption");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Inline);
    $line->SetLeaderLineExtensionLength(-4.0);
    $line->SetLeaderLineLength(-12.0);
    $line->SetLeaderLineOffset(2.0);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(10.0, 400.0, 200.0, 600.0));
    $line->SetStartPoint(new Point(25.0, 426.0));
    $line->SetEndPoint(new Point(180.0, 555.0));
    $line->SetStartStyle(LineAnnot::e_Circle);
    $line->SetEndStyle(LineAnnot::e_Square);
    $line->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $line->SetInteriorColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $line->SetContents("Offset Caption");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->SetTextHOffset(-60);
    $line->SetTextVOffset(10);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(200.0, 10.0, 400.0, 70.0));
    $line->SetStartPoint(new Point(220.0, 25.0));
    $line->SetEndPoint(new Point(370.0, 60.0));
    $line->SetStartStyle(LineAnnot::e_Butt);
    $line->SetEndStyle(LineAnnot::e_OpenArrow);
    $line->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $line->SetContents("Regular Caption");
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(200.0, 70.0, 400.0, 130.0));
    $line->SetStartPoint(new Point(220.0, 111.0));
    $line->SetEndPoint(new Point(370.0, 78.0));
    $line->SetStartStyle(LineAnnot::e_Circle);
    $line->SetEndStyle(LineAnnot::e_Diamond);
    $line->SetContents("Circle to Diamond");
    $line->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $line->SetInteriorColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(10.0, 100.0, 160.0, 200.0));
    $line->SetStartPoint(new Point(15.0, 110.0));
    $line->SetEndPoint(new Point(150.0, 190.0));
    $line->SetStartStyle(LineAnnot::e_Slash);
    $line->SetEndStyle(LineAnnot::e_ClosedArrow);
    $line->SetContents("Slash to CArrow");
    $line->SetColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $line->SetInteriorColor(new ColorPt(0.0, 1.0, 1.0), 3);
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(270.0, 270.0, 570.0, 433.0));
    $line->SetStartPoint(new Point(300.0, 400.0));
    $line->SetEndPoint(new Point(550.0, 300.0));
    $line->SetStartStyle(LineAnnot::e_RClosedArrow);
    $line->SetEndStyle(LineAnnot::e_ROpenArrow);
    $line->SetContents("ROpen & RClosed arrows");
    $line->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $line->SetInteriorColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(195.0, 395.0, 205.0, 505.0));
    $line->SetStartPoint(new Point(200.0, 400.0));
    $line->SetEndPoint(new Point(200.0, 500.0));
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(55.0, 299.0, 150.0, 301.0));
    $line->SetStartPoint(new Point(55.0, 300.0));
    $line->SetEndPoint(new Point(155.0, 300.0));
    $line->SetStartStyle(LineAnnot::e_Circle);
    $line->SetEndStyle(LineAnnot::e_Circle);
    $line->SetContents("Caption that's longer than its line.");
    $line->SetColor(new ColorPt(1.0, 0.0, 1.0), 3);
    $line->SetInteriorColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $line->SetShowCaption(true);
    $line->SetCaptionPosition(LineAnnot::e_Top);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $line = LineAnnot::Create($doc->GetSDFDoc(), new Rect(300.0, 200.0, 390.0, 234.0));
    $line->SetStartPoint(new Point(310.0, 210.0));
    $line->SetEndPoint(new Point(380.0, 220.0));
    $line->SetColor(new ColorPt(0.0, 0.0, 0.0), 3);
    $line->RefreshAppearance();
    $page->AnnotPushBack($line);
    $page3 = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $ew->Begin($page3);
    // begin writing to the page
    $ew->End();
    // save changes to the current page
    $doc->PagePushBack($page3);
    $circle = Circle::Create($doc->GetSDFDoc(), new Rect(300.0, 300.0, 390.0, 350.0));
    $circle->SetColor(new ColorPt(0.0, 0.0, 0.0), 3);
    $circle->RefreshAppearance();
    $page3->AnnotPushBack($circle);
    $circle = Circle::Create($doc->GetSDFDoc(), new Rect(100.0, 100.0, 200.0, 200.0));
    $circle->SetColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $circle->SetInteriorColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $circle->SetBorderStyle(new BorderStyle(BorderStyle::e_dashed, 3.0, 0.0, 0.0, array(2.0, 4.0)));
    $circle->SetPadding(2.0);
    $circle->RefreshAppearance();
    $page3->AnnotPushBack($circle);
    $sq = Square::Create($doc->GetSDFDoc(), new Rect(10.0, 200.0, 80.0, 300.0));
    $sq->SetColor(new ColorPt(0.0, 0.0, 0.0), 3);
    $sq->RefreshAppearance();
    $page3->AnnotPushBack($sq);
    $sq = Square::Create($doc->GetSDFDoc(), new Rect(500.0, 200.0, 580.0, 300.0));
    $sq->SetColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $sq->SetInteriorColor(new ColorPt(0.0, 1.0, 1.0), 3);
    $sq->SetBorderStyle(new BorderStyle(BorderStyle::e_dashed, 6.0, 0.0, 0.0, array(4.0, 2.0)));
    $sq->SetPadding(4.0);
    $sq->RefreshAppearance();
    $page3->AnnotPushBack($sq);
    $poly = Polygon::Create($doc->GetSDFDoc(), new Rect(5.0, 500.0, 125.0, 590.0));
    $poly->SetColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $poly->SetInteriorColor(new ColorPt(1.0, 1.0, 0.0), 3);
    $poly->SetVertex(0, new Point(12.0, 510.0));
    $poly->SetVertex(1, new Point(100.0, 510.0));
    $poly->SetVertex(2, new Point(100.0, 555.0));
    $poly->SetVertex(3, new Point(35.0, 544.0));
    $poly->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 4.0, 0.0, 0.0));
    $poly->SetPadding(4.0);
    $poly->RefreshAppearance();
    $page3->AnnotPushBack($poly);
    $poly = PolyLine::Create($doc->GetSDFDoc(), new Rect(400.0, 10.0, 500.0, 90.0));
    $poly->SetColor(new ColorPt(1.0, 0.0, 0.0), 3);
    $poly->SetInteriorColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $poly->SetVertex(0, new Point(405.0, 20.0));
    $poly->SetVertex(1, new Point(440.0, 40.0));
    $poly->SetVertex(2, new Point(410.0, 60.0));
    $poly->SetVertex(3, new Point(470.0, 80.0));
    $poly->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 2.0, 0.0, 0.0));
    $poly->SetPadding(4.0);
    $poly->SetStartStyle(LineAnnot::e_RClosedArrow);
    $poly->SetEndStyle(LineAnnot::e_ClosedArrow);
    $poly->RefreshAppearance();
    $page3->AnnotPushBack($poly);
    $lk = Link::Create($doc->GetSDFDoc(), new Rect(5.0, 5.0, 55.0, 24.0));
    //$lk->SetColor( new ColorPt(0.0,1.0,0.0), 3.0 );
    $lk->RefreshAppearance();
    $page3->AnnotPushBack($lk);
    $page4 = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $ew->Begin($page4);
    // begin writing to the page
    $ew->End();
    // save changes to the current page
    $doc->PagePushBack($page4);
    $ew->Begin($page4);
    $font = Font::Create($doc->GetSDFDoc(), Font::e_helvetica);
    $element = $eb->CreateTextBegin($font, 16.0);
    $element->SetPathFill(true);
    $ew->WriteElement($element);
    $element = $eb->CreateTextRun("Some random text on the page", $font, 16.0);
    $element->SetTextMatrix(1.0, 0.0, 0.0, 1.0, 100.0, 500.0);
    $ew->WriteElement($element);
    $ew->WriteElement($eb->CreateTextEnd());
    $ew->End();
    $hl = HighlightAnnot::Create($doc->GetSDFDoc(), new Rect(100.0, 490.0, 150.0, 515.0));
    $hl->SetColor(new ColorPt(0.0, 1.0, 0.0), 3);
    $hl->RefreshAppearance();
    $page4->AnnotPushBack($hl);
    $sq = Squiggly::Create($doc->GetSDFDoc(), new Rect(100.0, 450.0, 250.0, 600.0));
    //$sq->SetColor( new ColorPt(1.0,0.0,0.0), 3 );
    $sq->SetQuadPoint(0, new QuadPoint(new Point(122.0, 455.0), new Point(240.0, 545.0), new Point(230.0, 595.0), new Point(101.0, 500.0)));
    $sq->RefreshAppearance();
    $page4->AnnotPushBack($sq);
    $cr = Caret::Create($doc->GetSDFDoc(), new Rect(100.0, 40.0, 129.0, 69.0));
    $cr->SetColor(new ColorPt(0.0, 0.0, 1.0), 3);
    $cr->SetSymbol("P");
    $cr->RefreshAppearance();
    $page4->AnnotPushBack($cr);
    $page5 = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $ew->Begin($page5);
    // begin writing to the page
    $ew->End();
    // save changes to the current page
    $doc->PagePushBack($page5);
    global $input_path;
    $fs = FileSpec::Create($doc->GetSDFDoc(), $input_path . "butterfly.png", false);
    $page6 = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $ew->Begin($page6);
    // begin writing to the page
    $ew->End();
    // save changes to the current page
    $doc->PagePushBack($page6);
    for ($ipage = 0; $ipage < 2; ++$ipage) {
        for ($iann = 0; $iann < 100; $iann++) {
            if (!($iann > FileAttachment::e_Tag)) {
                $fa = FileAttachment::Create($doc->GetSDFDoc(), new Rect(50.0 + 50.0 * (double) $iann, 100.0, 70.0 + 50.0 * (double) $iann, 120.0), $fs, $iann);
                if ($ipage) {
                    $fa->SetColor(new ColorPt(1.0, 1.0, 0.0));
                }
                $fa->RefreshAppearance();
                if ($ipage == 0) {
                    $page5->AnnotPushBack($fa);
                } else {
                    $page6->AnnotPushBack($fa);
                }
            }
            if ($iann > Text::e_Note) {
                break;
            }
            $txt = Text::Create($doc->GetSDFDoc(), new Rect(10.0 + (double) $iann * 50.0, 200.0, 30.0 + (double) $iann * 50.0, 220.0));
            $txt->SetIcon($iann);
            $txt->SetContents($txt->GetIconName());
            if ($ipage) {
                $txt->SetColor(new ColorPt(1.0, 1.0, 0.0));
            }
            $txt->RefreshAppearance();
            if ($ipage == 0) {
                $page5->AnnotPushBack($txt);
            } else {
                $page6->AnnotPushBack($txt);
            }
        }
    }
    $txt = Text::Create($doc->GetSDFDoc(), new Rect(10.0, 20.0, 30.0, 40.0));
    $txt->SetIcon("UserIcon");
    $txt->SetContents("User defined icon, unrecognized by appearance generator");
    $txt->SetColor(new ColorPt(0.0, 1.0, 0.0));
    $txt->RefreshAppearance();
    $page6->AnnotPushBack($txt);
    $ink = Ink::Create($doc->GetSDFDoc(), new Rect(100.0, 400.0, 200.0, 550.0));
    $ink->SetColor(new ColorPt(0.0, 0.0, 1.0));
    $ink->SetPoint(1, 3, new Point(220.0, 505.0));
    $ink->SetPoint(1, 0, new Point(100.0, 490.0));
    $ink->SetPoint(0, 1, new Point(120.0, 410.0));
    $ink->SetPoint(0, 0, new Point(100.0, 400.0));
    $ink->SetPoint(1, 2, new Point(180.0, 490.0));
    $ink->SetPoint(1, 1, new Point(140.0, 440.0));
    $ink->SetBorderStyle(new BorderStyle(BorderStyle::e_solid, 3.0, 0.0, 0.0));
    $ink->RefreshAppearance();
    $page6->AnnotPushBack($ink);
    $page7 = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $ew->Begin($page7);
    // begin writing to the page
    $ew->End();
    // save changes to the current page
    $doc->PagePushBack($page7);
    $snd = Sound::Create($doc->GetSDFDoc(), new Rect(100.0, 500.0, 120.0, 520.0));
    $snd->SetColor(new ColorPt(1.0, 1.0, 0.0));
    $snd->SetIcon(Sound::e_Speaker);
    $snd->RefreshAppearance();
    $page7->AnnotPushBack($snd);
    $snd = Sound::Create($doc->GetSDFDoc(), new Rect(200.0, 500.0, 220.0, 520.0));
    $snd->SetColor(new ColorPt(1.0, 1.0, 0.0));
    $snd->SetIcon(Sound::e_Mic);
    $snd->RefreshAppearance();
    $page7->AnnotPushBack($snd);
    $page8 = $doc->PageCreate(new Rect(0.0, 0.0, 600.0, 600.0));
    $ew->Begin($page8);
    // begin writing to the page
    $ew->End();
    // save changes to the current page
    $doc->PagePushBack($page8);
    for ($ipage = 0; $ipage < 2; ++$ipage) {
        $px = 5;
        $py = 520;
        for ($istamp = RubberStamp::e_Approved; $istamp <= RubberStamp::e_Draft; $istamp = $istamp + 1) {
            $st = RubberStamp::Create($doc->GetSDFDoc(), new Rect(1.0, 1.0, 100.0, 100.0));
            $st->SetIcon($istamp);
            $st->SetContents($st->GetIconName());
            $st->SetRect(new Rect((double) $px, (double) $py, (double) $px + 100.0, (double) $py + 25.0));
            $py -= 100;
            if ($py < 0) {
                $py = 520;
                $px += 200;
            }
            if ($ipage == 0) {
                //$page7->AnnotPushBack( $st );
            } else {
                $page8->AnnotPushBack($st);
                $st->RefreshAppearance();
            }
        }
    }
    $st = RubberStamp::Create($doc->GetSDFDoc(), new Rect(400.0, 5.0, 550.0, 45.0));
    $st->SetIcon("UserStamp");
    $st->SetContents("User defined stamp");
    $page8->AnnotPushBack($st);
    $st->RefreshAppearance();
}
 /**
  * Process the form to edit an existing test session.
  *
  * @param sfWebRequest $request
  * @param SessionForm $form
  */
 protected function processEdit(sfWebRequest $request, SessionForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $qa_generic = sfConfig::get("app_table_qa_generic");
         // Get sent values and uploaded files
         $values = $form->getValues();
         $files = $request->getFiles();
         // Retrieve values from form
         $projectGroupId = $values["project_group_id"];
         $projectId = $values["project"];
         $productId = $values["product"];
         // Get test environment and image names
         $environmentForm = $form->getValue("environmentForm");
         $imageForm = $form->getValue("imageForm");
         // Create a new relationship between project group, project and product if needed
         $projectToProductId = Doctrine_Core::getTable("ProjectToProduct")->getProjectToProductId($projectGroupId, $projectId, $productId);
         if ($projectToProductId == null) {
             $projectToProduct = new ProjectToProduct();
             $projectToProduct->setProjectGroupId($projectGroupId);
             $projectToProduct->setProjectId($projectId);
             $projectToProduct->setProductId($productId);
             $projectToProduct->save($conn);
             $projectToProductId = $projectToProduct->getId();
         }
         // Create a new environment if needed
         $environment = Doctrine_Core::getTable("TestEnvironment")->findByArray($environmentForm);
         if ($environment == null) {
             // Add new environment
             $environment = new TestEnvironment();
             $environment->setName($environmentForm["name"]);
             $environment->setDescription($environmentForm["description"]);
             $environment->setCpu($environmentForm["cpu"]);
             $environment->setBoard($environmentForm["board"]);
             $environment->setGpu($environmentForm["gpu"]);
             $environment->setOtherHardware($environmentForm["other_hardware"]);
             // Check if its slug does not already exist and generate a new one if needed
             $slug = MiscUtils::slugify($environmentForm["name"]);
             $size = 1;
             while (Doctrine_Core::getTable("TestEnvironment")->checkSlug($slug)) {
                 $slug = MiscUtils::slugify($environmentForm["name"]) . substr(microtime(), -$size);
                 $size++;
             }
             $environment->setNameSlug($slug);
             $environment->save($conn);
             // Convert object into associative array
             $environment = $environment->toArray();
         }
         // Create a new image if needed
         $image = Doctrine_Core::getTable("Image")->findByArray($imageForm);
         if ($image == null) {
             // Add new image
             $image = new Image();
             $image->setName($imageForm["name"]);
             $image->setDescription($imageForm["description"]);
             $image->setOs($imageForm["os"]);
             $image->setDistribution($imageForm["distribution"]);
             $image->setVersion($imageForm["version"]);
             $image->setKernel($imageForm["kernel"]);
             $image->setArchitecture($imageForm["architecture"]);
             $image->setOtherFw($imageForm["other_fw"]);
             $image->setBinaryLink($imageForm["binary_link"]);
             $image->setSourceLink($imageForm["source_link"]);
             // Check if its slug does not already exist and generate a new one if needed
             $slug = MiscUtils::slugify($imageForm["name"]);
             $size = 1;
             while (Doctrine_Core::getTable("Image")->checkSlug($slug)) {
                 $slug = MiscUtils::slugify($imageForm["name"]) . substr(microtime(), -$size);
                 $size++;
             }
             $image->setNameSlug(MiscUtils::slugify($slug));
             $image->save($conn);
             // Convert object into associative array
             $image = $image->toArray();
         }
         // Create a new configuration relationship if needed
         $configurationId = Doctrine_Core::getTable("Configuration")->getConfigurationId($projectToProductId, $environment["id"], $image["id"]);
         if ($configurationId == null) {
             $configuration = new Configuration();
             $configuration->setProjectToProductId($projectToProductId);
             $configuration->setTestEnvironmentId($environment["id"]);
             $configuration->setImageId($image["id"]);
             $configuration->save($conn);
             $configurationId = $configuration->getId();
         }
         // Edit the session into DB
         $testSession = Doctrine_Core::getTable("TestSession")->find($values["id"]);
         $testSession->setId($values["id"]);
         $testSession->setBuildId($values["build_id"]);
         $testSession->setTestset($values["testset"]);
         $testSession->setName($values["name"]);
         $testSession->setTestObjective($values["test_objective"]);
         $testSession->setQaSummary($values["qa_summary"]);
         $testSession->setUserId($values["user_id"]);
         $testSession->setCreatedAt($values["created_at"]);
         $testSession->setEditorId($values["editor_id"]);
         $testSession->setUpdatedAt($values["updated_at"]);
         $testSession->setProjectRelease($values["project_release"]);
         $testSession->setProjectMilestone($values["project_milestone"]);
         $testSession->setIssueSummary($values["issue_summary"]);
         $testSession->setStatus($values["status"]);
         $testSession->setPublished($values["published"]);
         $testSession->setConfigurationId(intval($configurationId));
         $testSession->setCampaignChecksum($values["campaign_checksum"]);
         $testSession->setBuildSlug(MiscUtils::slugify($values["build_id"]));
         $testSession->setTestsetSlug(MiscUtils::slugify($values["testset"]));
         $testSession->setNotes($values["notes"]);
         $testSession->save();
         $testSessionId = $values["id"];
         // Get all results (and add associative key for each result)
         $array = array();
         foreach (Doctrine_Core::getTable("TestSession")->getSessionResults($this->currentSession["id"]) as $key => $value) {
             $array[MiscUtils::slugify($value["label"]) . $value["id"]] = $value;
         }
         $results = $array;
         // Get all measures (and add associative key for each measure)
         $array = array();
         foreach (Doctrine_Core::getTable("TestSession")->getSessionMeasures($this->currentSession["id"]) as $key => $value) {
             $array[MiscUtils::slugify($value["label"]) . $value["id"]] = $value;
         }
         $measures = $array;
         // Save test results
         foreach ($results as $key => $result) {
             if (array_key_exists($key, $values)) {
                 $resultForm = Doctrine_Core::getTable("TestResult")->find($result["id"]);
                 $resultForm->setId($result["id"]);
                 $resultForm->setDecisionCriteriaId($values[$key]["decision_criteria_id"]);
                 $resultForm->setComment($values[$key]["comment"]);
                 $resultForm->save();
             }
         }
         // Save measures
         foreach ($measures as $key => $measure) {
             if (array_key_exists($key, $values)) {
                 $resultForm = Doctrine_Core::getTable("TestResult")->find($measure["id"]);
                 $resultForm->setId($measure["id"]);
                 $resultForm->setDecisionCriteriaId($values[$key]["decision_criteria_id"]);
                 $resultForm->setComment($values[$key]["comment"]);
                 $resultForm->save();
             }
         }
         // Get project and product name slug
         $projectSlug = Doctrine_Core::getTable("Project")->getSlugById($projectId);
         $productSlug = Doctrine_Core::getTable("ProductType")->getSlugById($productId);
         // Retrieve table_name_test_session_id from table_name
         $tableName = Doctrine_Core::getTable("TableName")->findOneByName("test_session");
         $tableNameTestSessionId = $tableName->getId();
         // Import attachments and result files
         foreach ($files["attachments"] as $key => $file) {
             if ($file["error"] != UPLOAD_ERR_NO_FILE) {
                 $fileName = $file['name'];
                 $fileSize = $file['size'];
                 $fileType = $file['type'];
                 $fileError = $file['error'];
                 $fileChecksum = sha1_file($file["tmp_name"]);
                 // Check file error and file size (5Mo max)
                 if (!$fileError and $fileSize <= 5000000) {
                     // Concatenate destination path
                     $dest_path = sfConfig::get('sf_upload_dir') . "/testsession_" . $testSessionId;
                     if (!is_dir($dest_path)) {
                         mkdir($dest_path, 0777, true);
                     }
                     $dest_path .= "/" . $fileName;
                     // Move file to uploads directory
                     move_uploaded_file($file['tmp_name'], $dest_path);
                     $web_path = "/uploads" . "/testsession_" . $testSessionId . "/" . $fileName;
                     $fileAttachment = new FileAttachment();
                     $fileAttachment->setName($fileName);
                     $fileAttachment->setUserId($this->getUser()->getGuardUser()->getId());
                     $fileAttachment->setUploadedAt(date("Y-m-d H:i:s"));
                     $fileAttachment->setFilename($fileName);
                     $fileAttachment->setFileSize($fileSize);
                     $fileAttachment->setFileMimeType($fileType);
                     $fileAttachment->setLink($web_path);
                     $fileAttachment->setChecksum($fileChecksum);
                     $fileAttachment->setTableNameId($tableNameTestSessionId);
                     $fileAttachment->setTableEntryId($testSessionId);
                     $fileAttachment->setCategory(2);
                     $fileAttachment->save();
                 }
             }
         }
         // Customize database connection to begin a transactionnal query
         $conn = Doctrine_Manager::getInstance()->getConnection("qa_generic");
         $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, FALSE);
         $conn->beginTransaction();
         // Get file attachments id into an array
         $fileAttachmentIdList = array();
         $query = "SELECT fa.id\n\t\t\t\t\tFROM " . $qa_generic . ".file_attachment fa\n\t\t\t\t\tWHERE fa.table_entry_id = " . $testSessionId . "\n\t\t\t\t\t\tAND fa.table_name_id = " . $tableNameTestSessionId;
         $results = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetchAll(PDO::FETCH_ASSOC);
         foreach ($results as $result) {
             $fileAttachmentIdList[] = $result["id"];
         }
         $fileAttachmentIdStringList = implode(",", $fileAttachmentIdList);
         // Concatenate directory path
         $dir_path = sfConfig::get('sf_upload_dir') . "/testsession_" . $testSessionId;
         $fileAttachmentResultIds = array();
         $similarFileFound = false;
         foreach ($files["result_files"] as $key => $file) {
             if ($file["error"] != UPLOAD_ERR_NO_FILE) {
                 $reportType = false;
                 $fileName = $file['name'];
                 $fileSize = $file['size'];
                 $fileType = $file['type'];
                 $fileError = $file['error'];
                 $fileChecksum = sha1_file($file["tmp_name"]);
                 $query = "SELECT fa.id\n\t\t\t\t\t\t\tFROM " . $qa_generic . ".file_attachment fa\n\t\t\t\t\t\t\tWHERE fa.table_entry_id = " . $testSessionId . "\n\t\t\t\t\t\t\t\tAND fa.table_name_id = " . $tableNameTestSessionId . "\n\t\t\t\t\t\t\t\tAND fa.checksum = '" . $fileChecksum . "'";
                 $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
                 if (!empty($result["id"])) {
                     $fileAttachmentResultIds[] = $result["id"];
                     $similarFileFound = true;
                 }
                 // Check file error and file size
                 if (!$fileError and $fileSize <= sfConfig::get('app_max_file_size', '10000000')) {
                     if (!is_dir($dir_path)) {
                         mkdir($dir_path, 0777, true);
                     }
                     $dest_path = $dir_path . "/" . $fileName;
                     $idx = 0;
                     while (is_file($dest_path)) {
                         $idx++;
                         $dest_path = $dir_path . "/" . "(" . $idx . ")" . $fileName;
                     }
                     // Move file to uploads directory
                     move_uploaded_file($file['tmp_name'], $dest_path);
                     if ($idx == 0) {
                         $web_path = "/uploads" . "/testsession_" . $testSessionId . "/" . $fileName;
                     } else {
                         $web_path = "/uploads" . "/testsession_" . $testSessionId . "/" . "(" . $idx . ")" . $fileName;
                     }
                     $fileAttachment = new FileAttachment();
                     $fileAttachment->setName($fileName);
                     $fileAttachment->setUserId($this->getUser()->getGuardUser()->getId());
                     $fileAttachment->setUploadedAt(date("Y-m-d H:i:s"));
                     $fileAttachment->setFilename($fileName);
                     $fileAttachment->setFileSize($fileSize);
                     $fileAttachment->setFileMimeType($fileType);
                     $fileAttachment->setLink($web_path);
                     $fileAttachment->setChecksum($fileChecksum);
                     $fileAttachment->setTableNameId($tableNameTestSessionId);
                     $fileAttachment->setTableEntryId($testSessionId);
                     if (preg_match("#\\.xml\$#i", $fileName) | preg_match("#\\.csv\$#i", $fileName)) {
                         $reportType = true;
                         $fileAttachment->setCategory(1);
                     } else {
                         $fileAttachment->setCategory(2);
                     }
                     $fileAttachment->save($conn);
                     // If it is an XML or CSV file, parse it and fill qa_generic database
                     if ($reportType) {
                         if ($err_code = Import::file($dest_path, $testSessionId, $configurationId, $conn, true)) {
                             // Delete new files
                             $query = "SELECT fa.link\n\t\t\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".file_attachment fa\n\t\t\t\t\t\t\t\t\t\tWHERE fa.table_entry_id = " . $testSessionId . "\n\t\t\t\t\t\t\t\t\t\t\tAND fa.table_name_id = " . $tableNameTestSessionId . "\n\t\t\t\t\t\t\t\t\t\t\tAND fa.id NOT IN (" . $fileAttachmentIdStringList . ")";
                             $results = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetchAll(PDO::FETCH_ASSOC);
                             foreach ($results as $result) {
                                 unlink(sfConfig::get('sf_web_dir') . $result["link"]);
                             }
                             $error_message = Import::getImportErrorMessage($err_code);
                             $conn->rollback();
                             $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
                             $this->getUser()->setFlash("error", "Invalid file content on " . $fileName . " : " . $error_message);
                             $this->redirect("edit_report", array("project" => $projectSlug, "product" => $productSlug, "environment" => $environment["name_slug"], "image" => $image["name_slug"], "id" => $testSessionId));
                         }
                     }
                 } else {
                     // Delete new files
                     $query = "SELECT fa.link\n\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".file_attachment fa\n\t\t\t\t\t\t\t\tWHERE fa.table_entry_id = " . $testSessionId . "\n\t\t\t\t\t\t\t\t\tAND fa.table_name_id = " . $tableNameTestSessionId . "\n\t\t\t\t\t\t\t\t\tAND fa.id NOT IN (" . $fileAttachmentIdStringList . ")";
                     $results = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetchAll(PDO::FETCH_ASSOC);
                     foreach ($results as $result) {
                         unlink(sfConfig::get('sf_web_dir') . $result["link"]);
                     }
                     $conn->rollback();
                     $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
                     $this->getUser()->setFlash("error", "File size limit reached");
                     $this->redirect("edit_report", array("project" => $projectSlug, "product" => $productSlug, "environment" => $environment["name_slug"], "image" => $image["name_slug"], "id" => $testSessionId));
                 }
             }
         }
         if ($similarFileFound) {
             $fileAttachmentStringResultIds = implode(",", $fileAttachmentResultIds);
             // Delete similar files and attachment entries
             $query = "SELECT fa.id, fa.link\n\t\t\t\t\t\tFROM " . $qa_generic . ".file_attachment fa\n\t\t\t\t\t\tWHERE fa.table_entry_id = " . $testSessionId . "\n\t\t\t\t\t\t\tAND fa.table_name_id = " . $tableNameTestSessionId . "\n\t\t\t\t\t\t\tAND fa.id IN (" . $fileAttachmentStringResultIds . ")";
             $results = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetchAll(PDO::FETCH_ASSOC);
             foreach ($results as $result) {
                 unlink(sfConfig::get('sf_web_dir') . $result["link"]);
                 Doctrine_Core::getTable("FileAttachment")->deleteFileAttachmentById($result["id"], $conn);
             }
         }
         $conn->commit();
         $conn->setAttribute(Doctrine_Core::ATTR_AUTOCOMMIT, TRUE);
         // 			// Clear cache for actions related to this test session
         // 			$cacheManager = $this->getContext()->getViewCacheManager();
         // 			$cacheManager->remove("reports/session?project=".$projectSlug."&product=".$productSlug."&environment=".$environment["name_slug"]."&image=".$image["name_slug"]."?id=".$testSession["id"]);
         // Set flash for user and redirect to session display
         $this->getUser()->setFlash("notice", "Test session was updated successfully");
         if (!empty($testSession["build_slug"])) {
             $this->redirect("build_session", array("project" => $projectSlug, "product" => $productSlug, "build" => $testSession["build_slug"], "environment" => $environment["name_slug"], "image" => $image["name_slug"], "id" => $request->getParameter("id")));
         } else {
             $this->redirect("test_session", array("project" => $projectSlug, "product" => $productSlug, "environment" => $environment["name_slug"], "image" => $image["name_slug"], "id" => $request->getParameter("id")));
         }
     }
 }