[Pkg-owncloud-commits] [owncloud] 22/103: fix cherrypicking

David Prévot taffit at moszumanska.debian.org
Sun May 31 12:32:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.0.4RC1
in repository owncloud.

commit 92febbf574b771069885634292916bcfd1d4cb8a
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date:   Thu Apr 9 14:03:30 2015 +0200

    fix cherrypicking
---
 apps/user_ldap/lib/connection.php     |  2 +-
 apps/user_ldap/tests/user/manager.php |  4 ++++
 apps/user_ldap/tests/user_ldap.php    | 27 +++++++++++----------
 lib/private/hook.php                  |  2 +-
 tests/lib/files/filesystem.php        | 11 ++++++++-
 tests/lib/preview.php                 | 44 +++++++++++++++++------------------
 6 files changed, 51 insertions(+), 39 deletions(-)

diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 6a936b4..d22adbd 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -23,10 +23,10 @@
 
 namespace OCA\user_ldap\lib;
 
-//magic properties (incomplete)
 use OC\ServerNotAvailableException;
 
 /**
+ * magic properties (incomplete)
  * responsible for LDAP connections in context with the provided configuration
  *
  * @property string ldapUserFilter
diff --git a/apps/user_ldap/tests/user/manager.php b/apps/user_ldap/tests/user/manager.php
index 051adc2..4ce5043 100644
--- a/apps/user_ldap/tests/user/manager.php
+++ b/apps/user_ldap/tests/user/manager.php
@@ -143,6 +143,8 @@ class Test_User_Manager extends \Test\TestCase {
         $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
         $manager->setLdapAccess($access);
         $user = $manager->get($inputDN);
+
+        $this->assertNull($user);
     }
 
     public function testGetByUidExisting() {
@@ -190,6 +192,8 @@ class Test_User_Manager extends \Test\TestCase {
         $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc);
         $manager->setLdapAccess($access);
         $user = $manager->get($uid);
+
+        $this->assertNull($user);
     }
 
 }
diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php
index 95c241d..119b0b1 100644
--- a/apps/user_ldap/tests/user_ldap.php
+++ b/apps/user_ldap/tests/user_ldap.php
@@ -429,7 +429,7 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 	 */
 	public function testUserExistsForDeleted() {
 		$access = $this->getAccessMock();
-		$backend = new UserLDAP($access);
+		$backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
 		$this->prepareMockForUserExists($access);
 
 		$access->expects($this->any())
@@ -447,7 +447,7 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 
 	public function testUserExistsForNeverExisting() {
 		$access = $this->getAccessMock();
-		$backend = new UserLDAP($access);
+		$backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
 		$this->prepareMockForUserExists($access);
 
 		$access->expects($this->any())
@@ -489,7 +489,7 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 	 */
 	public function testUserExistsPublicAPIForDeleted() {
 		$access = $this->getAccessMock();
-		$backend = new UserLDAP($access);
+		$backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
 		$this->prepareMockForUserExists($access);
 		\OC_User::useBackend($backend);
 
@@ -508,7 +508,7 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 
 	public function testUserExistsPublicAPIForNeverExisting() {
 		$access = $this->getAccessMock();
-		$backend = new UserLDAP($access);
+		$backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
 		$this->prepareMockForUserExists($access);
 		\OC_User::useBackend($backend);
 
@@ -565,19 +565,15 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 				}
 			}));
 
-		$datadir = '/my/data/dir';
-		$config->expects($this->once())
-			->method('getSystemValue')
-			->will($this->returnValue($datadir));
-
 		//absolut path
 		$result = $backend->getHome('gunslinger');
 		$this->assertEquals('/tmp/rolandshome/', $result);
 	}
 
-	public function testGetHomeDatadirRelative() {
+	public function testGetHomeRelative() {
 		$access = $this->getAccessMock();
-		$backend = new UserLDAP($access);
+		$config = $this->getMock('\OCP\IConfig');
+		$backend = new UserLDAP($access, $config);
 		$this->prepareMockForUserExists($access);
 
 		$access->connection->expects($this->any())
@@ -604,9 +600,12 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 				}
 			}));
 		//datadir-relativ path
+		$datadir = '/my/data/dir';
+		$config->expects($this->once())
+			->method('getSystemValue')
+			->will($this->returnValue($datadir));
+
 		$result = $backend->getHome('ladyofshadows');
-		$datadir = \OCP\Config::getSystemValue('datadirectory',
-			\OC::$SERVERROOT.'/data');
 		$this->assertEquals($datadir.'/susannah/', $result);
 	}
 
@@ -615,7 +614,7 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
 	 */
 	public function testGetHomeNoPath() {
 		$access = $this->getAccessMock();
-		$backend = new UserLDAP($access);
+		$backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
 		$this->prepareMockForUserExists($access);
 
 		$access->connection->expects($this->any())
diff --git a/lib/private/hook.php b/lib/private/hook.php
index 7c71286..72a1f90 100644
--- a/lib/private/hook.php
+++ b/lib/private/hook.php
@@ -80,7 +80,7 @@ class OC_Hook{
 				OC_Log::write('hook',
 					'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(),
 					OC_Log::ERROR);
-				if($e instanceof \OC\ServerNotAvailableException && $signalclass === 'OC_Filesystem' && $signalname === 'setup') {
+				if($e instanceof \OC\ServerNotAvailableException && $signalClass === 'OC_Filesystem' && $signalName === 'setup') {
 					throw $e;
 				}
 			}
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index 5acfb1f..2da2937 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -25,6 +25,9 @@ namespace Test\Files;
 use OC\User\NoUserException;
 
 class Filesystem extends \Test\TestCase {
+
+	const TEST_FILESYSTEM_USER1 = "test-filesystem-user1";
+
 	/**
 	 * @var array tmpDirs
 	 */
@@ -246,8 +249,14 @@ class Filesystem extends \Test\TestCase {
 		if (\OC\Files\Filesystem::getView()) {
 			$user = \OC_User::getUser();
 		} else {
-			$user = $this->getUniqueID();
+			$user = self::TEST_FILESYSTEM_USER1;
+			$backend = new \OC_User_Dummy();
+			\OC_User::useBackend($backend);
+			$backend->createUser($user, $user);
+			$userObj = \OC::$server->getUserManager()->get($user);
+			\OC::$server->getUserSession()->setUser($userObj);
 			\OC\Files\Filesystem::init($user, '/' . $user . '/files');
+
 		}
 		\OC_Hook::clear('OC_Filesystem');
 		\OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
diff --git a/tests/lib/preview.php b/tests/lib/preview.php
index 2a67614..8323387 100644
--- a/tests/lib/preview.php
+++ b/tests/lib/preview.php
@@ -10,10 +10,7 @@ namespace Test;
 
 class Preview extends TestCase {
 
-	/**
-	 * @var string
-	 */
-	private $user;
+	const TEST_PREVIEW_USER1 = "test-preview-user1";
 
 	/**
 	 * @var \OC\Files\View
@@ -30,15 +27,18 @@ class Preview extends TestCase {
 
 		// create a new user with his own filesystem view
 		// this gets called by each test in this test class
-		$this->user = $this->getUniqueID();
-		\OC_User::setUserId($this->user);
-		\OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files');
+		$backend = new \OC_User_Dummy();
+		\OC_User::useBackend($backend);
+		$backend->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1);
+		$user = \OC::$server->getUserManager()->get(self::TEST_PREVIEW_USER1);
+		\OC::$server->getUserSession()->setUser($user);
+		\OC\Files\Filesystem::init(self::TEST_PREVIEW_USER1, '/' . self::TEST_PREVIEW_USER1 . '/files');
 
 		\OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/');
 
 		$this->rootView = new \OC\Files\View('');
-		$this->rootView->mkdir('/'.$this->user);
-		$this->rootView->mkdir('/'.$this->user.'/files');
+		$this->rootView->mkdir('/'.self::TEST_PREVIEW_USER1);
+		$this->rootView->mkdir('/'.self::TEST_PREVIEW_USER1.'/files');
 	}
 
 	protected function tearDown() {
@@ -50,20 +50,20 @@ class Preview extends TestCase {
 
 	public function testIsPreviewDeleted() {
 
-		$sampleFile = '/'.$this->user.'/files/test.txt';
+		$sampleFile = '/'.self::TEST_PREVIEW_USER1.'/files/test.txt';
 
 		$this->rootView->file_put_contents($sampleFile, 'dummy file data');
 		
 		$x = 50;
 		$y = 50;
 
-		$preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
+		$preview = new \OC\Preview(self::TEST_PREVIEW_USER1, 'files/', 'test.txt', $x, $y);
 		$preview->getPreview();
 
 		$fileInfo = $this->rootView->getFileInfo($sampleFile);
 		$fileId = $fileInfo['fileid'];
 
-		$thumbCacheFile = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
+		$thumbCacheFile = '/' . self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
 		
 		$this->assertEquals($this->rootView->file_exists($thumbCacheFile), true);
 
@@ -74,20 +74,20 @@ class Preview extends TestCase {
 
 	public function testAreAllPreviewsDeleted() {
 
-		$sampleFile = '/'.$this->user.'/files/test.txt';
+		$sampleFile = '/'.self::TEST_PREVIEW_USER1.'/files/test.txt';
 
 		$this->rootView->file_put_contents($sampleFile, 'dummy file data');
 		
 		$x = 50;
 		$y = 50;
 
-		$preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
+		$preview = new \OC\Preview(self::TEST_PREVIEW_USER1, 'files/', 'test.txt', $x, $y);
 		$preview->getPreview();
 
 		$fileInfo = $this->rootView->getFileInfo($sampleFile);
 		$fileId = $fileInfo['fileid'];
 		
-		$thumbCacheFolder = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/';
+		$thumbCacheFolder = '/' . self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/';
 		
 		$this->assertEquals($this->rootView->is_dir($thumbCacheFolder), true);
 
@@ -131,9 +131,9 @@ class Preview extends TestCase {
 		$x = 32;
 		$y = 32;
 
-		$sample = '/'.$this->user.'/files/test.'.$extension;
+		$sample = '/'.self::TEST_PREVIEW_USER1.'/files/test.'.$extension;
 		$this->rootView->file_put_contents($sample, $data);
-		$preview = new \OC\Preview($this->user, 'files/', 'test.'.$extension, $x, $y);
+		$preview = new \OC\Preview(self::TEST_PREVIEW_USER1, 'files/', 'test.'.$extension, $x, $y);
 		$image = $preview->getPreview();
 		$resource = $image->resource();
 
@@ -149,7 +149,7 @@ class Preview extends TestCase {
 
 	public function testCreationFromCached() {
 
-		$sampleFile = '/'.$this->user.'/files/test.txt';
+		$sampleFile = '/'.self::TEST_PREVIEW_USER1.'/files/test.txt';
 
 		$this->rootView->file_put_contents($sampleFile, 'dummy file data');
 
@@ -157,22 +157,22 @@ class Preview extends TestCase {
 		$x = 150;
 		$y = 150;
 
-		$preview = new \OC\Preview($this->user, 'files/', 'test.txt', $x, $y);
+		$preview = new \OC\Preview(self::TEST_PREVIEW_USER1, 'files/', 'test.txt', $x, $y);
 		$preview->getPreview();
 
 		$fileInfo = $this->rootView->getFileInfo($sampleFile);
 		$fileId = $fileInfo['fileid'];
 
-		$thumbCacheFile = '/' . $this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
+		$thumbCacheFile = '/' . self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/' . $x . '-' . $y . '.png';
 
 		$this->assertEquals($this->rootView->file_exists($thumbCacheFile), true);
 
 
 		// create smaller previews
-		$preview = new \OC\Preview($this->user, 'files/', 'test.txt', 50, 50);
+		$preview = new \OC\Preview(self::TEST_PREVIEW_USER1, 'files/', 'test.txt', 50, 50);
 		$isCached = $preview->isCached($fileId);
 
-		$this->assertEquals($this->user . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/150-150.png', $isCached);
+		$this->assertEquals(self::TEST_PREVIEW_USER1 . '/' . \OC\Preview::THUMBNAILS_FOLDER . '/' . $fileId . '/150-150.png', $isCached);
 	}
 
 	/*

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list