diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 76335f00bfe1335129fbff104e3d9b7eb6d9a8fa..bd6a8856d51983ed157f70fc04fcfffa6c423fea 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -279,7 +279,7 @@ EOD; $this->assertCount(0, $calendarObjects); } - + public function testMultipleCalendarObjectsWithSameUID() { $this->expectException(\Sabre\DAV\Exception\BadRequest::class); $this->expectExceptionMessage('Calendar object with uid already exists in this calendar collection.'); @@ -441,7 +441,7 @@ EOD; $expectedEventsInResult = array_map(function ($index) use ($events) { return $events[$index]; }, $expectedEventsInResult); - $this->assertEquals($expectedEventsInResult, $result, '', 0.0, 10, true); + $this->assertEqualsCanonicalizing($expectedEventsInResult, $result); } public function testGetCalendarObjectByUID() { diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php index b63a973668ef3f71b4fd23209bc57259e164fc41..c7dae373c94825e0adad0a443cad80aae602c8e2 100644 --- a/apps/dav/tests/unit/Command/ListCalendarsTest.php +++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php @@ -63,7 +63,6 @@ class ListCalendarsTest extends TestCase { ); } - public function testWithBadUser() { $this->expectException(\InvalidArgumentException::class); @@ -76,7 +75,7 @@ class ListCalendarsTest extends TestCase { $commandTester->execute([ 'uid' => self::USERNAME, ]); - $this->assertContains("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay()); + $this->assertStringContainsString("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay()); } public function testWithCorrectUserWithNoCalendars() { @@ -94,7 +93,7 @@ class ListCalendarsTest extends TestCase { $commandTester->execute([ 'uid' => self::USERNAME, ]); - $this->assertContains("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay()); + $this->assertStringContainsString("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay()); } public function dataExecute() { @@ -133,7 +132,7 @@ class ListCalendarsTest extends TestCase { $commandTester->execute([ 'uid' => self::USERNAME, ]); - $this->assertContains($output, $commandTester->getDisplay()); - $this->assertNotContains(BirthdayService::BIRTHDAY_CALENDAR_URI, $commandTester->getDisplay()); + $this->assertStringContainsString($output, $commandTester->getDisplay()); + $this->assertStringNotContainsString(BirthdayService::BIRTHDAY_CALENDAR_URI, $commandTester->getDisplay()); } } diff --git a/apps/dav/tests/unit/Command/MoveCalendarTest.php b/apps/dav/tests/unit/Command/MoveCalendarTest.php index a05674017277aa4b21fe33fa814a23b2ae7d6347..750863175a2d6c8274900438aaa104f265d3b1f7 100644 --- a/apps/dav/tests/unit/Command/MoveCalendarTest.php +++ b/apps/dav/tests/unit/Command/MoveCalendarTest.php @@ -121,7 +121,7 @@ class MoveCalendarTest extends TestCase { ]); } - + public function testMoveWithInexistantCalendar() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('User <user> has no calendar named <personal>. You can run occ dav:list-calendars to list calendars URIs for this user.'); @@ -148,7 +148,7 @@ class MoveCalendarTest extends TestCase { ]); } - + public function testMoveWithExistingDestinationCalendar() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('User <user2> already has a calendar named <personal>.'); @@ -313,7 +313,7 @@ class MoveCalendarTest extends TestCase { 'destinationuid' => 'user2', ]); - $this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay()); + $this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay()); } public function testMoveWithDestinationNotPartOfGroupAndForce() { @@ -360,7 +360,7 @@ class MoveCalendarTest extends TestCase { '--force' => true ]); - $this->assertContains("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay()); + $this->assertStringContainsString("[OK] Calendar <personal> was moved from user <user> to <user2>", $commandTester->getDisplay()); } public function dataTestMoveWithCalendarAlreadySharedToDestination(): array { diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 2b04428848a722af74835720f63b0c70f9c35b66..e3e13f05867570b02fe853b6b6234b9fe2b59aa1 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -198,7 +198,9 @@ class FederatedShareProviderTest extends \Test\TestCase { 'accepted' => 0, 'token' => 'token', ]; - $this->assertArraySubset($expected, $data); + foreach (array_keys($expected) as $key) { + $this->assertEquals($expected[$key], $data[$key], "Assert that value for key '$key' is the same"); + } $this->assertEquals($data['id'], $share->getId()); $this->assertEquals(IShare::TYPE_REMOTE, $share->getShareType()); diff --git a/tests/Core/Command/TwoFactorAuth/CleanupTest.php b/tests/Core/Command/TwoFactorAuth/CleanupTest.php index 98425aee2231226669eec094223a11dd23429a75..75e869ad06f7cff0355920a5ab58e8286b2fcf8d 100644 --- a/tests/Core/Command/TwoFactorAuth/CleanupTest.php +++ b/tests/Core/Command/TwoFactorAuth/CleanupTest.php @@ -60,6 +60,6 @@ class CleanupTest extends TestCase { $this->assertEquals(0, $rc); $output = $this->cmd->getDisplay(); - $this->assertContains("All user-provider associations for provider u2f have been removed", $output); + $this->assertStringContainsString("All user-provider associations for provider u2f have been removed", $output); } } diff --git a/tests/Core/Command/TwoFactorAuth/DisableTest.php b/tests/Core/Command/TwoFactorAuth/DisableTest.php index fc0def50b90f4c9e3f539d51cf105212b2dd5a0b..5accaccb907e8d0081106581f954f54bc7ea0ee4 100644 --- a/tests/Core/Command/TwoFactorAuth/DisableTest.php +++ b/tests/Core/Command/TwoFactorAuth/DisableTest.php @@ -67,7 +67,7 @@ class DisableTest extends TestCase { ]); $this->assertEquals(1, $rc); - $this->assertContains("Invalid UID", $this->command->getDisplay()); + $this->assertStringContainsString("Invalid UID", $this->command->getDisplay()); } public function testEnableNotSupported() { @@ -87,7 +87,7 @@ class DisableTest extends TestCase { ]); $this->assertEquals(2, $rc); - $this->assertContains("The provider does not support this operation", $this->command->getDisplay()); + $this->assertStringContainsString("The provider does not support this operation", $this->command->getDisplay()); } public function testEnabled() { @@ -107,6 +107,6 @@ class DisableTest extends TestCase { ]); $this->assertEquals(0, $rc); - $this->assertContains("Two-factor provider totp disabled for user ricky", $this->command->getDisplay()); + $this->assertStringContainsString("Two-factor provider totp disabled for user ricky", $this->command->getDisplay()); } } diff --git a/tests/Core/Command/TwoFactorAuth/EnableTest.php b/tests/Core/Command/TwoFactorAuth/EnableTest.php index f3b66912f43c646274a267fc90a256e1a869eca1..fc71cc32148add94af51148c52862f7067cb3aa5 100644 --- a/tests/Core/Command/TwoFactorAuth/EnableTest.php +++ b/tests/Core/Command/TwoFactorAuth/EnableTest.php @@ -67,7 +67,7 @@ class EnableTest extends TestCase { ]); $this->assertEquals(1, $rc); - $this->assertContains("Invalid UID", $this->command->getDisplay()); + $this->assertStringContainsString("Invalid UID", $this->command->getDisplay()); } public function testEnableNotSupported() { @@ -87,7 +87,7 @@ class EnableTest extends TestCase { ]); $this->assertEquals(2, $rc); - $this->assertContains("The provider does not support this operation", $this->command->getDisplay()); + $this->assertStringContainsString("The provider does not support this operation", $this->command->getDisplay()); } public function testEnabled() { @@ -107,6 +107,6 @@ class EnableTest extends TestCase { ]); $this->assertEquals(0, $rc); - $this->assertContains("Two-factor provider totp enabled for user belle", $this->command->getDisplay()); + $this->assertStringContainsString("Two-factor provider totp enabled for user belle", $this->command->getDisplay()); } } diff --git a/tests/Core/Command/TwoFactorAuth/EnforceTest.php b/tests/Core/Command/TwoFactorAuth/EnforceTest.php index 48c09f7e63990884be6db1128c083c8973f11ed5..ed3deaa3fb341600ff9c85f1de4a044a81a317b9 100644 --- a/tests/Core/Command/TwoFactorAuth/EnforceTest.php +++ b/tests/Core/Command/TwoFactorAuth/EnforceTest.php @@ -64,7 +64,7 @@ class EnforceTest extends TestCase { $this->assertEquals(0, $rc); $display = $this->command->getDisplay(); - $this->assertContains("Two-factor authentication is enforced for all users", $display); + $this->assertStringContainsString("Two-factor authentication is enforced for all users", $display); } public function testEnforceForOneGroup() { @@ -82,7 +82,7 @@ class EnforceTest extends TestCase { $this->assertEquals(0, $rc); $display = $this->command->getDisplay(); - $this->assertContains("Two-factor authentication is enforced for members of the group(s) twofactorers", $display); + $this->assertStringContainsString("Two-factor authentication is enforced for members of the group(s) twofactorers", $display); } public function testEnforceForAllExceptOneGroup() { @@ -100,7 +100,7 @@ class EnforceTest extends TestCase { $this->assertEquals(0, $rc); $display = $this->command->getDisplay(); - $this->assertContains("Two-factor authentication is enforced for all users, except members of yoloers", $display); + $this->assertStringContainsString("Two-factor authentication is enforced for all users, except members of yoloers", $display); } public function testDisableEnforced() { @@ -117,7 +117,7 @@ class EnforceTest extends TestCase { $this->assertEquals(0, $rc); $display = $this->command->getDisplay(); - $this->assertContains("Two-factor authentication is not enforced", $display); + $this->assertStringContainsString("Two-factor authentication is not enforced", $display); } public function testCurrentStateEnabled() { @@ -129,7 +129,7 @@ class EnforceTest extends TestCase { $this->assertEquals(0, $rc); $display = $this->command->getDisplay(); - $this->assertContains("Two-factor authentication is enforced for all users", $display); + $this->assertStringContainsString("Two-factor authentication is enforced for all users", $display); } public function testCurrentStateDisabled() { @@ -141,6 +141,6 @@ class EnforceTest extends TestCase { $this->assertEquals(0, $rc); $display = $this->command->getDisplay(); - $this->assertContains("Two-factor authentication is not enforced", $display); + $this->assertStringContainsString("Two-factor authentication is not enforced", $display); } } diff --git a/tests/Core/Command/TwoFactorAuth/StateTest.php b/tests/Core/Command/TwoFactorAuth/StateTest.php index ce52bcf2751fe154b3414e71528c08d00a94f748..54ab85b51b80eaa394b53529b3df93ca2f9fd12f 100644 --- a/tests/Core/Command/TwoFactorAuth/StateTest.php +++ b/tests/Core/Command/TwoFactorAuth/StateTest.php @@ -61,7 +61,7 @@ class StateTest extends TestCase { ]); $output = $this->cmd->getDisplay(); - $this->assertContains("Invalid UID", $output); + $this->assertStringContainsString("Invalid UID", $output); } public function testStateNoProvidersActive() { @@ -84,7 +84,7 @@ class StateTest extends TestCase { ]); $output = $this->cmd->getDisplay(); - $this->assertContains("Two-factor authentication is not enabled for user eldora", $output); + $this->assertStringContainsString("Two-factor authentication is not enabled for user eldora", $output); } public function testStateOneProviderActive() { @@ -107,6 +107,6 @@ class StateTest extends TestCase { ]); $output = $this->cmd->getDisplay(); - $this->assertContains("Two-factor authentication is enabled for user mohamed", $output); + $this->assertStringContainsString("Two-factor authentication is enabled for user mohamed", $output); } } diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php index 1ad53f5db1348da92e1a11764e7fb1e2145ce3b6..6c509b8bc59f9a227b354bdb7c65e76b4f0e8654 100644 --- a/tests/lib/AppFramework/Http/DownloadResponseTest.php +++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php @@ -45,7 +45,7 @@ class DownloadResponseTest extends \Test\TestCase { public function testHeaders() { $headers = $this->response->getHeaders(); - $this->assertContains('attachment; filename="file"', $headers['Content-Disposition']); - $this->assertContains('content', $headers['Content-Type']); + $this->assertStringContainsString('attachment; filename="file"', $headers['Content-Disposition']); + $this->assertStringContainsString('content', $headers['Content-Type']); } } diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php index aa6c50528cc199b8b5af6583d8ab53e4895fe543..d360d115824b9ae9b0a9704d4397d3bae4519d3f 100644 --- a/tests/lib/ConfigTest.php +++ b/tests/lib/ConfigTest.php @@ -71,9 +71,7 @@ class ConfigTest extends TestCase { public function testSetValue() { $this->config->setValue('foo', 'moo'); - $expectedConfig = $this->initialConfig; - $expectedConfig['foo'] = 'moo'; - $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); + $this->assertSame('moo', $this->config->getValue('foo')); $content = file_get_contents($this->configFile); $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . @@ -82,9 +80,8 @@ class ConfigTest extends TestCase { $this->config->setValue('bar', 'red'); $this->config->setValue('apps', ['files', 'gallery']); - $expectedConfig['bar'] = 'red'; - $expectedConfig['apps'] = ['files', 'gallery']; - $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); + $this->assertSame('red', $this->config->getValue('bar')); + $this->assertSame(['files', 'gallery'], $this->config->getValue('apps')); $content = file_get_contents($this->configFile); @@ -105,7 +102,8 @@ class ConfigTest extends TestCase { 'not_exists' => null, ]); - $this->assertAttributeEquals($this->initialConfig, 'cache', $this->config); + $this->assertSame('bar', $this->config->getValue('foo')); + $this->assertSame(null, $this->config->getValue('not_exists')); $content = file_get_contents($this->configFile); $this->assertEquals(self::TESTCONTENT, $content); @@ -113,10 +111,8 @@ class ConfigTest extends TestCase { 'foo' => 'moo', 'alcohol_free' => null, ]); - $expectedConfig = $this->initialConfig; - $expectedConfig['foo'] = 'moo'; - unset($expectedConfig['alcohol_free']); - $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); + $this->assertSame('moo', $this->config->getValue('foo')); + $this->assertSame(null, $this->config->getValue('not_exists')); $content = file_get_contents($this->configFile); $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . @@ -126,9 +122,7 @@ class ConfigTest extends TestCase { public function testDeleteKey() { $this->config->deleteKey('foo'); - $expectedConfig = $this->initialConfig; - unset($expectedConfig['foo']); - $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); + $this->assertSame('this_was_clearly_not_set_before', $this->config->getValue('foo', 'this_was_clearly_not_set_before')); $content = file_get_contents($this->configFile); $expected = "<?php\n\$CONFIG = array (\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php index 4b249d07c45e9ab7aec1d5db60d16870e3849b13..9f575a75da6dbd803058698517cbc2c2875d768d 100644 --- a/tests/lib/DB/DBSchemaTest.php +++ b/tests/lib/DB/DBSchemaTest.php @@ -83,8 +83,8 @@ class DBSchemaTest extends TestCase { $outfile = $this->tempManager->getTemporaryFile(); OC_DB::getDbStructure($outfile); $content = file_get_contents($outfile); - $this->assertContains($this->table1, $content); - $this->assertContains($this->table2, $content); + $this->assertStringContainsString($this->table1, $content); + $this->assertStringContainsString($this->table2, $content); } public function doTestSchemaRemoving() { diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index 7e1fb8c888660b20f994fd0927680273007a6b99..fb5286ebe65e6c6df9b618dbc55af5267935b528 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -329,7 +329,7 @@ class FactoryTest extends TestCase { ->with($app) ->willReturn(\OC::$SERVERROOT . '/tests/data/l10n/'); - $this->assertEquals(['cs', 'de', 'en', 'ru'], $factory->findAvailableLanguages($app), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing(['cs', 'de', 'en', 'ru'], $factory->findAvailableLanguages($app)); } public function dataLanguageExists() { @@ -360,7 +360,7 @@ class FactoryTest extends TestCase { ->with('theme') ->willReturn('abc'); - $this->assertEquals(['en', 'zz'], $factory->findAvailableLanguages($app), '', 0.0, 10, true); + $this->assertEqualsCanonicalizing(['en', 'zz'], $factory->findAvailableLanguages($app)); } /** diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php index 01f2285670e9db7d96d081a6d0e2b3bc971297b9..8c2a50e97ca2063c00e6675f89ab3e30b182e55c 100644 --- a/tests/lib/Template/CSSResourceLocatorTest.php +++ b/tests/lib/Template/CSSResourceLocatorTest.php @@ -107,16 +107,6 @@ class CSSResourceLocatorTest extends \Test\TestCase { return sha1(uniqid(mt_rand(), true)); } - public function testConstructor() { - $locator = $this->cssResourceLocator(); - $this->assertAttributeEquals('theme', 'theme', $locator); - $this->assertAttributeEquals('core', 'serverroot', $locator); - $this->assertAttributeEquals(['core'=>'map','3rd'=>'party'], 'mapping', $locator); - $this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator); - $this->assertAttributeEquals('map', 'webroot', $locator); - $this->assertAttributeEquals([], 'resources', $locator); - } - public function testFindWithAppPathSymlink() { // First create new apps path, and a symlink to it $apps_dirname = $this->randomString(); diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php index 0e6b217ec52fb0d3250912c080f024fc4aa2d5bf..3f5d157e7f539983e291dcf96112735e7e4b21eb 100644 --- a/tests/lib/Template/JSResourceLocatorTest.php +++ b/tests/lib/Template/JSResourceLocatorTest.php @@ -86,17 +86,6 @@ class JSResourceLocatorTest extends \Test\TestCase { return sha1(uniqid(mt_rand(), true)); } - - public function testConstructor() { - $locator = $this->jsResourceLocator(); - $this->assertAttributeEquals('theme', 'theme', $locator); - $this->assertAttributeEquals('core', 'serverroot', $locator); - $this->assertAttributeEquals(['core'=>'map','3rd'=>'party'], 'mapping', $locator); - $this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator); - $this->assertAttributeEquals('map', 'webroot', $locator); - $this->assertAttributeEquals([], 'resources', $locator); - } - public function testFindWithAppPathSymlink() { // First create new apps path, and a symlink to it $apps_dirname = $this->randomString(); diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php index f0fa8186686a800c16433cf2ee2d74fc92d7d45d..71f39a1179ee8985dbcc1a68c770310871daf90d 100644 --- a/tests/lib/Template/ResourceLocatorTest.php +++ b/tests/lib/Template/ResourceLocatorTest.php @@ -33,17 +33,6 @@ class ResourceLocatorTest extends \Test\TestCase { '', true, true, true, []); } - public function testConstructor() { - $locator = $this->getResourceLocator('theme', - ['core'=>'map'], ['3rd'=>'party'], ['foo'=>'bar']); - $this->assertAttributeEquals('theme', 'theme', $locator); - $this->assertAttributeEquals('core', 'serverroot', $locator); - $this->assertAttributeEquals(['core'=>'map','3rd'=>'party'], 'mapping', $locator); - $this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator); - $this->assertAttributeEquals('map', 'webroot', $locator); - $this->assertAttributeEquals([], 'resources', $locator); - } - public function testFind() { $locator = $this->getResourceLocator('theme', ['core' => 'map'], ['3rd' => 'party'], ['foo' => 'bar']);