Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable18] Fix PHPUnit deprecation warnings #22058

Merged
merged 5 commits into from Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Expand Up @@ -280,7 +280,7 @@ public function testCalendarObjectsOperations() {
$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.');
Expand Down Expand Up @@ -443,7 +443,7 @@ public function testCalendarQuery($expectedEventsInResult, $propFilters, $compFi
$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() {
Expand Down
9 changes: 4 additions & 5 deletions apps/dav/tests/unit/Command/ListCalendarsTest.php
Expand Up @@ -63,7 +63,6 @@ protected function setUp(): void {
);
}


public function testWithBadUser()
{
$this->expectException(\InvalidArgumentException::class);
Expand All @@ -77,7 +76,7 @@ public function testWithBadUser()
$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()
Expand All @@ -96,7 +95,7 @@ public function testWithCorrectUserWithNoCalendars()
$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()
Expand Down Expand Up @@ -137,7 +136,7 @@ public function testWithCorrectUser(bool $readOnly, string $output)
$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());
}
}
7 changes: 3 additions & 4 deletions apps/dav/tests/unit/Command/MoveCalendarTest.php
Expand Up @@ -121,7 +121,6 @@ public function testWithBadUserOrigin($userOriginExists, $userDestinationExists)
]);
}


public function testMoveWithInexistantCalendar()
{
$this->expectException(\InvalidArgumentException::class);
Expand Down Expand Up @@ -149,7 +148,7 @@ public function testMoveWithInexistantCalendar()
]);
}


public function testMoveWithExistingDestinationCalendar()
{
$this->expectException(\InvalidArgumentException::class);
Expand Down Expand Up @@ -319,7 +318,7 @@ public function testMoveWithDestinationPartOfGroup()
'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()
Expand Down Expand Up @@ -367,7 +366,7 @@ public function testMoveWithDestinationNotPartOfGroupAndForce()
'--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
Expand Down
Expand Up @@ -196,7 +196,9 @@ public function testCreate() {
'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(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType());
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Command/TwoFactorAuth/CleanupTest.php
Expand Up @@ -60,7 +60,7 @@ public function testCleanup() {

$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);
}

}
6 changes: 3 additions & 3 deletions tests/Core/Command/TwoFactorAuth/DisableTest.php
Expand Up @@ -67,7 +67,7 @@ public function testInvalidUID() {
]);

$this->assertEquals(1, $rc);
$this->assertContains("Invalid UID", $this->command->getDisplay());
$this->assertStringContainsString("Invalid UID", $this->command->getDisplay());
}

public function testEnableNotSupported() {
Expand All @@ -87,7 +87,7 @@ public function testEnableNotSupported() {
]);

$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() {
Expand All @@ -107,6 +107,6 @@ public function testEnabled() {
]);

$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());
}
}
6 changes: 3 additions & 3 deletions tests/Core/Command/TwoFactorAuth/EnableTest.php
Expand Up @@ -67,7 +67,7 @@ public function testInvalidUID() {
]);

$this->assertEquals(1, $rc);
$this->assertContains("Invalid UID", $this->command->getDisplay());
$this->assertStringContainsString("Invalid UID", $this->command->getDisplay());
}

public function testEnableNotSupported() {
Expand All @@ -87,7 +87,7 @@ public function testEnableNotSupported() {
]);

$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() {
Expand All @@ -107,7 +107,7 @@ public function testEnabled() {
]);

$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());
}

}
12 changes: 6 additions & 6 deletions tests/Core/Command/TwoFactorAuth/EnforceTest.php
Expand Up @@ -64,7 +64,7 @@ public function testEnforce() {

$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() {
Expand All @@ -82,7 +82,7 @@ public function testEnforceForOneGroup() {

$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() {
Expand All @@ -100,7 +100,7 @@ public function testEnforceForAllExceptOneGroup() {

$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() {
Expand All @@ -117,7 +117,7 @@ public function testDisableEnforced() {

$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() {
Expand All @@ -129,7 +129,7 @@ public function testCurrentStateEnabled() {

$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() {
Expand All @@ -141,7 +141,7 @@ public function testCurrentStateDisabled() {

$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);
}

}
6 changes: 3 additions & 3 deletions tests/Core/Command/TwoFactorAuth/StateTest.php
Expand Up @@ -61,7 +61,7 @@ public function testWrongUID() {
]);

$output = $this->cmd->getDisplay();
$this->assertContains("Invalid UID", $output);
$this->assertStringContainsString("Invalid UID", $output);
}

public function testStateNoProvidersActive() {
Expand All @@ -84,7 +84,7 @@ public function testStateNoProvidersActive() {
]);

$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() {
Expand All @@ -107,7 +107,7 @@ public function testStateOneProviderActive() {
]);

$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);
}

}
4 changes: 2 additions & 2 deletions tests/lib/AppFramework/Http/DownloadResponseTest.php
Expand Up @@ -47,8 +47,8 @@ protected function setUp(): void {
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']);
}


Expand Down
24 changes: 9 additions & 15 deletions tests/lib/ConfigTest.php
Expand Up @@ -71,20 +71,17 @@ public function testGetValueReturnsEnvironmentValueIfSetToFalse() {

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 " .
" 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n);\n";
$this->assertEquals($expected, $content);

$this->config->setValue('bar', 'red');
$this->config->setValue('apps', array('files', 'gallery'));
$expectedConfig['bar'] = 'red';
$expectedConfig['apps'] = array('files', 'gallery');
$this->assertAttributeEquals($expectedConfig, 'cache', $this->config);
$this->config->setValue('apps', ['files', 'gallery']);
$this->assertSame('red', $this->config->getValue('bar'));
$this->assertSame(['files', 'gallery'], $this->config->getValue('apps'));

$content = file_get_contents($this->configFile);

Expand All @@ -105,18 +102,17 @@ public function testSetValues() {
'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);

$this->config->setValues([
'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 " .
Expand All @@ -126,9 +122,7 @@ public function testSetValues() {

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 " .
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/DB/DBSchemaTest.php
Expand Up @@ -83,8 +83,8 @@ public function doTestSchemaDumping() {
$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() {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/L10N/FactoryTest.php
Expand Up @@ -329,7 +329,7 @@ public function testFindAvailableLanguages($app) {
->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() {
Expand Down Expand Up @@ -360,7 +360,7 @@ public function testFindAvailableLanguagesWithThemes() {
->with('theme')
->willReturn('abc');

$this->assertEquals(['en', 'zz'], $factory->findAvailableLanguages($app), '', 0.0, 10, true);
$this->assertEqualsCanonicalizing(['en', 'zz'], $factory->findAvailableLanguages($app));
}

/**
Expand Down
10 changes: 0 additions & 10 deletions tests/lib/Template/CSSResourceLocatorTest.php
Expand Up @@ -107,16 +107,6 @@ private function randomString() {
return sha1(uniqid(mt_rand(), true));
}

public function testConstructor() {
$locator = $this->cssResourceLocator();
$this->assertAttributeEquals('theme', 'theme', $locator);
$this->assertAttributeEquals('core', 'serverroot', $locator);
$this->assertAttributeEquals(array('core'=>'map','3rd'=>'party'), 'mapping', $locator);
$this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator);
$this->assertAttributeEquals('map', 'webroot', $locator);
$this->assertAttributeEquals(array(), 'resources', $locator);
}

public function testFindWithAppPathSymlink() {
// First create new apps path, and a symlink to it
$apps_dirname = $this->randomString();
Expand Down
11 changes: 0 additions & 11 deletions tests/lib/Template/JSResourceLocatorTest.php
Expand Up @@ -86,17 +86,6 @@ private function randomString() {
return sha1(uniqid(mt_rand(), true));
}


public function testConstructor() {
$locator = $this->jsResourceLocator();
$this->assertAttributeEquals('theme', 'theme', $locator);
$this->assertAttributeEquals('core', 'serverroot', $locator);
$this->assertAttributeEquals(array('core'=>'map','3rd'=>'party'), 'mapping', $locator);
$this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator);
$this->assertAttributeEquals('map', 'webroot', $locator);
$this->assertAttributeEquals(array(), 'resources', $locator);
}

public function testFindWithAppPathSymlink() {
// First create new apps path, and a symlink to it
$apps_dirname = $this->randomString();
Expand Down
11 changes: 0 additions & 11 deletions tests/lib/Template/ResourceLocatorTest.php
Expand Up @@ -33,17 +33,6 @@ public function getResourceLocator($theme, $core_map, $party_map, $appsRoots) {
'', true, true, true, array());
}

public function testConstructor() {
$locator = $this->getResourceLocator('theme',
array('core'=>'map'), array('3rd'=>'party'), array('foo'=>'bar'));
$this->assertAttributeEquals('theme', 'theme', $locator);
$this->assertAttributeEquals('core', 'serverroot', $locator);
$this->assertAttributeEquals(array('core'=>'map','3rd'=>'party'), 'mapping', $locator);
$this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator);
$this->assertAttributeEquals('map', 'webroot', $locator);
$this->assertAttributeEquals(array(), 'resources', $locator);
}

public function testFind() {
$locator = $this->getResourceLocator('theme',
array('core' => 'map'), array('3rd' => 'party'), array('foo' => 'bar'));
Expand Down