Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2022-08-04 10:58:26 +0300
committerGitHub <noreply@github.com>2022-08-04 10:58:26 +0300
commit7e7dcdaf178ba55bdd6af65cfe70aca72c7c3096 (patch)
tree90934e12d2f86265886a84390a97a85b8cb4d11e
parentf30d23b92e06b140d2bb7de4b9d6fcb7909eb5ec (diff)
parent539162ba8ba7f8d1902310000b8ce2284f2124fd (diff)
Merge pull request #33435 from nextcloud/fix/remove-at-matchers-in-tests
Remove at matchers from tests in oauth2 and tests/Test
-rw-r--r--apps/oauth2/tests/Controller/SettingsControllerTest.php11
-rw-r--r--tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php50
-rw-r--r--tests/Test/Repair/Owncloud/CleanPreviewsTest.php21
-rw-r--r--tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php30
4 files changed, 49 insertions, 63 deletions
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php
index 4954d379f9d..216655190ae 100644
--- a/apps/oauth2/tests/Controller/SettingsControllerTest.php
+++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php
@@ -72,15 +72,12 @@ class SettingsControllerTest extends TestCase {
public function testAddClient() {
$this->secureRandom
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('generate')
->with(64, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
- ->willReturn('MySecret');
- $this->secureRandom
- ->expects($this->at(1))
- ->method('generate')
- ->with(64, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')
- ->willReturn('MyClientIdentifier');
+ ->willReturnOnConsecutiveCalls(
+ 'MySecret',
+ 'MyClientIdentifier');
$client = new Client();
$client->setName('My Client Name');
diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
index 8ecef60c35d..3c15d51fd61 100644
--- a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
+++ b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
@@ -107,12 +107,12 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$this->equalTo(['uid' => 'myuid'])
);
- $this->logger->expects($this->at(0))
+ $this->logger->expects($this->exactly(2))
->method('info')
- ->with($this->equalTo('Started preview cleanup for myuid'));
- $this->logger->expects($this->at(1))
- ->method('info')
- ->with($this->equalTo('New preview cleanup scheduled for myuid'));
+ ->withConsecutive(
+ [$this->equalTo('Started preview cleanup for myuid')],
+ [$this->equalTo('New preview cleanup scheduled for myuid')],
+ );
$this->job->run(['uid' => 'myuid']);
}
@@ -146,12 +146,12 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$this->jobList->expects($this->never())
->method('add');
- $this->logger->expects($this->at(0))
- ->method('info')
- ->with($this->equalTo('Started preview cleanup for myuid'));
- $this->logger->expects($this->at(1))
+ $this->logger->expects($this->exactly(2))
->method('info')
- ->with($this->equalTo('Preview cleanup done for myuid'));
+ ->withConsecutive(
+ [$this->equalTo('Started preview cleanup for myuid')],
+ [$this->equalTo('Preview cleanup done for myuid')],
+ );
$thumbnailFolder->expects($this->once())
->method('delete');
@@ -165,12 +165,12 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
->with($this->equalTo('myuid'))
->willThrowException(new NotFoundException());
- $this->logger->expects($this->at(0))
- ->method('info')
- ->with($this->equalTo('Started preview cleanup for myuid'));
- $this->logger->expects($this->at(1))
+ $this->logger->expects($this->exactly(2))
->method('info')
- ->with($this->equalTo('Preview cleanup done for myuid'));
+ ->withConsecutive(
+ [$this->equalTo('Started preview cleanup for myuid')],
+ [$this->equalTo('Preview cleanup done for myuid')],
+ );
$this->job->run(['uid' => 'myuid']);
}
@@ -189,12 +189,12 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
->with($this->equalTo('thumbnails'))
->willThrowException(new NotFoundException());
- $this->logger->expects($this->at(0))
- ->method('info')
- ->with($this->equalTo('Started preview cleanup for myuid'));
- $this->logger->expects($this->at(1))
+ $this->logger->expects($this->exactly(2))
->method('info')
- ->with($this->equalTo('Preview cleanup done for myuid'));
+ ->withConsecutive(
+ [$this->equalTo('Started preview cleanup for myuid')],
+ [$this->equalTo('Preview cleanup done for myuid')],
+ );
$this->job->run(['uid' => 'myuid']);
}
@@ -229,12 +229,12 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$this->jobList->expects($this->never())
->method('add');
- $this->logger->expects($this->at(0))
+ $this->logger->expects($this->exactly(2))
->method('info')
- ->with($this->equalTo('Started preview cleanup for myuid'));
- $this->logger->expects($this->at(1))
- ->method('info')
- ->with($this->equalTo('Preview cleanup done for myuid'));
+ ->withConsecutive(
+ [$this->equalTo('Started preview cleanup for myuid')],
+ [$this->equalTo('Preview cleanup done for myuid')],
+ );
$thumbnailFolder->expects($this->once())
->method('delete')
diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsTest.php
index abd166057be..7a6c374a2d7 100644
--- a/tests/Test/Repair/Owncloud/CleanPreviewsTest.php
+++ b/tests/Test/Repair/Owncloud/CleanPreviewsTest.php
@@ -79,18 +79,17 @@ class CleanPreviewsTest extends TestCase {
$function($user2);
}));
- $this->jobList->expects($this->at(0))
+ $this->jobList->expects($this->exactly(2))
->method('add')
- ->with(
- $this->equalTo(CleanPreviewsBackgroundJob::class),
- $this->equalTo(['uid' => 'user1'])
- );
-
- $this->jobList->expects($this->at(1))
- ->method('add')
- ->with(
- $this->equalTo(CleanPreviewsBackgroundJob::class),
- $this->equalTo(['uid' => 'user2'])
+ ->withConsecutive(
+ [
+ $this->equalTo(CleanPreviewsBackgroundJob::class),
+ $this->equalTo(['uid' => 'user1'])
+ ],
+ [
+ $this->equalTo(CleanPreviewsBackgroundJob::class),
+ $this->equalTo(['uid' => 'user2'])
+ ],
);
$this->config->expects($this->once())
diff --git a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php
index 3b0b2f57f5f..b5d339eef2f 100644
--- a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php
+++ b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php
@@ -96,27 +96,17 @@ class UpdateLanguageCodesTest extends TestCase {
/** @var IOutput|\PHPUnit_Framework_MockObject_MockObject $outputMock */
$outputMock = $this->createMock(IOutput::class);
- $outputMock->expects($this->at(0))
+ $outputMock->expects($this->exactly(7))
->method('info')
- ->with('Changed 1 setting(s) from "bg_BG" to "bg" in preferences table.');
- $outputMock->expects($this->at(1))
- ->method('info')
- ->with('Changed 0 setting(s) from "cs_CZ" to "cs" in preferences table.');
- $outputMock->expects($this->at(2))
- ->method('info')
- ->with('Changed 1 setting(s) from "fi_FI" to "fi" in preferences table.');
- $outputMock->expects($this->at(3))
- ->method('info')
- ->with('Changed 0 setting(s) from "hu_HU" to "hu" in preferences table.');
- $outputMock->expects($this->at(4))
- ->method('info')
- ->with('Changed 0 setting(s) from "nb_NO" to "nb" in preferences table.');
- $outputMock->expects($this->at(5))
- ->method('info')
- ->with('Changed 0 setting(s) from "sk_SK" to "sk" in preferences table.');
- $outputMock->expects($this->at(6))
- ->method('info')
- ->with('Changed 2 setting(s) from "th_TH" to "th" in preferences table.');
+ ->withConsecutive(
+ ['Changed 1 setting(s) from "bg_BG" to "bg" in preferences table.'],
+ ['Changed 0 setting(s) from "cs_CZ" to "cs" in preferences table.'],
+ ['Changed 1 setting(s) from "fi_FI" to "fi" in preferences table.'],
+ ['Changed 0 setting(s) from "hu_HU" to "hu" in preferences table.'],
+ ['Changed 0 setting(s) from "nb_NO" to "nb" in preferences table.'],
+ ['Changed 0 setting(s) from "sk_SK" to "sk" in preferences table.'],
+ ['Changed 2 setting(s) from "th_TH" to "th" in preferences table.'],
+ );
$this->config->expects($this->once())
->method('getSystemValue')