summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/app/expected-info.json7
-rw-r--r--tests/lib/InstallerTest.php (renamed from tests/lib/installer.php)29
-rw-r--r--tests/lib/activity/managertest.php (renamed from tests/lib/activitymanager.php)32
-rw-r--r--tests/lib/archive/tar.php6
-rw-r--r--tests/lib/archive/zip.php6
-rw-r--r--tests/lib/log/owncloud.php15
-rw-r--r--tests/lib/logger.php15
-rw-r--r--tests/lib/server.php2
-rw-r--r--tests/lib/session/memory.php9
9 files changed, 83 insertions, 38 deletions
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json
index 51d0c00ccef..81de5341efa 100644
--- a/tests/data/app/expected-info.json
+++ b/tests/data/app/expected-info.json
@@ -69,8 +69,11 @@
}
},
"repair-steps": {
+ "install": [],
"pre-migration": [],
"post-migration": [],
- "live-migration": []
- }
+ "live-migration": [],
+ "uninstall": []
+ },
+ "background-jobs": []
}
diff --git a/tests/lib/installer.php b/tests/lib/InstallerTest.php
index ca210ba31ef..e1c17b841a2 100644
--- a/tests/lib/installer.php
+++ b/tests/lib/InstallerTest.php
@@ -6,7 +6,12 @@
* See the COPYING-README file.
*/
-class Test_Installer extends \Test\TestCase {
+namespace Test;
+
+
+use OC\Installer;
+
+class InstallerTest extends TestCase {
private static $appid = 'testapp';
private $appstore;
@@ -17,11 +22,11 @@ class Test_Installer extends \Test\TestCase {
$config = \OC::$server->getConfig();
$this->appstore = $config->setSystemValue('appstoreenabled', true);
$config->setSystemValue('appstoreenabled', true);
- OC_Installer::removeApp(self::$appid);
+ Installer::removeApp(self::$appid);
}
protected function tearDown() {
- OC_Installer::removeApp(self::$appid);
+ Installer::removeApp(self::$appid);
\OC::$server->getConfig()->setSystemValue('appstoreenabled', $this->appstore);
parent::tearDown();
@@ -33,7 +38,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfTestApp .= 'testapp.zip';
$tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
- OC_Helper::copyr($pathOfTestApp, $tmp);
+ \OC_Helper::copyr($pathOfTestApp, $tmp);
$data = array(
'path' => $tmp,
@@ -44,8 +49,8 @@ class Test_Installer extends \Test\TestCase {
]
);
- OC_Installer::installApp($data);
- $isInstalled = OC_Installer::isInstalled(self::$appid);
+ Installer::installApp($data);
+ $isInstalled = Installer::isInstalled(self::$appid);
$this->assertTrue($isInstalled);
}
@@ -56,7 +61,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfOldTestApp .= 'testapp.zip';
$oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
- OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
+ \OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
$oldData = array(
'path' => $oldTmp,
@@ -72,7 +77,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfNewTestApp .= 'testapp2.zip';
$newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
- OC_Helper::copyr($pathOfNewTestApp, $newTmp);
+ \OC_Helper::copyr($pathOfNewTestApp, $newTmp);
$newData = array(
'path' => $newTmp,
@@ -83,11 +88,11 @@ class Test_Installer extends \Test\TestCase {
]
);
- OC_Installer::installApp($oldData);
- $oldVersionNumber = OC_App::getAppVersion(self::$appid);
+ Installer::installApp($oldData);
+ $oldVersionNumber = \OC_App::getAppVersion(self::$appid);
- OC_Installer::updateApp($newData);
- $newVersionNumber = OC_App::getAppVersion(self::$appid);
+ Installer::updateApp($newData);
+ $newVersionNumber = \OC_App::getAppVersion(self::$appid);
$this->assertNotEquals($oldVersionNumber, $newVersionNumber);
}
diff --git a/tests/lib/activitymanager.php b/tests/lib/activity/managertest.php
index 26759d46270..cf855dd2813 100644
--- a/tests/lib/activitymanager.php
+++ b/tests/lib/activity/managertest.php
@@ -8,18 +8,22 @@
*
*/
-class Test_ActivityManager extends \Test\TestCase {
+namespace Test\Activity;
- /** @var \OC\ActivityManager */
+use Test\TestCase;
+
+class ManagerTest extends TestCase {
+
+ /** @var \OC\Activity\Manager */
private $activityManager;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
protected $request;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
protected $session;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config;
protected function setUp() {
@@ -35,7 +39,7 @@ class Test_ActivityManager extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $this->activityManager = new \OC\ActivityManager(
+ $this->activityManager = new \OC\Activity\Manager(
$this->request,
$this->session,
$this->config
@@ -71,7 +75,7 @@ class Test_ActivityManager extends \Test\TestCase {
*/
public function testGetConsumersInvalidConsumer() {
$this->activityManager->registerConsumer(function() {
- return new StdClass();
+ return new \stdClass();
});
$this->invokePrivate($this->activityManager, 'getConsumers');
@@ -88,7 +92,7 @@ class Test_ActivityManager extends \Test\TestCase {
*/
public function testGetExtensionsInvalidExtension() {
$this->activityManager->registerExtension(function() {
- return new StdClass();
+ return new \stdClass();
});
$this->invokePrivate($this->activityManager, 'getExtensions');
@@ -119,10 +123,10 @@ class Test_ActivityManager extends \Test\TestCase {
}
public function testTranslate() {
- $result = $this->activityManager->translate('APP0', '', '', array(), false, false, 'en');
+ $result = $this->activityManager->translate('APP0', '', array(), false, false, 'en');
$this->assertEquals('Stupid translation', $result);
- $result = $this->activityManager->translate('APP1', '', '', array(), false, false, 'en');
+ $result = $this->activityManager->translate('APP1', '', array(), false, false, 'en');
$this->assertFalse($result);
}
@@ -259,7 +263,7 @@ class Test_ActivityManager extends \Test\TestCase {
}
/**
- * @expectedException BadMethodCallException
+ * @expectedException \BadMethodCallException
* @expectedExceptionMessage App not set
* @expectedExceptionCode 10
*/
@@ -269,7 +273,7 @@ class Test_ActivityManager extends \Test\TestCase {
}
/**
- * @expectedException BadMethodCallException
+ * @expectedException \BadMethodCallException
* @expectedExceptionMessage Type not set
* @expectedExceptionCode 11
*/
@@ -280,7 +284,7 @@ class Test_ActivityManager extends \Test\TestCase {
}
/**
- * @expectedException BadMethodCallException
+ * @expectedException \BadMethodCallException
* @expectedExceptionMessage Affected user not set
* @expectedExceptionCode 12
*/
@@ -292,7 +296,7 @@ class Test_ActivityManager extends \Test\TestCase {
}
/**
- * @expectedException BadMethodCallException
+ * @expectedException \BadMethodCallException
* @expectedExceptionMessage Subject not set
* @expectedExceptionCode 13
*/
diff --git a/tests/lib/archive/tar.php b/tests/lib/archive/tar.php
index 43157e2054d..2d20bb4c3b1 100644
--- a/tests/lib/archive/tar.php
+++ b/tests/lib/archive/tar.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+use OC\Archive\TAR;
+
class Test_Archive_TAR extends Test_Archive {
protected function setUp() {
parent::setUp();
@@ -17,10 +19,10 @@ class Test_Archive_TAR extends Test_Archive {
protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data';
- return new OC_Archive_TAR($dir . '/data.tar.gz');
+ return new TAR($dir . '/data.tar.gz');
}
protected function getNew() {
- return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz'));
+ return new TAR(OCP\Files::tmpFile('.tar.gz'));
}
}
diff --git a/tests/lib/archive/zip.php b/tests/lib/archive/zip.php
index 09ea5d7d27c..2f4c9cace1d 100644
--- a/tests/lib/archive/zip.php
+++ b/tests/lib/archive/zip.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+use OC\Archive\ZIP;
+
class Test_Archive_ZIP extends Test_Archive {
protected function setUp() {
parent::setUp();
@@ -17,10 +19,10 @@ class Test_Archive_ZIP extends Test_Archive {
protected function getExisting() {
$dir = OC::$SERVERROOT . '/tests/data';
- return new OC_Archive_ZIP($dir . '/data.zip');
+ return new ZIP($dir . '/data.zip');
}
protected function getNew() {
- return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip'));
+ return new ZIP(OCP\Files::tmpFile('.zip'));
}
}
diff --git a/tests/lib/log/owncloud.php b/tests/lib/log/owncloud.php
index adecc49768c..e19063a83f5 100644
--- a/tests/lib/log/owncloud.php
+++ b/tests/lib/log/owncloud.php
@@ -15,12 +15,17 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+namespace Test\Log;
+
+use OC\Log\Owncloud;
+use Test\TestCase;
+
/**
- * Class Test_Log_Owncloud
+ * Class OwncloudTest
*
* @group DB
*/
-class Test_Log_Owncloud extends Test\TestCase
+class OwncloudTest extends TestCase
{
private $restore_logfile;
private $restore_logdateformat;
@@ -32,7 +37,7 @@ class Test_Log_Owncloud extends Test\TestCase
$this->restore_logdateformat = $config->getSystemValue('logdateformat');
$config->setSystemValue("logfile", $config->getSystemValue('datadirectory') . "/logtest");
- OC_Log_Owncloud::init();
+ Owncloud::init();
}
protected function tearDown() {
$config = \OC::$server->getConfig();
@@ -46,7 +51,7 @@ class Test_Log_Owncloud extends Test\TestCase
} else {
$config->deleteSystemValue("restore_logdateformat");
}
- OC_Log_Owncloud::init();
+ Owncloud::init();
parent::tearDown();
}
@@ -57,7 +62,7 @@ class Test_Log_Owncloud extends Test\TestCase
# set format & write log line
$config->setSystemValue('logdateformat', 'u');
- OC_Log_Owncloud::write('test', 'message', \OCP\Util::ERROR);
+ Owncloud::write('test', 'message', \OCP\Util::ERROR);
# read log line
$handle = @fopen($config->getSystemValue('logfile'), 'r');
diff --git a/tests/lib/logger.php b/tests/lib/logger.php
index 9c9cd9e6728..e6a0abfbf28 100644
--- a/tests/lib/logger.php
+++ b/tests/lib/logger.php
@@ -107,4 +107,19 @@ class Logger extends TestCase {
$this->assertContains('checkPassword(*** username and password replaced ***)', $logLine);
}
}
+
+ /**
+ * @dataProvider userAndPasswordData
+ */
+ public function testDetectvalidateUserPass($user, $password) {
+ $e = new \Exception('test');
+ $this->logger->logException($e);
+ $logLines = $this->getLogs();
+
+ foreach($logLines as $logLine) {
+ $this->assertNotContains($user, $logLine);
+ $this->assertNotContains($password, $logLine);
+ $this->assertContains('validateUserPass(*** username and password replaced ***)', $logLine);
+ }
+ }
}
diff --git a/tests/lib/server.php b/tests/lib/server.php
index d13f9be0c9e..fe3c6fd5ee8 100644
--- a/tests/lib/server.php
+++ b/tests/lib/server.php
@@ -44,7 +44,7 @@ class Server extends \Test\TestCase {
public function dataTestQuery() {
return [
- ['ActivityManager', '\OC\ActivityManager'],
+ ['ActivityManager', '\OC\Activity\Manager'],
['ActivityManager', '\OCP\Activity\IManager'],
['AllConfig', '\OC\AllConfig'],
['AllConfig', '\OCP\IConfig'],
diff --git a/tests/lib/session/memory.php b/tests/lib/session/memory.php
index 1ca4956c6ea..dbf2737fb3f 100644
--- a/tests/lib/session/memory.php
+++ b/tests/lib/session/memory.php
@@ -10,8 +10,17 @@
namespace Test\Session;
class Memory extends Session {
+
protected function setUp() {
parent::setUp();
$this->instance = new \OC\Session\Memory($this->getUniqueID());
}
+
+ /**
+ * @expectedException OCP\Session\Exceptions\SessionNotAvailableException
+ */
+ public function testThrowsExceptionOnGetId() {
+ $this->instance->getId();
+ }
+
}