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

github.com/nextcloud/calendar.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnna Larch <anna@nextcloud.com>2021-11-23 21:27:08 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-11-25 18:06:32 +0300
commit34743dbb1a316e430b3830ba8838b31e27c153cc (patch)
treeec28b4ea35a9f6b730877bb567b102386031bc21 /tests
parent3fe1fe790a0adf8364c442b0857c272453ad2932 (diff)
Removed times 60 multiplier for appointments
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/php/integration/Db/AppointmentConfigMapperTest.php24
-rw-r--r--tests/php/unit/BackgroundJob/CleanupOutdatedBookingJobTest.php2
-rw-r--r--tests/php/unit/Controller/AppointmentConfigControllerTest.php40
-rw-r--r--tests/php/unit/Service/Appointments/AvailabilityGeneratorTest.php39
-rw-r--r--tests/php/unit/Service/Appointments/SlotExtrapolatorTest.php30
5 files changed, 68 insertions, 67 deletions
diff --git a/tests/php/integration/Db/AppointmentConfigMapperTest.php b/tests/php/integration/Db/AppointmentConfigMapperTest.php
index 15b00306..c1bb7566 100644
--- a/tests/php/integration/Db/AppointmentConfigMapperTest.php
+++ b/tests/php/integration/Db/AppointmentConfigMapperTest.php
@@ -70,8 +70,8 @@ class AppointmentConfigMapperTest extends TestCase {
$appointment->setToken('okens');
$appointment->setName('Test 2');
$appointment->setDescription('Test Description');
- $appointment->setIncrement(15);
- $appointment->setLength(60);
+ $appointment->setIncrement(15 * 60);
+ $appointment->setLength(60 * 60);
$appointment->setTargetCalendarUri('testuri');
$appointment->setVisibility(AppointmentConfig::VISIBILITY_PUBLIC);
$appointment->setUserId('testuser');
@@ -87,9 +87,9 @@ class AppointmentConfigMapperTest extends TestCase {
$this->assertObjectHasAttribute('description', $appointment);
$this->assertEquals('Test Description', $appointment->getDescription());
$this->assertObjectHasAttribute('increment', $appointment);
- $this->assertEquals(15, $appointment->getIncrement());
+ $this->assertEquals(15 * 60, $appointment->getIncrement());
$this->assertObjectHasAttribute('length', $appointment);
- $this->assertEquals(60, $appointment->getLength());
+ $this->assertEquals(60 * 60, $appointment->getLength());
$this->assertObjectHasAttribute('targetCalendarUri', $appointment);
$this->assertEquals('testuri', $appointment->getTargetCalendarUri());
$this->assertObjectHasAttribute('visibility', $appointment);
@@ -106,8 +106,8 @@ class AppointmentConfigMapperTest extends TestCase {
$appointment->setToken('okensdsadsas');
$appointment->setName('Test 2');
$appointment->setDescription('Test Description');
- $appointment->setIncrement(15);
- $appointment->setLength(60);
+ $appointment->setIncrement(15 * 60);
+ $appointment->setLength(60 * 60);
$appointment->setTargetCalendarUri('testuri');
$appointment->setVisibility(AppointmentConfig::VISIBILITY_PUBLIC);
$appointment->setUserId('testuser');
@@ -123,9 +123,9 @@ class AppointmentConfigMapperTest extends TestCase {
$this->assertObjectHasAttribute('description', $appointment);
$this->assertEquals('Test Description', $appointment->getDescription());
$this->assertObjectHasAttribute('increment', $appointment);
- $this->assertEquals(15, $appointment->getIncrement());
+ $this->assertEquals(15 * 60, $appointment->getIncrement());
$this->assertObjectHasAttribute('length', $appointment);
- $this->assertEquals(60, $appointment->getLength());
+ $this->assertEquals(60 * 60, $appointment->getLength());
$this->assertObjectHasAttribute('targetCalendarUri', $appointment);
$this->assertEquals('testuri', $appointment->getTargetCalendarUri());
$this->assertObjectHasAttribute('visibility', $appointment);
@@ -139,8 +139,8 @@ class AppointmentConfigMapperTest extends TestCase {
$appointment->setToken('frokns');
$appointment->setName('Test 3');
$appointment->setDescription('Test Description');
- $appointment->setIncrement(15);
- $appointment->setLength(60);
+ $appointment->setIncrement(15 * 60);
+ $appointment->setLength(60 * 60);
$appointment->setTargetCalendarUri('testuri');
$appointment->setVisibility(AppointmentConfig::VISIBILITY_PUBLIC);
$appointment->setUserId('testuser');
@@ -161,8 +161,8 @@ class AppointmentConfigMapperTest extends TestCase {
$appointment->setToken('frokns');
$appointment->setName('Test 2');
$appointment->setDescription('Test Description');
- $appointment->setIncrement(15);
- $appointment->setLength(60);
+ $appointment->setIncrement(15 * 60);
+ $appointment->setLength(60 * 60);
$appointment->setTargetCalendarUri('testuri');
$appointment->setVisibility(AppointmentConfig::VISIBILITY_PUBLIC);
$appointment->setUserId('testuser');
diff --git a/tests/php/unit/BackgroundJob/CleanupOutdatedBookingJobTest.php b/tests/php/unit/BackgroundJob/CleanupOutdatedBookingJobTest.php
index 9f27ffbf..16f4b82a 100644
--- a/tests/php/unit/BackgroundJob/CleanupOutdatedBookingJobTest.php
+++ b/tests/php/unit/BackgroundJob/CleanupOutdatedBookingJobTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
*
*/
+use ChristophWurst\Nextcloud\Testing\TestCase;
use OC\BackgroundJob\JobList;
use OCA\Calendar\BackgroundJob\CleanUpOutdatedBookingsJob;
use OCA\Calendar\Service\Appointments\BookingService;
@@ -31,7 +32,6 @@ use OCP\Calendar\ICalendarQuery;
use OCP\ILogger;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-use Test\TestCase;
class CleanupOutdatedBookingJobTest extends TestCase {
diff --git a/tests/php/unit/Controller/AppointmentConfigControllerTest.php b/tests/php/unit/Controller/AppointmentConfigControllerTest.php
index 27464c47..1104a1d8 100644
--- a/tests/php/unit/Controller/AppointmentConfigControllerTest.php
+++ b/tests/php/unit/Controller/AppointmentConfigControllerTest.php
@@ -137,8 +137,8 @@ class AppointmentConfigControllerTest extends TestCase {
$appointment->setLocation('Test');
$appointment->setVisibility('PUBLIC');
$appointment->setTargetCalendarUri('test');
- $appointment->setLength(5);
- $appointment->setIncrement(5);
+ $appointment->setLength(5 * 60);
+ $appointment->setIncrement(5 * 60);
$this->service->expects($this->once())
->method('create')
@@ -152,8 +152,8 @@ class AppointmentConfigControllerTest extends TestCase {
'PUBLIC',
'test',
null,
- 5,
- 5
+ 5 * 60,
+ 5 * 60
);
$this->assertEquals(200, $response->getStatus());
@@ -166,8 +166,8 @@ class AppointmentConfigControllerTest extends TestCase {
$appointment->setLocation('Test');
$appointment->setVisibility('PUBLIC');
$appointment->setTargetCalendarUri('test');
- $appointment->setLength(5);
- $appointment->setIncrement(5);
+ $appointment->setLength(5 * 60);
+ $appointment->setIncrement(5 * 60);
$this->service->expects($this->once())
->method('create')
@@ -181,8 +181,8 @@ class AppointmentConfigControllerTest extends TestCase {
'PUBLIC',
'test',
null,
- 5,
- 5
+ 5 * 60,
+ 5 * 60
);
$this->assertEquals(500, $response->getStatus());
@@ -196,8 +196,8 @@ class AppointmentConfigControllerTest extends TestCase {
$appointment->setLocation('Test');
$appointment->setVisibility('PUBLIC');
$appointment->setTargetCalendarUri('test');
- $appointment->setLength(5);
- $appointment->setIncrement(5);
+ $appointment->setLength(5 * 60);
+ $appointment->setIncrement(5 * 60);
$this->service->expects($this->once())
->method('findByIdAndUser')
@@ -217,8 +217,8 @@ class AppointmentConfigControllerTest extends TestCase {
'PUBLIC',
'test',
null,
- 5,
- 5
+ 5 * 60,
+ 5 * 60
);
$this->assertEquals(200, $response->getStatus());
@@ -232,8 +232,8 @@ class AppointmentConfigControllerTest extends TestCase {
$appointment->setLocation('Test');
$appointment->setVisibility('PUBLIC');
$appointment->setTargetCalendarUri('test');
- $appointment->setLength(5);
- $appointment->setIncrement(5);
+ $appointment->setLength(5 * 60);
+ $appointment->setIncrement(5 * 60);
$this->service->expects($this->once())
->method('findByIdAndUser')
@@ -247,8 +247,8 @@ class AppointmentConfigControllerTest extends TestCase {
'PUBLIC',
'test',
null,
- 5,
- 5
+ 5 * 60,
+ 5 * 60
);
$this->assertEquals(500, $response->getStatus());
@@ -262,8 +262,8 @@ class AppointmentConfigControllerTest extends TestCase {
$appointment->setLocation('Test');
$appointment->setVisibility('PUBLIC');
$appointment->setTargetCalendarUri('test');
- $appointment->setLength(5);
- $appointment->setIncrement(5);
+ $appointment->setLength(5 * 60);
+ $appointment->setIncrement(5 * 60);
$this->service->expects($this->once())
->method('update')
@@ -277,8 +277,8 @@ class AppointmentConfigControllerTest extends TestCase {
'PUBLIC',
'test',
null,
- 5,
- 5
+ 5 * 60,
+ 5 * 60
);
$this->assertEquals(403, $response->getStatus());
diff --git a/tests/php/unit/Service/Appointments/AvailabilityGeneratorTest.php b/tests/php/unit/Service/Appointments/AvailabilityGeneratorTest.php
index f6e46190..e1389d6c 100644
--- a/tests/php/unit/Service/Appointments/AvailabilityGeneratorTest.php
+++ b/tests/php/unit/Service/Appointments/AvailabilityGeneratorTest.php
@@ -59,7 +59,7 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilitySet(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability(null);
$slots = $this->generator->generate($config, 1 * 3600, 2 * 3600);
@@ -72,7 +72,7 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilitySetRoundToFive(): void {
$config = new AppointmentConfig();
- $config->setLength(47);
+ $config->setLength(47 * 60);
$config->setAvailability(null);
$slots = $this->generator->generate($config, (int)2.8 * 3600, 4 * 3600);
@@ -83,8 +83,8 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilitySetRoundWithIncrement(): void {
$config = new AppointmentConfig();
- $config->setLength(90);
- $config->setIncrement(60);
+ $config->setLength(90 * 60);
+ $config->setIncrement(60 * 60);
$config->setAvailability(null);
$slots = $this->generator->generate($config, 1 * 5400, 2 * 5400);
@@ -95,7 +95,7 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilitySetRoundWithPrettyNumbers(): void {
$config = new AppointmentConfig();
- $config->setLength(90);
+ $config->setLength(90 * 60);
$config->setAvailability(null);
$slots = $this->generator->generate($config, 1 * 5400 + 1, 2 * 5400 + 1);
@@ -107,7 +107,7 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilitySetRoundWithFourtyMinutes(): void {
$config = new AppointmentConfig();
- $config->setLength(40);
+ $config->setLength(40 * 60);
$config->setAvailability(null);
$slots = $this->generator->generate($config, 1 * 2400, 2 * 2400);
@@ -118,7 +118,7 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilitySetRoundWithFourtyMinutesNotPretty(): void {
$config = new AppointmentConfig();
- $config->setLength(40);
+ $config->setLength(40 * 60);
$config->setAvailability(null);
$slots = $this->generator->generate($config, 1 * 2400 +1, 2 * 2400+1);
@@ -130,7 +130,7 @@ class AvailabilityGeneratorTest extends TestCase {
public function testNoAvailabilityButEndDate(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability(null);
$config->setEnd(10*3600);
@@ -146,7 +146,7 @@ class AvailabilityGeneratorTest extends TestCase {
$this->timeFactory->method('getTime')
->willReturn(15*3600);
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability(null);
$config->setEnd(10*3600);
@@ -194,7 +194,7 @@ class AvailabilityGeneratorTest extends TestCase {
$array = json_encode($testData, JSON_THROW_ON_ERROR);
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability($array);
$wednesdayMidnight = (new DateTimeImmutable())->setDate(2021, 11, 3)->setTime(0, 0);
@@ -244,13 +244,14 @@ class AvailabilityGeneratorTest extends TestCase {
$array = json_encode($testData, JSON_THROW_ON_ERROR);
$config = new AppointmentConfig();
- $config->setLength(60);
- $config->setAvailability($array);
+ $config->setLength(60 * 60
+ );
+ $config->setAvailability('RRULE:FREQ=MINUTELY;INTERVAL=15;WKST=MO;BYDAY=MO;BYHOUR=8,9,10,11');
- $wednesdayMidnight = (new DateTimeImmutable())->setDate(2021, 11, 3)->setTime(0, 0);
- $thursdayMidnight = $wednesdayMidnight->modify('+1 day');
+ $mondayMidnight = (new DateTimeImmutable())->setDate(2021, 11, 1)->setTime(0, 0);
+ $sundayMidnight = $mondayMidnight->modify('+7 days');
- $slots = $this->generator->generate($config, $wednesdayMidnight->getTimestamp(), $thursdayMidnight->getTimestamp());
+ $slots = $this->generator->generate($config, $mondayMidnight->getTimestamp(), $sundayMidnight->getTimestamp());
self::assertCount(1, $slots);
}
@@ -293,7 +294,7 @@ class AvailabilityGeneratorTest extends TestCase {
$array = json_encode($testData, JSON_THROW_ON_ERROR);
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability($array);
$wednesdayMidnight = (new DateTimeImmutable())->setDate(2021, 11, 3)->setTime(0, 0);
@@ -344,7 +345,7 @@ class AvailabilityGeneratorTest extends TestCase {
$array = json_encode($testData, JSON_THROW_ON_ERROR);
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability($array);
$wednesdayMidnight = (new DateTimeImmutable())->setTimezone($tz)->setDate(2021, 11, 3)->setTime(0, 0);
@@ -393,7 +394,7 @@ class AvailabilityGeneratorTest extends TestCase {
$array = json_encode($testData, JSON_THROW_ON_ERROR);
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability($array);
$auckland = new DateTimeZone('Pacific/Auckland');
@@ -444,7 +445,7 @@ class AvailabilityGeneratorTest extends TestCase {
$array = json_encode($testData, JSON_THROW_ON_ERROR);
$config = new AppointmentConfig();
- $config->setLength(60);
+ $config->setLength(60 * 60);
$config->setAvailability($array);
$auckland = new DateTimeZone('Pacific/Auckland');
diff --git a/tests/php/unit/Service/Appointments/SlotExtrapolatorTest.php b/tests/php/unit/Service/Appointments/SlotExtrapolatorTest.php
index fefd56f1..6630ca53 100644
--- a/tests/php/unit/Service/Appointments/SlotExtrapolatorTest.php
+++ b/tests/php/unit/Service/Appointments/SlotExtrapolatorTest.php
@@ -48,8 +48,8 @@ class SlotExtrapolatorTest extends TestCase {
public function testNoAvailability(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
- $config->setIncrement(15);
+ $config->setLength(60 * 60);
+ $config->setIncrement(15 * 60);
$availabilityIntervals = [];
$slots = $this->extrapolator->extrapolate($config, $availabilityIntervals);
@@ -62,10 +62,10 @@ class SlotExtrapolatorTest extends TestCase {
*/
public function testNoneFits(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
- $config->setIncrement(15);
+ $config->setLength(60 * 60);
+ $config->setIncrement(15 * 60);
$availabilityIntervals = [
- new Interval(0, 30 * 60),
+ new Interval(0, 30 * 60 * 60),
];
$slots = $this->extrapolator->extrapolate($config, $availabilityIntervals);
@@ -78,10 +78,10 @@ class SlotExtrapolatorTest extends TestCase {
*/
public function testExactlyOne(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
- $config->setIncrement(15);
+ $config->setLength(60 * 60);
+ $config->setIncrement(15 * 60);
$availabilityIntervals = [
- new Interval(0, 60 * 60),
+ new Interval(0, 60 * 60 *60),
];
$slots = $this->extrapolator->extrapolate($config, $availabilityIntervals);
@@ -94,10 +94,10 @@ class SlotExtrapolatorTest extends TestCase {
*/
public function testOverlaps(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
- $config->setIncrement(15);
+ $config->setLength(60 * 60);
+ $config->setIncrement(15 * 60);
$availabilityIntervals = [
- new Interval(0, 90 * 60),
+ new Interval(0, 90 * 60 * 60),
];
$slots = $this->extrapolator->extrapolate($config, $availabilityIntervals);
@@ -110,11 +110,11 @@ class SlotExtrapolatorTest extends TestCase {
*/
public function testMultipleIntervals(): void {
$config = new AppointmentConfig();
- $config->setLength(60);
- $config->setIncrement(15);
+ $config->setLength(60 * 60);
+ $config->setIncrement(15 * 60);
$availabilityIntervals = [
- new Interval(0, 60 * 60),
- new Interval(100 * 60, 160 * 60),
+ new Interval(0, 60 * 60 * 60),
+ new Interval(100 * 60 * 60, 160 * 60 * 60),
];
$slots = $this->extrapolator->extrapolate($config, $availabilityIntervals);