[Pkg-owncloud-commits] [owncloud] 14/121: add unit test to make sure getVersions returns the correct result

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 16:44:26 UTC 2014


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

taffit pushed a commit to branch master
in repository owncloud.

commit 7540a58ce7e921f1eb8083f58ded6977ade10ad0
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Tue Aug 5 17:26:23 2014 +0200

    add unit test to make sure getVersions returns the correct result
---
 apps/files_versions/tests/versions.php | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 0343227..558c8df 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -267,6 +267,40 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
 	}
 
 	/**
+	 * test if we find all versions and if the versions array contain
+	 * the correct 'path' and 'name'
+	 */
+	public function testGetVersions() {
+
+		$t1 = time();
+		// second version is two weeks older, this way we make sure that no
+		// version will be expired
+		$t2 = $t1 - 60 * 60 * 24 * 14;
+
+		// create some versions
+		$v1 = self::USERS_VERSIONS_ROOT . '/subfolder/test.txt.v' . $t1;
+		$v2 = self::USERS_VERSIONS_ROOT . '/subfolder/test.txt.v' . $t2;
+
+		$this->rootView->mkdir(self::USERS_VERSIONS_ROOT . '/subfolder/');
+
+		$this->rootView->file_put_contents($v1, 'version1');
+		$this->rootView->file_put_contents($v2, 'version2');
+
+		// execute copy hook of versions app
+		$versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '/subfolder/test.txt');
+
+		$this->assertSame(2, count($versions));
+
+		foreach ($versions as $version) {
+			$this->assertSame('/subfolder/test.txt', $version['path']);
+			$this->assertSame('test.txt', $version['name']);
+		}
+
+		//cleanup
+		$this->rootView->deleteAll(self::USERS_VERSIONS_ROOT . '/subfolder');
+	}
+
+	/**
 	 * @param string $user
 	 * @param bool $create
 	 * @param bool $password

-- 
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