diff options
author | Joas Schilling <coding@schilljs.com> | 2018-01-25 11:23:12 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-01-25 11:33:25 +0100 |
commit | bf2be08c9f3b6957a3327929a169eb6204e84cd0 (patch) | |
tree | 4738ade539309fea85c5db8e796783c2cdbc0438 /tests | |
parent | 24af5c20bd65f8e657bcc495984234088c22e824 (diff) | |
download | nextcloud-server-bf2be08c9f3b6957a3327929a169eb6204e84cd0.tar.gz nextcloud-server-bf2be08c9f3b6957a3327929a169eb6204e84cd0.zip |
Fix risky tests without assertions
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
24 files changed, 59 insertions, 30 deletions
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 274a2810cba..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); } } @@ -265,7 +265,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { if($shouldFail) { $this->expectException(SecurityException::class); } else { - $this->assertTrue(true); + $this->addToAssertionCount(1); } $this->reader->reflect(__CLASS__, $method); 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 d5141136a11..e28248fb0fb 100644 --- a/tests/lib/Contacts/ContactsMenu/EntryTest.php +++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php @@ -41,6 +41,7 @@ class EntryTest extends 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/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/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/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() { |