Merge pull request #27312 from francoisfreitag/tests-at

Rewrite birthday calendar tests without $this->at()
This commit is contained in:
Lukas Reschke 2021-06-01 21:05:37 +02:00 committed by GitHub
commit 446c1c5ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 16 deletions

View File

@ -82,7 +82,7 @@ class EnablePluginTest extends TestCase {
$plugin = new EnablePlugin($this->config, $this->birthdayService); $plugin = new EnablePlugin($this->config, $this->birthdayService);
$server->expects($this->at(0)) $server->expects($this->once())
->method('on') ->method('on')
->with('method:POST', [$plugin, 'httpPost']); ->with('method:POST', [$plugin, 'httpPost']);
@ -120,11 +120,11 @@ class EnablePluginTest extends TestCase {
->with('/bar/foo') ->with('/bar/foo')
->willReturn($calendarHome); ->willReturn($calendarHome);
$this->request->expects($this->at(0)) $this->request->expects($this->once())
->method('getBodyAsString') ->method('getBodyAsString')
->willReturn('<nc:disable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>'); ->willReturn('<nc:disable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
$this->request->expects($this->at(1)) $this->request->expects($this->once())
->method('getUrl') ->method('getUrl')
->willReturn('url_abc'); ->willReturn('url_abc');
@ -158,11 +158,11 @@ class EnablePluginTest extends TestCase {
->method('getOwner') ->method('getOwner')
->willReturn('principals/users/BlaBlub'); ->willReturn('principals/users/BlaBlub');
$this->request->expects($this->at(0)) $this->request->expects($this->once())
->method('getBodyAsString') ->method('getBodyAsString')
->willReturn('<nc:enable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>'); ->willReturn('<nc:enable-birthday-calendar xmlns:nc="http://nextcloud.com/ns"/>');
$this->request->expects($this->at(1)) $this->request->expects($this->once())
->method('getUrl') ->method('getUrl')
->willReturn('url_abc'); ->willReturn('url_abc');

View File

@ -96,15 +96,13 @@ class BirthdayCalendarControllerTest extends TestCase {
$closure($user3); $closure($user3);
}); });
$this->jobList->expects($this->at(0)) $this->jobList->expects($this->exactly(3))
->method('add') ->method('add')
->with(GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid1']); ->withConsecutive(
$this->jobList->expects($this->at(1)) [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid1']],
->method('add') [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid2']],
->with(GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid2']); [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid3']],
$this->jobList->expects($this->at(2)) );
->method('add')
->with(GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid3']);
$response = $this->controller->enable(); $response = $this->controller->enable();
$this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response); $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response);

View File

@ -62,7 +62,7 @@ class RegenerateBirthdayCalendarsTest extends TestCase {
} }
public function testRun() { public function testRun() {
$this->config->expects($this->at(0)) $this->config->expects($this->once())
->method('getAppValue') ->method('getAppValue')
->with('dav', 'regeneratedBirthdayCalendarsForYearFix') ->with('dav', 'regeneratedBirthdayCalendarsForYearFix')
->willReturn(null); ->willReturn(null);
@ -72,11 +72,11 @@ class RegenerateBirthdayCalendarsTest extends TestCase {
->method('info') ->method('info')
->with('Adding background jobs to regenerate birthday calendar'); ->with('Adding background jobs to regenerate birthday calendar');
$this->jobList->expects($this->at(0)) $this->jobList->expects($this->once())
->method('add') ->method('add')
->with(RegisterRegenerateBirthdayCalendars::class); ->with(RegisterRegenerateBirthdayCalendars::class);
$this->config->expects($this->at(1)) $this->config->expects($this->once())
->method('setAppValue') ->method('setAppValue')
->with('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); ->with('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');