summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-03-10 12:13:47 +0100
committerJoas Schilling <coding@schilljs.com>2023-03-13 11:41:36 +0100
commitc7400fa4d55f542ca4616e7eb1c6b8f6e7d89695 (patch)
tree70076b0d8124c37bf41791460326cec6b079f26a
parentc3c3dcbcd9ff9b8aa9c68a5b7b19507c2c334e40 (diff)
downloadnextcloud-server-c7400fa4d55f542ca4616e7eb1c6b8f6e7d89695.tar.gz
nextcloud-server-c7400fa4d55f542ca4616e7eb1c6b8f6e7d89695.zip
fix(CI): Add unit test for nextcloud/server#37167
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php47
1 files changed, 46 insertions, 1 deletions
diff --git a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
index 46b895bdd46..59438c7cd28 100644
--- a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
@@ -154,6 +154,51 @@ END:VCALENDAR');
->with('user', IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND, true);
}
- $this->invokePrivate($automation, 'run', [['userId' => 'user']]);
+ self::invokePrivate($automation, 'run', [['userId' => 'user']]);
+ }
+
+ public function testRunNoMoreAvailabilityDefined(): void {
+ $this->config->method('getUserValue')
+ ->with('user', 'dav', 'user_status_automation', 'no')
+ ->willReturn('yes');
+
+ $this->time->method('getDateTime')
+ ->willReturn(new \DateTime('2023-02-24 13:58:24.479357', new \DateTimeZone('UTC')));
+
+ $automation = $this->getAutomationMock(['getAvailabilityFromPropertiesTable']);
+ $automation->method('getAvailabilityFromPropertiesTable')
+ ->with('user')
+ ->willReturn('BEGIN:VCALENDAR
+PRODID:Nextcloud DAV app
+BEGIN:VTIMEZONE
+TZID:Europe/Berlin
+BEGIN:STANDARD
+TZNAME:CET
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+DTSTART:19701025T030000
+RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
+END:STANDARD
+BEGIN:DAYLIGHT
+TZNAME:CEST
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+DTSTART:19700329T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VAVAILABILITY
+END:VAVAILABILITY
+END:VCALENDAR');
+
+ $this->statusManager->expects($this->once())
+ ->method('revertUserStatus')
+ ->with('user', IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND);
+
+ $this->jobList->expects($this->once())
+ ->method('remove')
+ ->with(UserStatusAutomation::class, ['userId' => 'user']);
+
+ self::invokePrivate($automation, 'run', [['userId' => 'user']]);
}
}