summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-11-25 00:25:37 +0100
committerLukas Reschke <lukas@owncloud.com>2014-11-25 00:25:37 +0100
commiteb1dcb87c10cb41151941876af301e3c01b19aa0 (patch)
treee5c833a7c808ec0a66b5e73b55a01beb165163e4 /tests
parent02095d4f2052350132631970467c5aedd7cffe0c (diff)
parent216d617938705d27c84939935030dd12e4886438 (diff)
downloadnextcloud-server-eb1dcb87c10cb41151941876af301e3c01b19aa0.tar.gz
nextcloud-server-eb1dcb87c10cb41151941876af301e3c01b19aa0.zip
Merge pull request #12380 from owncloud/remove-oc-migrate
Remove OC_Migrate
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/migrate.php98
1 files changed, 0 insertions, 98 deletions
diff --git a/tests/lib/migrate.php b/tests/lib/migrate.php
deleted file mode 100644
index 9c1e980c445..00000000000
--- a/tests/lib/migrate.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-/**
- * Copyright (c) 2014 Tom Needham <tom@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-class Test_Migrate extends \Test\TestCase {
-
- public $users;
- public $tmpfiles = array();
-
- /** @var \OC\Files\Storage\Storage */
- private $originalStorage;
-
- protected function setUp() {
- parent::setUp();
-
- $this->originalStorage = \OC\Files\Filesystem::getStorage('/');
- }
-
- protected function tearDown() {
- $u = new OC_User();
- foreach($this->users as $user) {
- $u->deleteUser($user);
- }
- foreach($this->tmpfiles as $file) {
- \OC_Helper::rmdirr($file);
- }
-
- \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
- parent::tearDown();
- }
-
- /**
- * Generates a test user and sets up their file system
- * @return string the test users id
- */
- public function generateUser() {
- $username = $this->getUniqueID();
- \OC_User::createUser($username, 'password');
- \OC_Util::tearDownFS();
- \OC_User::setUserId('');
- \OC\Files\Filesystem::tearDown();
- \OC_Util::setupFS($username);
- $this->users[] = $username;
- return $username;
- }
-
- /**
- * validates an export for a user
- * checks for existence of export_info.json and file folder
- * @param string $exportedUser the user that was exported
- * @param string $path the path to the .zip export
- * @param string $exportedBy
- */
- public function validateUserExport($exportedBy, $exportedUser, $path) {
- $this->assertTrue(file_exists($path));
- // Extract
- $extract = get_temp_dir() . '/oc_import_' . uniqid();
- //mkdir($extract);
- $this->tmpfiles[] = $extract;
- $zip = new ZipArchive;
- $zip->open($path);
- $zip->extractTo($extract);
- $zip->close();
- $this->assertTrue(file_exists($extract.'/export_info.json'));
- $exportInfo = file_get_contents($extract.'/export_info.json');
- $exportInfo = json_decode($exportInfo);
- $this->assertNotNull($exportInfo);
- $this->assertEquals($exportedUser, $exportInfo->exporteduser);
- $this->assertEquals($exportedBy, $exportInfo->exportedby);
- $this->assertTrue(file_exists($extract.'/'.$exportedUser.'/files'));
- }
-
- public function testUserSelfExport() {
- // Create a user
- $user = $this->generateUser();
- \OC_User::setUserId($user);
- $export = \OC_Migrate::export($user);
- // Check it succeeded and exists
- $this->assertTrue(json_decode($export)->success);
- // Validate the export
- $this->validateUserExport($user, $user, json_decode($export)->data);
- }
-
- public function testUserOtherExport() {
- $user = $this->generateUser();
- $user2 = $this->generateUser();
- \OC_User::setUserId($user2);
- $export = \OC_Migrate::export($user);
- // Check it succeeded and exists
- $this->assertTrue(json_decode($export)->success);
- // Validate the export
- $this->validateUserExport($user2, $user, json_decode($export)->data);
- }
-}