aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php')
-rw-r--r--apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php38
1 files changed, 16 insertions, 22 deletions
diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
index 888b2cdd596..769516cda85 100644
--- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
+++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
@@ -11,6 +11,7 @@ use OCP\Federation\ICloudId;
use OCP\Federation\ICloudIdManager;
use OCP\IDBConnection;
use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -24,20 +25,9 @@ use Test\TestCase;
*/
class CleanupRemoteStoragesTest extends TestCase {
- /**
- * @var CleanupRemoteStorages
- */
- private $command;
-
- /**
- * @var IDBConnection
- */
- private $connection;
-
- /**
- * @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject
- */
- private $cloudIdManager;
+ protected IDBConnection $connection;
+ protected CleanupRemoteStorages $command;
+ private ICloudIdManager&MockObject $cloudIdManager;
private $storages = [
['id' => 'shared::7b4a322b22f9d0047c38d77d471ce3cf', 'share_token' => 'f2c69dad1dc0649f26976fd210fc62e1', 'remote' => 'https://hostname.tld/owncloud1', 'user' => 'user1'],
@@ -77,7 +67,7 @@ class CleanupRemoteStoragesTest extends TestCase {
foreach ($this->storages as &$storage) {
if (isset($storage['id'])) {
$storageQuery->setParameter('id', $storage['id']);
- $storageQuery->execute();
+ $storageQuery->executeStatement();
$storage['numeric_id'] = $storageQuery->getLastInsertId();
}
@@ -121,13 +111,13 @@ class CleanupRemoteStoragesTest extends TestCase {
foreach ($this->storages as $storage) {
if (isset($storage['id'])) {
$storageQuery->setParameter('id', $storage['id']);
- $storageQuery->execute();
+ $storageQuery->executeStatement();
}
if (isset($storage['share_token'])) {
$shareExternalQuery->setParameter('share_token', $storage['share_token']);
$shareExternalQuery->setParameter('remote', $storage['remote']);
- $shareExternalQuery->execute();
+ $shareExternalQuery->executeStatement();
}
}
@@ -174,14 +164,13 @@ class CleanupRemoteStoragesTest extends TestCase {
->getMock();
// parent folder, `files`, ´test` and `welcome.txt` => 4 elements
-
+ $outputCalls = [];
$output
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['5 remote storage(s) need(s) to be checked'],
- ['5 remote share(s) exist'],
- );
+ ->willReturnCallback(function (string $text) use (&$outputCalls) {
+ $outputCalls[] = $text;
+ });
$this->cloudIdManager
->expects($this->any())
@@ -206,5 +195,10 @@ class CleanupRemoteStoragesTest extends TestCase {
$this->assertFalse($this->doesStorageExist($this->storages[3]['numeric_id']));
$this->assertTrue($this->doesStorageExist($this->storages[4]['numeric_id']));
$this->assertFalse($this->doesStorageExist($this->storages[5]['numeric_id']));
+
+ $this->assertEquals([
+ '5 remote storage(s) need(s) to be checked',
+ '5 remote share(s) exist',
+ ], array_slice($outputCalls, 0, 2));
}
}