public function testExport()
 {
     $this->simulateLogin('*****@*****.**', true);
     $controller = new ExportServiceUserDataController(true);
     $_POST['instance_id'] = 1;
     ob_start();
     $controller->go();
     $results = ob_get_contents();
     ob_end_clean();
     // write downloaded zip file to disk...
     $fh = fopen($this->export_test, 'wb');
     fwrite($fh, $results);
     fclose($fh);
     // verify contents of zip file...
     $za = new ZipArchive();
     $za->open($this->export_test);
     $zip_files = array();
     for ($i = 0; $i < $za->numFiles; $i++) {
         $zfile = $za->statIndex($i);
         $zip_files[$zfile['name']] = $zfile['name'];
     }
     //verify we have create table file
     $this->assertTrue($zip_files["/README.txt"]);
     $this->assertTrue($zip_files["/posts.tmp"]);
     $this->assertTrue($zip_files["/links.tmp"]);
     $this->assertTrue($zip_files["/users_from_posts.tmp"]);
     $this->assertTrue($zip_files["/follows.tmp"]);
     $this->assertTrue($zip_files["/encoded_locations.tmp"]);
     $this->assertTrue($zip_files["/favorites.tmp"]);
     $za->close();
 }
示例#2
0
/**
 *
 * ThinkUp/webapp/install/exportuserdata.php
 *
 * Copyright (c) 2009-2012 Gina Trapani
 *
 * LICENSE:
 *
 * This file is part of ThinkUp (http://thinkupapp.com).
 *
 * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
 * later version.
 *
 * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with ThinkUp.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 *
 * @author Gina Trapani <ginatrapani[at]gmail[dot]com>
 * @license http://www.gnu.org/licenses/gpl.html
 * @copyright 2009-2012 Gina Trapani, Dwi Widiastuti
 */
chdir('..');
require_once 'init.php';
$controller = new ExportServiceUserDataController();
echo $controller->go();
 public function testMySQLErrors()
 {
     $this->simulateLogin('*****@*****.**', true);
     // backup of DAO mapping
     $dao_mapping_backup = DAOFactory::$dao_mapping['ExportDAO'];
     DAOFactory::$dao_mapping['ExportDAO']['mysql'] = 'TestExportDAOFileFail';
     $controller = new ExportServiceUserDataController(true);
     $_POST['instance_id'] = 1;
     $results = $controller->go();
     $this->assertPattern("/MySQL user does not have the proper file permissions/", $results);
     DAOFactory::$dao_mapping['ExportDAO']['mysql'] = 'TestExportDAOGrantFail';
     $controller = new ExportServiceUserDataController(true);
     $_POST['instance_id'] = 1;
     $results = $controller->go();
     $this->assertPattern("/MySQL user does not have the proper permissions to/", $results);
     DAOFactory::$dao_mapping['ExportDAO']['mysql'] = $dao_mapping_backup;
 }