summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-01-25 14:50:46 +0100
committerGitHub <noreply@github.com>2018-01-25 14:50:46 +0100
commit8160d0bc2aa334806e6c6e45e4f49bd9cf1a8097 (patch)
tree38a85a16e46ab97f9f8ab4afc3afbd596ce7fb24 /tests
parentfe88e7f9264e3826e7efeb7144eb8ce0267cefe8 (diff)
parent4718d2b80d88170f3814d3f7795bda9557ef12ac (diff)
downloadnextcloud-server-8160d0bc2aa334806e6c6e45e4f49bd9cf1a8097.tar.gz
nextcloud-server-8160d0bc2aa334806e6c6e45e4f49bd9cf1a8097.zip
Merge pull request #8036 from nextcloud/phpunit6
Require PHPUnit 6.5 or higher
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Activity/SecurityProviderTest.php2
-rw-r--r--tests/bootstrap.php4
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php17
-rw-r--r--tests/lib/AppFramework/Db/MapperTest.php16
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php4
-rw-r--r--tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php4
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php3
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php8
-rw-r--r--tests/lib/Authentication/LoginCredentials/StoreTest.php1
-rw-r--r--tests/lib/Contacts/ContactsMenu/EntryTest.php4
-rw-r--r--tests/lib/DB/ConnectionTest.php6
-rw-r--r--tests/lib/DB/DBSchemaTest.php2
-rw-r--r--tests/lib/DB/MDB2SchemaManagerTest.php2
-rw-r--r--tests/lib/DB/MigratorTest.php10
-rw-r--r--tests/lib/DB/MySqlMigrationTest.php2
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php4
-rw-r--r--tests/lib/DB/SqliteMigrationTest.php2
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php8
-rw-r--r--tests/lib/Federation/CloudIdTest.php4
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php2
-rw-r--r--tests/lib/Files/PathVerificationTest.php4
-rw-r--r--tests/lib/Files/Storage/LocalTest.php1
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php16
-rw-r--r--tests/lib/Group/Backend.php2
-rw-r--r--tests/lib/Hooks/BasicEmitterTest.php18
-rw-r--r--tests/lib/InfoXmlTest.php2
-rw-r--r--tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php1
-rw-r--r--tests/lib/L10N/FactoryTest.php2
-rw-r--r--tests/lib/Notification/NotificationTest.php4
-rw-r--r--tests/lib/RichObjectStrings/ValidatorTest.php1
-rw-r--r--tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php1
-rw-r--r--tests/lib/Share20/ManagerTest.php11
-rw-r--r--tests/lib/Support/CrashReport/RegistryTest.php1
-rw-r--r--tests/lib/Template/CSSResourceLocatorTest.php3
-rw-r--r--tests/lib/TestCase.php24
-rw-r--r--tests/lib/User/ManagerTest.php2
-rw-r--r--tests/startsessionlistener.php40
39 files changed, 115 insertions, 131 deletions
diff --git a/tests/Settings/Activity/SecurityProviderTest.php b/tests/Settings/Activity/SecurityProviderTest.php
index 552548984d7..0623779735b 100644
--- a/tests/Settings/Activity/SecurityProviderTest.php
+++ b/tests/Settings/Activity/SecurityProviderTest.php
@@ -62,7 +62,7 @@ class SecurityProviderTest extends TestCase {
$event->expects($this->once())
->method('getType')
->willReturn('comments');
- $this->setExpectedException(InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$this->provider->parse($lang, $event);
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 44c42d353e9..a1bc26bbf0e 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -14,10 +14,6 @@ require_once __DIR__ . '/../lib/base.php';
// load all enabled apps
\OC_App::loadApps();
-if (!class_exists('PHPUnit_Framework_TestCase')) {
- require_once('PHPUnit/Autoload.php');
-}
-
OC_Hook::clear();
set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/php');
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index e1a3d7533be..c9a90da7c59 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -46,7 +46,7 @@ class TestEntity extends Entity {
protected $preName;
public function __construct($name=null){
- $this->addType('testId', 'integer');
+ $this->addType('testId', 'integer');
$this->name = $name;
}
};
@@ -119,23 +119,26 @@ class EntityTest extends \Test\TestCase {
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testCallShouldOnlyWorkForGetterSetter(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->something();
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testGetterShouldFailIfAttributeNotDefined(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->getTest();
}
+ /**
+ * @expectedException \BadFunctionCallException
+ */
public function testSetterShouldFailIfAttributeNotDefined(){
- $this->setExpectedException('\BadFunctionCallException');
-
$this->entity->setTest();
}
diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php
index 108e4eee28e..990391a1de1 100644
--- a/tests/lib/AppFramework/Db/MapperTest.php
+++ b/tests/lib/AppFramework/Db/MapperTest.php
@@ -24,6 +24,8 @@
namespace Test\AppFramework\Db;
+use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use \OCP\IDBConnection;
use \OCP\AppFramework\Db\Entity;
use \OCP\AppFramework\Db\Mapper;
@@ -95,8 +97,7 @@ class MapperTest extends MapperTestUtility {
$params = array('jo');
$rows = array();
$this->setMapperResult($sql, $params, $rows);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\DoesNotExistException');
+ $this->expectException(DoesNotExistException::class);
$this->mapper->find($sql, $params);
}
@@ -105,8 +106,7 @@ class MapperTest extends MapperTestUtility {
$params = array('jo');
$rows = array();
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\DoesNotExistException');
+ $this->expectException(DoesNotExistException::class);
$this->mapper->findOneEntity($sql, $params);
}
@@ -117,8 +117,7 @@ class MapperTest extends MapperTestUtility {
array('jo'), array('ho')
);
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->expectException(MultipleObjectsReturnedException::class);
$this->mapper->find($sql, $params);
}
@@ -129,8 +128,7 @@ class MapperTest extends MapperTestUtility {
array('jo'), array('ho')
);
$this->setMapperResult($sql, $params, $rows, null, null, true);
- $this->setExpectedException(
- '\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->expectException(MultipleObjectsReturnedException::class);
$this->mapper->findOneEntity($sql, $params);
}
@@ -223,7 +221,7 @@ class MapperTest extends MapperTestUtility {
$entity->setPreName($params[0]);
$entity->setEmail($params[1]);
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->mapper->update($entity);
}
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index eb08d00e358..95fa3c2a047 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -267,7 +267,7 @@ class DispatcherTest extends \Test\TestCase {
$responseHeaders = array('hell' => 'yeah');
$this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders, true, false);
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$response = $this->dispatcher->dispatch($this->controller,
$this->controllerMethod);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index e71be9c5f16..b2f78c17fe6 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -177,7 +177,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
$this->dispatcher->registerMiddleware($m1);
$this->dispatcher->registerMiddleware($m2);
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
}
@@ -206,7 +206,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
public function testAfterExceptionCorrectArguments(){
$m1 = $this->getMiddleware();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
@@ -253,7 +253,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
$m1 = $this->getMiddleware();
$m2 = $this->getMiddleware();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->dispatcher->beforeController($this->controller, $this->method);
$this->dispatcher->afterException($this->controller, $this->method, $this->exception);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index 07028745676..038bec25148 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -75,8 +75,8 @@ class MiddlewareTest extends \Test\TestCase {
public function testAfterExceptionRaiseAgainWhenUnhandled() {
- $this->setExpectedException('Exception');
- $afterEx = $this->middleware->afterException($this->controller, null, $this->exception);
+ $this->expectException(\Exception::class);
+ $this->middleware->afterException($this->controller, null, $this->exception);
}
diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
index 2c610736f4a..95729e286f9 100644
--- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
@@ -89,7 +89,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
/**
* @PasswordConfirmationRequired
- * @dataProvider testProvider
+ * @dataProvider dataProvider
*/
public function testAnnotation($backend, $lastConfirm, $currentTime, $exception) {
$this->reflector->reflect(__CLASS__, __FUNCTION__);
@@ -116,7 +116,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
$this->assertSame($exception, $thrown);
}
- public function testProvider() {
+ public function dataProvider() {
return [
['foo', 2000, 4000, true],
['foo', 2000, 3000, false],
diff --git a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
index bd1568bcd6b..7784f55e84a 100644
--- a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
@@ -55,6 +55,7 @@ class SameSiteCookieMiddlewareTest extends TestCase {
->willReturn('/ocs/v2.php');
$this->middleware->beforeController($this->createMock(Controller::class), 'foo');
+ $this->addToAssertionCount(1);
}
public function testBeforeControllerIndexHasAnnotation() {
@@ -66,6 +67,7 @@ class SameSiteCookieMiddlewareTest extends TestCase {
->willReturn(true);
$this->middleware->beforeController($this->createMock(Controller::class), 'foo');
+ $this->addToAssertionCount(1);
}
public function testBeforeControllerIndexNoAnnotationPassingCheck() {
@@ -80,6 +82,7 @@ class SameSiteCookieMiddlewareTest extends TestCase {
->willReturn(true);
$this->middleware->beforeController($this->createMock(Controller::class), 'foo');
+ $this->addToAssertionCount(1);
}
public function testBeforeControllerIndexNoAnnotationFailingCheck() {
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 0d7418673dd..b68f0cb1981 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -168,7 +168,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
// add assertion if everything should work fine otherwise phpunit will
// complain
if ($status === 0) {
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
@@ -263,9 +263,9 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$sec = $this->getMiddleware($isLoggedIn, $isAdminUser);
if($shouldFail) {
- $this->setExpectedException('\OC\AppFramework\Middleware\Security\Exceptions\SecurityException');
+ $this->expectException(SecurityException::class);
} else {
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
$this->reader->reflect(__CLASS__, $method);
@@ -454,7 +454,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
public function testAfterExceptionNotCaughtThrowsItAgain(){
$ex = new \Exception();
- $this->setExpectedException('\Exception');
+ $this->expectException(\Exception::class);
$this->middleware->afterException($this->controller, 'test', $ex);
}
diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php
index 9a719339b43..4588eae35f0 100644
--- a/tests/lib/Authentication/LoginCredentials/StoreTest.php
+++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php
@@ -79,6 +79,7 @@ class StoreTest extends TestCase {
$session = $this->createMock(ISession::class);
$this->store->setSession($session);
+ $this->addToAssertionCount(1);
}
public function testGetLoginCredentialsNoTokenProvider() {
diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php
index ddc6cc916d7..e28248fb0fb 100644
--- a/tests/lib/Contacts/ContactsMenu/EntryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php
@@ -26,10 +26,9 @@ namespace Tests\Contacts\ContactsMenu;
use OC\Contacts\ContactsMenu\Actions\LinkAction;
use OC\Contacts\ContactsMenu\Entry;
-use OCP\Contacts\ContactsMenu\IAction;
use Test\TestCase;
-class EntryTest extends \PHPUnit_Framework_TestCase {
+class EntryTest extends TestCase {
/** @var Entry */
private $entry;
@@ -42,6 +41,7 @@ class EntryTest extends \PHPUnit_Framework_TestCase {
public function testSetId() {
$this->entry->setId(123);
+ $this->addToAssertionCount(1);
}
public function testSetGetFullName() {
diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php
index 2a0cd70f83a..3a4a80bdbd9 100644
--- a/tests/lib/DB/ConnectionTest.php
+++ b/tests/lib/DB/ConnectionTest.php
@@ -58,7 +58,7 @@ class ConnectionTest extends \Test\TestCase {
public function assertTableExist($table) {
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
// sqlite removes the tables after closing the DB
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
} else {
$this->assertTrue($this->connection->tableExists($table), 'Table ' . $table . ' exists.');
}
@@ -70,7 +70,7 @@ class ConnectionTest extends \Test\TestCase {
public function assertTableNotExist($table) {
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
// sqlite removes the tables after closing the DB
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
} else {
$this->assertFalse($this->connection->tableExists($table), 'Table ' . $table . " doesn't exist.");
}
@@ -195,5 +195,7 @@ class ConnectionTest extends \Test\TestCase {
], [
'textfield' => 'foo'
]);
+
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php
index 8eb7fcf81b4..cc6059c163f 100644
--- a/tests/lib/DB/DBSchemaTest.php
+++ b/tests/lib/DB/DBSchemaTest.php
@@ -107,7 +107,7 @@ class DBSchemaTest extends TestCase {
$platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
if ($platform instanceof SqlitePlatform) {
// sqlite removes the tables after closing the DB
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
} else {
$this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.');
}
diff --git a/tests/lib/DB/MDB2SchemaManagerTest.php b/tests/lib/DB/MDB2SchemaManagerTest.php
index 93078b4f722..75572bb36a5 100644
--- a/tests/lib/DB/MDB2SchemaManagerTest.php
+++ b/tests/lib/DB/MDB2SchemaManagerTest.php
@@ -46,7 +46,7 @@ class MDB2SchemaManagerTest extends \Test\TestCase {
$connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
$manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index ea718240c5e..9dfed5ecd1a 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -132,7 +132,7 @@ class MigratorTest extends \Test\TestCase {
$migrator->checkMigrate($endSchema);
$migrator->migrate($endSchema);
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testUpgradeDifferentPrefix() {
@@ -151,7 +151,7 @@ class MigratorTest extends \Test\TestCase {
$migrator->checkMigrate($endSchema);
$migrator->migrate($endSchema);
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
$this->config->setSystemValue('dbtableprefix', $oldTablePrefix);
}
@@ -169,7 +169,7 @@ class MigratorTest extends \Test\TestCase {
$this->connection->insert($this->tableName, array('id' => 2, 'name' => 'qwerty'));
$this->fail('Expected duplicate key insert to fail');
} catch (DBALException $e) {
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
@@ -191,7 +191,7 @@ class MigratorTest extends \Test\TestCase {
$migrator->checkMigrate($endSchema);
$migrator->migrate($endSchema);
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testReservedKeywords() {
@@ -213,7 +213,7 @@ class MigratorTest extends \Test\TestCase {
$migrator->checkMigrate($endSchema);
$migrator->migrate($endSchema);
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testAddingForeignKey() {
diff --git a/tests/lib/DB/MySqlMigrationTest.php b/tests/lib/DB/MySqlMigrationTest.php
index cdc7ef47784..3bbe89fe025 100644
--- a/tests/lib/DB/MySqlMigrationTest.php
+++ b/tests/lib/DB/MySqlMigrationTest.php
@@ -43,7 +43,7 @@ class MySqlMigrationTest extends \Test\TestCase {
$manager = new \OC\DB\MDB2SchemaManager($this->connection);
$manager->updateDbFromStructure(__DIR__ . '/testschema.xml');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
index e264fde6ec7..fa1c4add0ab 100644
--- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
@@ -1137,7 +1137,7 @@ class QueryBuilderTest extends \Test\TestCase {
$qB->getLastInsertId();
$this->fail('getLastInsertId() should throw an exception, when being called before insert()');
} catch (\BadMethodCallException $e) {
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
$qB->insert('properties')
@@ -1163,7 +1163,7 @@ class QueryBuilderTest extends \Test\TestCase {
$qB->getLastInsertId();
$this->fail('getLastInsertId() should throw an exception, when being called after delete()');
} catch (\BadMethodCallException $e) {
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/DB/SqliteMigrationTest.php b/tests/lib/DB/SqliteMigrationTest.php
index 76002e1afce..4712fc6d70b 100644
--- a/tests/lib/DB/SqliteMigrationTest.php
+++ b/tests/lib/DB/SqliteMigrationTest.php
@@ -43,7 +43,7 @@ class SqliteMigrationTest extends \Test\TestCase {
$manager = new \OC\DB\MDB2SchemaManager($this->connection);
$manager->updateDbFromStructure(__DIR__ . '/testschema.xml');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 06c5e0e2df8..59c24fb3c1d 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -34,6 +34,7 @@ use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -300,8 +301,11 @@ class DecryptAllTest extends TestCase {
->method('decryptFile')
->with('/user1/files/foo/subfile');
- $progressBar = $this->getMockBuilder(ProgressBar::class)
- ->disableOriginalConstructor()->getMock();
+ $output = $this->createMock(OutputInterface::class);
+ $output->expects($this->any())
+ ->method('getFormatter')
+ ->willReturn($this->createMock(OutputFormatterInterface::class));
+ $progressBar = new ProgressBar($output);
$this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']);
diff --git a/tests/lib/Federation/CloudIdTest.php b/tests/lib/Federation/CloudIdTest.php
index 7a6e841fb34..feb4108efe5 100644
--- a/tests/lib/Federation/CloudIdTest.php
+++ b/tests/lib/Federation/CloudIdTest.php
@@ -25,7 +25,7 @@ use OC\Federation\CloudId;
use Test\TestCase;
class CloudIdTest extends TestCase {
- public function testGetDisplayCloudIdProvider() {
+ public function dataGetDisplayCloudId() {
return [
['test@example.com', 'test@example.com'],
['test@http://example.com', 'test@example.com'],
@@ -34,7 +34,7 @@ class CloudIdTest extends TestCase {
}
/**
- * @dataProvider testGetDisplayCloudIdProvider
+ * @dataProvider dataGetDisplayCloudId
*
* @param string $id
* @param string $display
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index f26e3a59f1c..365049c1cc6 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -79,7 +79,7 @@ class CacheJailTest extends CacheTest {
function testGetIncomplete() {
//not supported
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
function testMoveFromJail() {
diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php
index c1cebe975fd..7e0b7dd2650 100644
--- a/tests/lib/Files/PathVerificationTest.php
+++ b/tests/lib/Files/PathVerificationTest.php
@@ -87,6 +87,8 @@ class PathVerificationTest extends \Test\TestCase {
if (!$connection->supports4ByteText()) {
$this->expectException(InvalidPathException::class);
$this->expectExceptionMessage('File name contains at least one invalid character');
+ } else {
+ $this->addToAssertionCount(1);
}
$this->view->verifyPath('', $fileName);
@@ -161,7 +163,7 @@ class PathVerificationTest extends \Test\TestCase {
self::invokePrivate($storage, 'verifyPosixPath', [$fileName]);
// nothing thrown
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function providesValidPosixPaths() {
diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php
index 89dd2f0786f..f17933413a5 100644
--- a/tests/lib/Files/Storage/LocalTest.php
+++ b/tests/lib/Files/Storage/LocalTest.php
@@ -106,6 +106,7 @@ class LocalTest extends Storage {
$storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]);
$storage->file_put_contents('sym/foo', 'bar');
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index c184752ff7e..5bcff56e373 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -719,9 +719,7 @@ class EncryptionTest extends Storage {
}
public function testCopyBetweenStorageMinimumEncryptedVersion() {
- $storage2 = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $storage2 = $this->createMock(\OC\Files\Storage\Storage::class);
$sourceInternalPath = $targetInternalPath = 'file.txt';
$preserveMtime = $isRename = false;
@@ -768,9 +766,7 @@ class EncryptionTest extends Storage {
* @param bool $expectedEncrypted
*/
public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) {
- $storage2 = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $storage2 = $this->createMock(\OC\Files\Storage\Storage::class);
$sourceInternalPath = $targetInternalPath = 'file.txt';
$preserveMtime = $isRename = false;
@@ -830,13 +826,9 @@ class EncryptionTest extends Storage {
*/
public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) {
- $sourceStorage = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $sourceStorage = $this->createMock(\OC\Files\Storage\Storage::class);
- $targetStorage = $this->getMockBuilder(Storage::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $targetStorage = $this->createMock(\OC\Files\Storage\Storage::class);
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Group/Backend.php b/tests/lib/Group/Backend.php
index eb17e9bded7..f702d94b2b4 100644
--- a/tests/lib/Group/Backend.php
+++ b/tests/lib/Group/Backend.php
@@ -157,5 +157,7 @@ abstract class Backend extends \Test\TestCase {
$this->backend->createGroup($group);
$this->backend->createGroup($group);
+
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php
index 2e6bd8100e3..7b71bb8259e 100644
--- a/tests/lib/Hooks/BasicEmitterTest.php
+++ b/tests/lib/Hooks/BasicEmitterTest.php
@@ -157,7 +157,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->removeListener('Test', 'test', $listener);
$this->emitter->emitEvent('Test', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testRemoveWildcardListener() {
@@ -172,7 +172,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->removeListener('Test', 'test');
$this->emitter->emitEvent('Test', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testRemoveWildcardMethod() {
@@ -185,7 +185,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->emitEvent('Test', 'test');
$this->emitter->emitEvent('Test', 'foo');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testRemoveWildcardScope() {
@@ -198,7 +198,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->emitEvent('Test', 'test');
$this->emitter->emitEvent('Bar', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
public function testRemoveWildcardScopeAndMethod() {
@@ -213,7 +213,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->emitEvent('Test', 'foo');
$this->emitter->emitEvent('Bar', 'foo');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
/**
@@ -231,7 +231,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->removeListener('Test', 'test', $listener1);
$this->emitter->emitEvent('Test', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
/**
@@ -246,7 +246,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->removeListener('Test', 'foo', $listener);
$this->emitter->emitEvent('Test', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
/**
@@ -261,7 +261,7 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->removeListener('Bar', 'test', $listener);
$this->emitter->emitEvent('Test', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
/**
@@ -275,6 +275,6 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->removeListener('Bar', 'test', $listener);
$this->emitter->emitEvent('Test', 'test');
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php
index 18391a20c03..3d740cd39dd 100644
--- a/tests/lib/InfoXmlTest.php
+++ b/tests/lib/InfoXmlTest.php
@@ -67,8 +67,10 @@ class InfoXmlTest extends TestCase {
$applicationClassName = \OCP\AppFramework\App::buildAppNamespace($app) . '\\AppInfo\\Application';
if (class_exists($applicationClassName)) {
$application = new $applicationClassName();
+ $this->addToAssertionCount(1);
} else {
$application = new \OCP\AppFramework\App($app);
+ $this->addToAssertionCount(1);
}
if (isset($appInfo['background-jobs'])) {
diff --git a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
index de4aeec78cc..4e581c0f2e2 100644
--- a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
@@ -64,5 +64,6 @@ class FileAccessHelperTest extends TestCase {
public function testAssertDirectoryExists() {
$this->fileAccessHelper->assertDirectoryExists(\OC::$server->getTempManager()->getTemporaryFolder('/testfolder/'));
+ $this->addToAssertionCount(1);
}
}
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index 4f31784337a..1e5c2ef5421 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -392,7 +392,7 @@ class FactoryTest extends TestCase {
->willReturn($header);
if ($expected instanceof LanguageNotFoundException) {
- $this->setExpectedException(LanguageNotFoundException::class);
+ $this->expectException(LanguageNotFoundException::class);
self::invokePrivate($factory, 'getLanguageFromRequest', [$app]);
} else {
$this->assertSame($expected, self::invokePrivate($factory, 'getLanguageFromRequest', [$app]), 'Asserting returned language');
diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php
index eabed273608..5aa24fc762a 100644
--- a/tests/lib/Notification/NotificationTest.php
+++ b/tests/lib/Notification/NotificationTest.php
@@ -466,7 +466,7 @@ class NotificationTest extends TestCase {
$this->assertSame($this->notification, $this->notification->addAction($action));
- $this->setExpectedException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->notification->addAction($action);
}
@@ -512,7 +512,7 @@ class NotificationTest extends TestCase {
$this->assertSame($this->notification, $this->notification->addParsedAction($action));
- $this->setExpectedException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->notification->addParsedAction($action);
}
diff --git a/tests/lib/RichObjectStrings/ValidatorTest.php b/tests/lib/RichObjectStrings/ValidatorTest.php
index f18d1bdd908..0c344248f77 100644
--- a/tests/lib/RichObjectStrings/ValidatorTest.php
+++ b/tests/lib/RichObjectStrings/ValidatorTest.php
@@ -49,6 +49,7 @@ class ValidatorTest extends TestCase {
'path' => 'path/to/test.txt',
],
]);
+ $this->addToAssertionCount(2);
}
}
diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
index f0fb1610d98..25c92571441 100644
--- a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
+++ b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
@@ -35,6 +35,7 @@ class ContentSecurityPolicyManagerTest extends \Test\TestCase {
public function testAddDefaultPolicy() {
$this->contentSecurityPolicyManager->addDefaultPolicy(new \OCP\AppFramework\Http\ContentSecurityPolicy());
+ $this->addToAssertionCount(1);
}
public function testGetDefaultPolicyWithPolicies() {
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index d52cb48e479..cc98223d4b5 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -779,6 +779,7 @@ class ManagerTest extends \Test\TestCase {
try {
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
+ $this->addToAssertionCount(1);
} catch (\OCP\Share\Exceptions\GenericShareException $e) {
$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getMessage());
$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getHint());
@@ -1008,6 +1009,7 @@ class ManagerTest extends \Test\TestCase {
->willReturn([]);
self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
+ $this->addToAssertionCount(1);
}
/**
@@ -1143,6 +1145,7 @@ class ManagerTest extends \Test\TestCase {
->willReturn([$share2]);
self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
+ $this->addToAssertionCount(1);
}
/**
@@ -1237,6 +1240,7 @@ class ManagerTest extends \Test\TestCase {
]));
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
+ $this->addToAssertionCount(1);
}
/**
@@ -1292,6 +1296,7 @@ class ManagerTest extends \Test\TestCase {
]));
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
+ $this->addToAssertionCount(1);
}
/**
@@ -1360,6 +1365,7 @@ class ManagerTest extends \Test\TestCase {
]));
self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
+ $this->addToAssertionCount(1);
}
public function testLinkCreateChecksReadOnly() {
@@ -1375,6 +1381,7 @@ class ManagerTest extends \Test\TestCase {
]));
self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
+ $this->addToAssertionCount(1);
}
/**
@@ -1407,12 +1414,14 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager->method('findIn')->with('path')->willReturn([$mount]);
self::invokePrivate($this->manager, 'pathCreateChecks', [$path]);
+ $this->addToAssertionCount(1);
}
public function testPathCreateChecksContainsNoFolder() {
$path = $this->createMock(File::class);
self::invokePrivate($this->manager, 'pathCreateChecks', [$path]);
+ $this->addToAssertionCount(1);
}
public function dataIsSharingDisabledForUser() {
@@ -2744,6 +2753,7 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0));
$this->manager->moveShare($share, 'recipient');
+ $this->addToAssertionCount(1);
}
/**
@@ -2801,6 +2811,7 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0));
$this->manager->moveShare($share, 'recipient');
+ $this->addToAssertionCount(1);
}
/**
diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php
index b73bf2737ee..ba225ec1330 100644
--- a/tests/lib/Support/CrashReport/RegistryTest.php
+++ b/tests/lib/Support/CrashReport/RegistryTest.php
@@ -47,6 +47,7 @@ class RegistryTest extends TestCase {
$exception = new Exception('test');
$this->registry->delegateReport($exception);
+ $this->addToAssertionCount(1);
}
public function testDelegateToAll() {
diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php
index a16cc18cb0a..ef3ef4f42c8 100644
--- a/tests/lib/Template/CSSResourceLocatorTest.php
+++ b/tests/lib/Template/CSSResourceLocatorTest.php
@@ -24,6 +24,7 @@
namespace Test\Template;
use OC\Files\AppData\Factory;
+use OCP\Files\IAppData;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IConfig;
@@ -37,7 +38,7 @@ class CSSResourceLocatorTest extends \Test\TestCase {
protected $appData;
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
protected $urlGenerator;
- /** @var SystemConfig|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config;
/** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
protected $themingDefaults;
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 345b2a68e6f..92076580510 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -33,7 +33,7 @@ use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Security\ISecureRandom;
-abstract class TestCase extends \PHPUnit_Framework_TestCase {
+abstract class TestCase extends \PHPUnit\Framework\TestCase {
/** @var \OC\Command\QueueBus */
private $commandBus;
@@ -47,24 +47,6 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
protected $services = [];
/**
- * Wrapper to be forward compatible to phpunit 5.4+
- *
- * @param string $originalClassName
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- protected function createMock($originalClassName) {
- if (is_callable('parent::createMock')) {
- return parent::createMock($originalClassName);
- }
-
- return $this->getMockBuilder($originalClassName)
- ->disableOriginalConstructor()
- ->disableOriginalClone()
- ->disableArgumentCloning()
- ->getMock();
- }
-
- /**
* @param string $name
* @param mixed $newService
* @return bool
@@ -152,7 +134,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
}
}
- protected function onNotSuccessfulTest($e) {
+ protected function onNotSuccessfulTest(\Throwable $t) {
$this->restoreAllServices();
// restore database connection
@@ -162,7 +144,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
});
}
- parent::onNotSuccessfulTest($e);
+ parent::onNotSuccessfulTest($t);
}
protected function tearDown() {
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index f6a362a5031..2ecae3a8500 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -329,7 +329,7 @@ class ManagerTest extends TestCase {
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
- $this->setExpectedException(\InvalidArgumentException::class, $exception);
+ $this->expectException(\InvalidArgumentException::class, $exception);
$manager->createUser($uid, $password);
}
diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php
index 88544cc6ce9..24a72db0065 100644
--- a/tests/startsessionlistener.php
+++ b/tests/startsessionlistener.php
@@ -6,45 +6,25 @@
* See the COPYING-README file.
*/
+use OC\Session\Memory;
+use PHPUnit\Framework\Test;
+use PHPUnit\Framework\TestListener;
+use PHPUnit\Framework\TestListenerDefaultImplementation;
+
/**
* Starts a new session before each test execution
*/
-class StartSessionListener implements PHPUnit_Framework_TestListener {
-
- public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
- }
-
- public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
- }
-
- public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
- }
-
- public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
- }
+class StartSessionListener implements TestListener {
- public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
- }
-
- public function startTest(PHPUnit_Framework_Test $test) {
- }
+ use TestListenerDefaultImplementation;
- public function endTest(PHPUnit_Framework_Test $test, $time) {
+ public function endTest(Test $test, $time) {
// reopen the session - only allowed for memory session
- if (\OC::$server->getSession() instanceof \OC\Session\Memory) {
- /** @var $session \OC\Session\Memory */
+ if (\OC::$server->getSession() instanceof Memory) {
+ /** @var $session Memory */
$session = \OC::$server->getSession();
$session->reopen();
}
}
- public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
- }
-
- public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
- }
-
- public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) {
- }
-
}