From 5d0451b84862c2c905b7d1a8d5943ac53d87f990 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 2 Dec 2015 14:49:27 +0100 Subject: [PATCH] Safe teardowns --- apps/files_sharing/tests/backend.php | 6 ++++-- apps/files_sharing/tests/external/cache.php | 4 +++- apps/files_sharing/tests/sharedmount.php | 6 ++++-- apps/files_sharing/tests/updater.php | 6 ++++-- apps/files_sharing/tests/watcher.php | 12 +++++++----- apps/files_versions/tests/versions.php | 10 ++++++---- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/apps/files_sharing/tests/backend.php b/apps/files_sharing/tests/backend.php index 0e151d9e76..acb5985539 100644 --- a/apps/files_sharing/tests/backend.php +++ b/apps/files_sharing/tests/backend.php @@ -58,8 +58,10 @@ class Test_Files_Sharing_Backend extends TestCase { } protected function tearDown() { - $this->view->unlink($this->filename); - $this->view->deleteAll($this->folder); + if ($this->view) { + $this->view->unlink($this->filename); + $this->view->deleteAll($this->folder); + } parent::tearDown(); } diff --git a/apps/files_sharing/tests/external/cache.php b/apps/files_sharing/tests/external/cache.php index 52e01677fa..3e078bf372 100644 --- a/apps/files_sharing/tests/external/cache.php +++ b/apps/files_sharing/tests/external/cache.php @@ -75,7 +75,9 @@ class Cache extends TestCase { } protected function tearDown() { - $this->cache->clear(); + if ($this->cache) { + $this->cache->clear(); + } parent::tearDown(); } diff --git a/apps/files_sharing/tests/sharedmount.php b/apps/files_sharing/tests/sharedmount.php index 347ec0d2a7..e01deeb60f 100644 --- a/apps/files_sharing/tests/sharedmount.php +++ b/apps/files_sharing/tests/sharedmount.php @@ -48,8 +48,10 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase { } protected function tearDown() { - $this->view->unlink($this->folder); - $this->view->unlink($this->filename); + if ($this->view) { + $this->view->unlink($this->folder); + $this->view->unlink($this->filename); + } parent::tearDown(); } diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php index 02c5f487e0..dd1f83c99a 100644 --- a/apps/files_sharing/tests/updater.php +++ b/apps/files_sharing/tests/updater.php @@ -52,8 +52,10 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase { } protected function tearDown() { - $this->view->unlink($this->filename); - $this->view->deleteAll($this->folder); + if ($this->view) { + $this->view->unlink($this->filename); + $this->view->deleteAll($this->folder); + } parent::tearDown(); } diff --git a/apps/files_sharing/tests/watcher.php b/apps/files_sharing/tests/watcher.php index 021f10bacc..247fb59f35 100644 --- a/apps/files_sharing/tests/watcher.php +++ b/apps/files_sharing/tests/watcher.php @@ -88,13 +88,15 @@ class Test_Files_Sharing_Watcher extends OCA\Files_sharing\Tests\TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $fileinfo = $this->view->getFileInfo('container/shareddir'); - \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, - self::TEST_FILES_SHARING_API_USER2); + if ($this->view) { + $fileinfo = $this->view->getFileInfo('container/shareddir'); + \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, + self::TEST_FILES_SHARING_API_USER2); - $this->view->deleteAll('container'); + $this->view->deleteAll('container'); - $this->ownerCache->clear(); + $this->ownerCache->clear(); + } parent::tearDown(); } diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php index 74d6006cfd..ac922b74b9 100644 --- a/apps/files_versions/tests/versions.php +++ b/apps/files_versions/tests/versions.php @@ -86,10 +86,12 @@ class Test_Files_Versioning extends \Test\TestCase { } protected function tearDown() { - $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/'); - $this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files/'); - $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files_versions/'); - $this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files_versions/'); + if ($this->rootView) { + $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/'); + $this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files/'); + $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files_versions/'); + $this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files_versions/'); + } \OC_Hook::clear();