]> source.dussan.org Git - nextcloud-server.git/commitdiff
improved unit tests
authorBjoern Schiessle <schiessle@owncloud.com>
Fri, 4 Jul 2014 15:37:35 +0000 (17:37 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Fri, 4 Jul 2014 15:37:35 +0000 (17:37 +0200)
apps/files_encryption/tests/proxy.php

index 8d6bc81b08d217b03e61ca09cb7cf62fa78f8469..9ec1f940edd9685ef5c251422b9de855d5947178 100644 (file)
@@ -47,6 +47,7 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
        public $view;     // view in /data/user/files
        public $rootView; // view on /data/user
        public $data;
+       public $dataLong;
        public $filename;
 
        public static function setUpBeforeClass() {
@@ -80,6 +81,7 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
 
                // init short data
                $this->data = 'hats';
+               $this->dataLong = file_get_contents(__DIR__ . '/../lib/crypt.php');
                $this->filename = 'enc_proxy_tests-' . uniqid() . '.txt';
 
        }
@@ -95,17 +97,19 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase {
         */
        function testPostFileSize() {
 
-               $this->view->file_put_contents($this->filename, $this->data);
+               $this->view->file_put_contents($this->filename, $this->dataLong);
+               $size = strlen($this->dataLong);
 
                \OC_FileProxy::$enabled = false;
 
-               $unencryptedSize = $this->view->filesize($this->filename);
+               $encryptedSize = $this->view->filesize($this->filename);
 
                \OC_FileProxy::$enabled = true;
 
-               $encryptedSize = $this->view->filesize($this->filename);
+               $unencryptedSize = $this->view->filesize($this->filename);
 
-               $this->assertTrue($encryptedSize !== $unencryptedSize);
+               $this->assertTrue($encryptedSize > $unencryptedSize);
+               $this->assertSame($size, $unencryptedSize);
 
                // cleanup
                $this->view->unlink($this->filename);