Пример #1
0
 public function testKnownGoodZipArchiveEqualsGeneratedZipArchive()
 {
     $this->auth();
     $goodZip = new ZipArchiveModel(null, array('filename' => PROJECT_PATH . "/test/data/zip/test-archive.zip"));
     $xml = file_get_contents(PROJECT_PATH . "/test/data/xml/test1-questionnaire-definition.xml");
     QuestionnaireModel::importXML($xml);
     InstanceModel::importXML($xml, 'Test1 Company');
     $instance = new InstanceModel(array('questionnaireName' => 'Test1 Questionnaire', 'questionnaireVersion' => '3.00', 'revision' => 1, 'instanceName' => 'Test1 Company', 'depth' => 'question'));
     while ($page = $instance->nextPage()) {
         while ($section = $page->nextSection()) {
             while ($question = $section->nextQuestion()) {
                 $fileObj = new FileModel($question);
                 $fileObj->store(file_get_contents(PROJECT_PATH . '/test/data/zip/test-archive-attachment.txt'), array('filename' => 'test-archive-attachment.txt'));
                 break 3;
             }
         }
     }
     $zip = new ZipArchiveModel($instance, array('new' => '1'));
     $zip->addInstanceFullResponsesXMLDocument();
     $zip->addAttachments();
     $zip->close();
     $zip = new ZipArchiveModel($instance, array('filename' => $zip->getZipFileName()));
     $this->assertEquals($goodZip->getInstanceFullResponsesXMLDocument(), $zip->getInstanceFullResponsesXMLDocument());
     $this->assertEquals($goodZip->getFromName('files/4'), $zip->getFromName('files/4'));
     $zip->deleteZipFile();
 }
Пример #2
0
 /**
  * Action for copying an instance
  */
 public function copyInstanceAction()
 {
     $session = new Zend_Session_Namespace('login');
     $instance = new InstanceModel(array('instanceID' => $session->dataInstanceID, 'depth' => 'instance'));
     $instanceName = $this->_getParam('instanceName');
     $zip = new ZipArchiveModel($instance, array('new' => '1'));
     $zip->addInstanceFullResponsesXMLDocument();
     $zip->addAttachments();
     $zip->close();
     $filename = $zip->getZipFileName();
     $zip = new ZipArchiveModel(null, array('filename' => $filename));
     InstanceModel::importXML($zip, $instanceName, array('pageResponses' => array('all' => 1)));
     $zip->deleteZipFile();
     $this->flash('notice', 'Copy Complete');
     $this->_redirector->gotoRoute(array('action' => 'index'));
 }