diff options
Diffstat (limited to 'apps/files_encryption/tests/stream.php')
-rw-r--r-- | apps/files_encryption/tests/stream.php | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index c3f777df859..b1404ca282a 100644 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -20,15 +20,13 @@ * */ -require_once __DIR__ . '/util.php'; - use OCA\Encryption; /** * Class Test_Encryption_Stream * this class provide basic stream tests */ -class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { +class Test_Encryption_Stream extends \OCA\Files_Encryption\Tests\TestCase { const TEST_ENCRYPTION_STREAM_USER1 = "test-stream-user1"; @@ -42,6 +40,8 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { public $stateFilesTrashbin; public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); @@ -54,10 +54,12 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { \OC_FileProxy::register(new OCA\Encryption\Proxy()); // create test user - \Test_Encryption_Util::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true); + self::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true); } - function setUp() { + protected function setUp() { + parent::setUp(); + // set user id \OC_User::setUserId(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1); $this->userId = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; @@ -76,7 +78,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { \OC_App::disable('files_trashbin'); } - function tearDown() { + protected function tearDown() { // reset app files_trashbin if ($this->stateFilesTrashbin) { OC_App::enable('files_trashbin'); @@ -84,6 +86,8 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { else { OC_App::disable('files_trashbin'); } + + parent::tearDown(); } public static function tearDownAfterClass() { @@ -97,10 +101,12 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { $view = new \OC\Files\View('/'); $view->rmdir('public-keys'); $view->rmdir('owncloud_private_key'); + + parent::tearDownAfterClass(); } function testStreamOptions() { - $filename = '/tmp-' . uniqid(); + $filename = '/tmp-' . $this->getUniqueID(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -118,12 +124,14 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { $this->assertTrue(flock($handle, LOCK_SH)); $this->assertTrue(flock($handle, LOCK_UN)); + fclose($handle); + // tear down $view->unlink($filename); } function testStreamSetBlocking() { - $filename = '/tmp-' . uniqid(); + $filename = '/tmp-' . $this->getUniqueID(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -154,7 +162,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { * @medium */ function testStreamSetTimeout() { - $filename = '/tmp-' . uniqid(); + $filename = '/tmp-' . $this->getUniqueID(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -175,7 +183,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { } function testStreamSetWriteBuffer() { - $filename = '/tmp-' . uniqid(); + $filename = '/tmp-' . $this->getUniqueID(); $view = new \OC\Files\View('/' . $this->userId . '/files'); // Save short data as encrypted file using stream wrapper @@ -201,9 +209,9 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { */ function testStreamFromLocalFile() { - $filename = '/' . $this->userId . '/files/' . 'tmp-' . uniqid().'.txt'; + $filename = '/' . $this->userId . '/files/' . 'tmp-' . $this->getUniqueID().'.txt'; - $tmpFilename = "/tmp/" . uniqid() . ".txt"; + $tmpFilename = "/tmp/" . $this->getUniqueID() . ".txt"; // write an encrypted file $cryptedFile = $this->view->file_put_contents($filename, $this->dataShort); @@ -228,6 +236,8 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase { // check if it was successful $this->assertEquals($this->dataShort, $contentFromTmpFile); + fclose($handle); + // clean up unlink($tmpFilename); $this->view->unlink($filename); |