diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2022-12-05 12:03:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-05 12:03:39 +0100 |
commit | 30560d316584276a08c909f5198a839c1c170cc9 (patch) | |
tree | 154477dee76d6b7451671010aa2318c500975521 /tests | |
parent | cb0450b5c4fbe590e7b35284a40d78d96a0251f6 (diff) | |
parent | 4196bf81e653c39d33d25c76652cc78dab8c5e1c (diff) | |
download | nextcloud-server-30560d316584276a08c909f5198a839c1c170cc9.tar.gz nextcloud-server-30560d316584276a08c909f5198a839c1c170cc9.zip |
Merge branch 'master' into tests/fix-phpunit-warnings
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/acceptance/features/app-theming.feature | 34 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FilesAppSharingContext.php | 8 | ||||
-rwxr-xr-x | tests/drone-run-integration-tests.sh | 2 | ||||
-rw-r--r-- | tests/lib/Accounts/AccountManagerTest.php | 39 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/RequestStream.php | 26 | ||||
-rw-r--r-- | tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php | 2 | ||||
-rw-r--r-- | tests/lib/DB/MigrationsTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Encryption/Keys/StorageTest.php | 9 | ||||
-rw-r--r-- | tests/lib/Group/ManagerTest.php | 62 | ||||
-rw-r--r-- | tests/lib/ImageTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Notification/ManagerTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Security/VerificationToken/VerificationTokenTest.php | 11 | ||||
-rw-r--r-- | tests/lib/Settings/ManagerTest.php | 20 | ||||
-rw-r--r-- | tests/lib/Share20/ShareTest.php | 6 |
14 files changed, 129 insertions, 106 deletions
diff --git a/tests/acceptance/features/app-theming.feature b/tests/acceptance/features/app-theming.feature deleted file mode 100644 index d12d1521f8b..00000000000 --- a/tests/acceptance/features/app-theming.feature +++ /dev/null @@ -1,34 +0,0 @@ -@apache -Feature: app-theming - -# FIXME test with cypress -# The existing DOM testing framework used here is not fully suitable for testing UIs implemented with modern frontend frameworks like Vue - - Scenario: changing the color updates the primary color - Given I am logged in as the admin - And I visit the admin settings page - And I open the "Theming" section - # And I see that the color selector in the Theming app has loaded - # The "eventually" part is not really needed here, as the colour is not - # being animated at this point, but there is no need to create a specific - # step just for this. - # And I see that the primary color is eventually "#00639a" - # And I see that the non-plain background color variable is eventually "#0082c9" - # When I set the "Color" parameter in the Theming app to "#C9C9C9" - # Then I see that the parameters in the Theming app are eventually saved - # And I see that the primary color is eventually "#00639a" - # And I see that the non-plain background color variable is eventually "#C9C9C9" - - Scenario: resetting the color updates the primary color - Given I am logged in as the admin - And I visit the admin settings page - And I open the "Theming" section - # And I see that the color selector in the Theming app has loaded - # And I set the "Color" parameter in the Theming app to "#C9C9C9" - # And I see that the parameters in the Theming app are eventually saved - # And I see that the primary color is eventually "#00639a" - # And I see that the non-plain background color variable is eventually "#C9C9C9" - # When I reset the "Color" parameter in the Theming app to its default value - # Then I see that the parameters in the Theming app are eventually saved - # And I see that the primary color is eventually "#00639a" - # And I see that the non-plain background color variable is eventually "#0082c9" diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php index fd85315f49f..a6ae90d32d0 100644 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php @@ -41,7 +41,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareWithInput() { - return Locator::forThe()->css(".sharing-input .multiselect__input")-> + return Locator::forThe()->css(".sharing-search__input .multiselect__input")-> descendantOf(FilesAppContext::detailsView())-> describedAs("Share with input in the details view in Files app"); } @@ -50,7 +50,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareWithInputResults() { - return Locator::forThe()->css(".sharing-input .multiselect__content-wrapper")-> + return Locator::forThe()->css(".sharing-search__input .multiselect__content-wrapper")-> descendantOf(FilesAppContext::detailsView())-> describedAs("Share with input results list in the details view in Files app"); } @@ -206,7 +206,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function copyLinkButton() { - return Locator::forThe()->css("a.sharing-entry__copy")-> + return Locator::forThe()->css("button.sharing-entry__copy")-> descendantOf(self::shareLinkRow())-> describedAs("Copy link button in the details view in Files app"); } @@ -391,7 +391,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { // Clicking on the menu item copies the link to the clipboard, but it is // not possible to access that value from the acceptance tests. Due to // this the value of the attribute that holds the URL is used instead. - $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyLinkButton(), 2)->getWrappedElement()->getAttribute("href"); + $this->actor->getSharedNotebook()["shared link"] = $this->actor->getSession()->evaluateScript("return document.querySelector('.sharing-entry__link').__vue__.shareLink;"); } /** diff --git a/tests/drone-run-integration-tests.sh b/tests/drone-run-integration-tests.sh index af3c7a895c8..a341f363b86 100755 --- a/tests/drone-run-integration-tests.sh +++ b/tests/drone-run-integration-tests.sh @@ -20,4 +20,6 @@ echo "=========================" [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c "^build/integration/") -gt 0 ]] && echo "Integration test files are modified" && exit 0 +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c "3rdparty") -gt 0 ]] && echo "3rdparty is modified" && exit 0 + exit 1 diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index 2eaec755b50..3a3405f18a0 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -157,6 +157,11 @@ class AccountManagerTest extends TestCase { 'scope' => IAccountManager::SCOPE_PUBLISHED ], [ + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + 'value' => '@someMastodon@mastodon.social', + 'scope' => IAccountManager::SCOPE_PUBLISHED + ], + [ 'name' => IAccountManager::PROPERTY_PHONE, 'value' => '+491601231212', 'scope' => IAccountManager::SCOPE_FEDERATED @@ -212,6 +217,11 @@ class AccountManagerTest extends TestCase { 'scope' => IAccountManager::SCOPE_FEDERATED ], [ + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + 'value' => '@a_alice@cool.social', + 'scope' => IAccountManager::SCOPE_FEDERATED + ], + [ 'name' => IAccountManager::PROPERTY_PHONE, 'value' => '+491602312121', 'scope' => IAccountManager::SCOPE_LOCAL @@ -267,6 +277,11 @@ class AccountManagerTest extends TestCase { 'scope' => IAccountManager::SCOPE_LOCAL ], [ + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + 'value' => '', + 'scope' => IAccountManager::SCOPE_LOCAL + ], + [ 'name' => IAccountManager::PROPERTY_PHONE, 'value' => '+491603121212', 'scope' => IAccountManager::SCOPE_PUBLISHED @@ -322,6 +337,11 @@ class AccountManagerTest extends TestCase { scope' => IAccountManager::SCOPE_LOCAL ], [ + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + 'value' => '', ' + scope' => IAccountManager::SCOPE_LOCAL + ], + [ 'name' => IAccountManager::PROPERTY_PHONE, 'value' => '+71601212123', 'scope' => IAccountManager::SCOPE_LOCAL @@ -387,6 +407,11 @@ class AccountManagerTest extends TestCase { 'scope' => IAccountManager::SCOPE_LOCAL ], [ + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + 'value' => '', + 'scope' => IAccountManager::SCOPE_LOCAL + ], + [ 'name' => IAccountManager::PROPERTY_PHONE, 'value' => '+71602121231', 'scope' => IAccountManager::SCOPE_FEDERATED @@ -571,6 +596,13 @@ class AccountManagerTest extends TestCase { ], [ + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + 'value' => '', + 'scope' => IAccountManager::SCOPE_LOCAL, + 'verified' => IAccountManager::NOT_VERIFIED, + ], + + [ 'name' => IAccountManager::PROPERTY_ORGANISATION, 'value' => '', 'scope' => IAccountManager::SCOPE_LOCAL, @@ -620,6 +652,12 @@ class AccountManagerTest extends TestCase { 'name' => IAccountManager::PROPERTY_TWITTER, ], [ + 'value' => '@mastohandle@mastodon.social', + 'scope' => IAccountManager::SCOPE_LOCAL, + 'verified' => IAccountManager::NOT_VERIFIED, + 'name' => IAccountManager::PROPERTY_FEDIVERSE, + ], + [ 'value' => 'test@example.com', 'scope' => IAccountManager::SCOPE_PUBLISHED, 'verified' => IAccountManager::VERIFICATION_IN_PROGRESS, @@ -634,6 +672,7 @@ class AccountManagerTest extends TestCase { ]; $expected = new Account($user); $expected->setProperty(IAccountManager::PROPERTY_TWITTER, '@twitterhandle', IAccountManager::SCOPE_LOCAL, IAccountManager::NOT_VERIFIED); + $expected->setProperty(IAccountManager::PROPERTY_FEDIVERSE, '@mastohandle@mastodon.social', IAccountManager::SCOPE_LOCAL, IAccountManager::NOT_VERIFIED); $expected->setProperty(IAccountManager::PROPERTY_EMAIL, 'test@example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFICATION_IN_PROGRESS); $expected->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_FEDERATED, IAccountManager::VERIFIED); diff --git a/tests/lib/AppFramework/Http/RequestStream.php b/tests/lib/AppFramework/Http/RequestStream.php index 3868ed16505..1a99685e340 100644 --- a/tests/lib/AppFramework/Http/RequestStream.php +++ b/tests/lib/AppFramework/Http/RequestStream.php @@ -7,24 +7,26 @@ namespace Test\AppFramework\Http; * Used to simulate php://input for Request tests */ class RequestStream { - protected $position; - protected $varname; + protected int $position = 0; + protected string $varname = ''; + /* @var resource */ + public $context; - public function stream_open($path, $mode, $options, &$opened_path) { + public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool { $url = parse_url($path); - $this->varname = $url["host"]; + $this->varname = $url["host"] ?? ''; $this->position = 0; return true; } - public function stream_read($count) { + public function stream_read(int $count): string { $ret = substr($GLOBALS[$this->varname], $this->position, $count); $this->position += strlen($ret); return $ret; } - public function stream_write($data) { + public function stream_write(string $data): int { $left = substr($GLOBALS[$this->varname], 0, $this->position); $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); $GLOBALS[$this->varname] = $left . $data . $right; @@ -32,15 +34,15 @@ class RequestStream { return strlen($data); } - public function stream_tell() { + public function stream_tell(): int { return $this->position; } - public function stream_eof() { + public function stream_eof(): bool { return $this->position >= strlen($GLOBALS[$this->varname]); } - public function stream_seek($offset, $whence) { + public function stream_seek(int $offset, int $whence = SEEK_SET): bool { switch ($whence) { case SEEK_SET: if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { @@ -74,7 +76,7 @@ class RequestStream { } } - public function stream_stat() { + public function stream_stat(): array { $size = strlen($GLOBALS[$this->varname]); $time = time(); $data = [ @@ -96,10 +98,10 @@ class RequestStream { //return false; } - public function stream_metadata($path, $option, $var) { + public function stream_metadata(string $path, int $option, $var): bool { if ($option == STREAM_META_TOUCH) { $url = parse_url($path); - $varname = $url["host"]; + $varname = $url["host"] ?? ''; if (!isset($GLOBALS[$varname])) { $GLOBALS[$varname] = ''; } diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index 197cb46a592..d6e8dba31be 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -51,7 +51,7 @@ class PublicKeyTokenProviderTest extends TestCase { private $crypto; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @var IDBConnection|IDBConnection|MockObject */ + /** @var IDBConnection|MockObject */ private IDBConnection $db; /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index 3d115f25adf..b7d49b565ac 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/tests/lib/DB/MigrationsTest.php @@ -31,7 +31,6 @@ use OCP\Migration\IMigrationStep; * @package Test\DB */ class MigrationsTest extends \Test\TestCase { - /** @var MigrationService | \PHPUnit\Framework\MockObject\MockObject */ private $migrationService; /** @var \PHPUnit\Framework\MockObject\MockObject | IDBConnection $db */ @@ -247,6 +246,9 @@ class MigrationsTest extends \Test\TestCase { ->willReturn(\str_repeat('a', 30)); $primaryKey = $this->createMock(Index::class); + $primaryKey->expects($this->once()) + ->method('getName') + ->willReturn(\str_repeat('a', 30)); $table->expects($this->once()) ->method('getColumns') diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index bb7bbbcd7c1..d1c0257cc6e 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -31,22 +31,23 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class StorageTest extends TestCase { - /** @var Storage */ protected $storage; - /** @var \PHPUnit\Framework\MockObject\MockObject */ + /** @var MockObject|\OC\Encryption\Util */ protected $util; - /** @var \PHPUnit\Framework\MockObject\MockObject */ + /** @var MockObject|View */ protected $view; - /** @var \PHPUnit\Framework\MockObject\MockObject */ + /** @var MockObject|IConfig */ protected $config; /** @var MockObject|ICrypto */ protected $crypto; + private array $mkdirStack = []; + protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index d689fd4eb7a..65210bcc0f7 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -26,6 +26,7 @@ namespace Test\Group; use OC\Group\Database; use OC\User\Manager; use OCP\GroupInterface; +use OCP\ICacheFactory; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -39,6 +40,8 @@ class ManagerTest extends TestCase { protected $dispatcher; /** @var LoggerInterface|MockObject */ protected $logger; + /** @var ICacheFactory|MockObject */ + private $cache; protected function setUp(): void { parent::setUp(); @@ -46,6 +49,7 @@ class ManagerTest extends TestCase { $this->userManager = $this->createMock(Manager::class); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); $this->logger = $this->createMock(LoggerInterface::class); + $this->cache = $this->createMock(ICacheFactory::class); } private function getTestUser($userId) { @@ -107,7 +111,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->get('group1'); @@ -116,7 +120,7 @@ class ManagerTest extends TestCase { } public function testGetNoBackend() { - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $this->assertNull($manager->get('group1')); } @@ -131,7 +135,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(false); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertNull($manager->get('group1')); @@ -141,7 +145,7 @@ class ManagerTest extends TestCase { $backend = new \Test\Util\Group\Dummy(); $backend->createGroup('group1'); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->get('group1'); @@ -168,7 +172,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -194,7 +198,7 @@ class ManagerTest extends TestCase { return true; }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -223,7 +227,7 @@ class ManagerTest extends TestCase { ->method('getGroupDetails') ->willReturn([]); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -240,7 +244,7 @@ class ManagerTest extends TestCase { $backend->expects($this->never()) ->method('createGroup'); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $group = $manager->createGroup('group1'); @@ -261,7 +265,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->search('1'); @@ -295,7 +299,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -332,7 +336,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -359,7 +363,7 @@ class ManagerTest extends TestCase { /** @var \OC\User\Manager $userManager */ $userManager = $this->createMock(Manager::class); - $manager = new \OC\Group\Manager($userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->search('1'); @@ -380,7 +384,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->getUserGroups($this->getTestUser('user1')); @@ -398,7 +402,7 @@ class ManagerTest extends TestCase { ->with('myUID') ->willReturn(['123', 'abc']); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); /** @var \OC\User\User|\PHPUnit\Framework\MockObject\MockObject $user */ @@ -428,7 +432,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(false); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); /** @var \OC\User\User|\PHPUnit\Framework\MockObject\MockObject $user */ @@ -454,7 +458,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertTrue($manager->isInGroup('user1', 'group1')); @@ -473,7 +477,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertTrue($manager->isAdmin('user1')); @@ -492,7 +496,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $this->assertFalse($manager->isAdmin('user1')); @@ -523,7 +527,7 @@ class ManagerTest extends TestCase { ->method('groupExists') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend1); $manager->addBackend($backend2); @@ -582,7 +586,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3'); @@ -642,7 +646,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3', 1); @@ -706,7 +710,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', 'user3', 1, 1); @@ -746,7 +750,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', ''); @@ -785,7 +789,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', '', 1); @@ -824,7 +828,7 @@ class ManagerTest extends TestCase { } }); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $users = $manager->displayNamesInGroup('testgroup', '', 1, 1); @@ -852,7 +856,7 @@ class ManagerTest extends TestCase { ->with('group1') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); // prime cache @@ -895,7 +899,7 @@ class ManagerTest extends TestCase { ->method('removeFromGroup') ->willReturn(true); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); // prime cache @@ -925,7 +929,7 @@ class ManagerTest extends TestCase { ->with('user1') ->willReturn(null); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); $groups = $manager->getUserIdGroups('user1'); @@ -951,7 +955,7 @@ class ManagerTest extends TestCase { ['group2', ['gid' => 'group2']], ]); - $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache); $manager->addBackend($backend); // group with display name diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php index c843d5f5eb9..2a753b01550 100644 --- a/tests/lib/ImageTest.php +++ b/tests/lib/ImageTest.php @@ -140,7 +140,7 @@ class ImageTest extends \Test\TestCase { $config = $this->createMock(IConfig::class); $config->expects($this->once()) ->method('getAppValue') - ->with('preview', 'jpeg_quality', 90) + ->with('preview', 'jpeg_quality', '80') ->willReturn(null); $config->expects($this->once()) ->method('getSystemValueInt') @@ -152,7 +152,7 @@ class ImageTest extends \Test\TestCase { /** @psalm-suppress InvalidScalarArgument */ imageinterlace($raw, (PHP_VERSION_ID >= 80000 ? true : 1)); ob_start(); - imagejpeg($raw); + imagejpeg($raw, null, 80); $expected = ob_get_clean(); $this->assertEquals($expected, $img->data()); diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php index e482ba3876b..a32eebcdb95 100644 --- a/tests/lib/Notification/ManagerTest.php +++ b/tests/lib/Notification/ManagerTest.php @@ -248,10 +248,10 @@ class ManagerTest extends TestCase { public function dataIsFairUseOfFreePushService(): array { return [ - [true, 499, true], - [true, 500, true], - [false, 499, true], - [false, 500, false], + [true, 999, true], + [true, 1000, true], + [false, 999, true], + [false, 1000, false], ]; } diff --git a/tests/lib/Security/VerificationToken/VerificationTokenTest.php b/tests/lib/Security/VerificationToken/VerificationTokenTest.php index 4d90e304ab7..481646f26ab 100644 --- a/tests/lib/Security/VerificationToken/VerificationTokenTest.php +++ b/tests/lib/Security/VerificationToken/VerificationTokenTest.php @@ -35,18 +35,21 @@ use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; use OCP\Security\VerificationToken\InvalidTokenException; use Test\TestCase; +use PHPUnit\Framework\MockObject\MockObject; class VerificationTokenTest extends TestCase { /** @var VerificationToken */ protected $token; - /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|MockObject */ protected $config; - /** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ISecureRandom|MockObject */ protected $secureRandom; - /** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICrypto|MockObject */ protected $crypto; - /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ITimeFactory|MockObject */ protected $timeFactory; + /** @var IJobList|MockObject */ + protected $jobList; protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index 29ae33c3c93..cc13479b1d0 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -36,24 +36,26 @@ use OCP\Settings\ISettings; use OCP\Settings\ISubAdminSettings; use Psr\Log\LoggerInterface; use Test\TestCase; +use PHPUnit\Framework\MockObject\MockObject; class ManagerTest extends TestCase { - - /** @var Manager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var Manager|MockObject */ private $manager; - /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; - /** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IDBConnection|MockObject */ private $l10n; - /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IFactory|MockObject */ private $l10nFactory; - /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IURLGenerator|MockObject */ private $url; - /** @var IServerContainer|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IServerContainer|MockObject */ private $container; - /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var AuthorizedGroupMapper|MockObject */ + private $mapper; + /** @var IGroupManager|MockObject */ private $groupManager; - /** @var ISubAdmin|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ISubAdmin|MockObject */ private $subAdmin; protected function setUp(): void { diff --git a/tests/lib/Share20/ShareTest.php b/tests/lib/Share20/ShareTest.php index 7d4dc6de2d6..b2419e07683 100644 --- a/tests/lib/Share20/ShareTest.php +++ b/tests/lib/Share20/ShareTest.php @@ -23,6 +23,7 @@ namespace Test\Share20; use OCP\Files\IRootFolder; use OCP\IUserManager; +use PHPUnit\Framework\MockObject\MockObject; /** * Class ShareTest @@ -30,9 +31,10 @@ use OCP\IUserManager; * @package Test\Share20 */ class ShareTest extends \Test\TestCase { - - /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IRootFolder|MockObject */ protected $rootFolder; + /** @var IUserManager|MockObject */ + protected $userManager; /** @var \OCP\Share\IShare */ protected $share; |