em = static::getContainer()->get(EntityManagerInterface::class); /** @var \PDO $pdo */ $pdo = $this->em->getConnection()->getNativeConnection(); $this->backend = new CalendarBackend($pdo); $this->em->getConnection()->beginTransaction(); } protected function tearDown(): void { $this->em->getConnection()->rollBack(); parent::tearDown(); } private function subscriptionFor(string $uri): array { foreach ($this->backend->getSubscriptionsForUser(self::PRINCIPAL) as $subscription) { if ($uri === $subscription['uri']) { return $subscription; } } $this->fail(sprintf('No subscription found for uri "%s"', $uri)); } /** * sabre only lists `calendarorder` in its INSERT when the client sent * {http://apple.com/ns/ical/}calendar-order, so the column needs a default. */ public function testSubscriptionCanBeCreatedWithoutACalendarOrder(): void { $this->backend->createSubscription(self::PRINCIPAL, 'holidays', [ '{http://calendarserver.org/ns/}source' => new Href(self::SOURCE), ]); $subscription = $this->subscriptionFor('holidays'); $this->assertSame(self::SOURCE, $subscription['source']); $this->assertSame(0, (int) $subscription['{http://apple.com/ns/ical/}calendar-order']); } public function testAnExplicitCalendarOrderIsStillHonoured(): void { $this->backend->createSubscription(self::PRINCIPAL, 'ordered', [ '{http://calendarserver.org/ns/}source' => new Href(self::SOURCE), '{http://apple.com/ns/ical/}calendar-order' => 3, ]); $this->assertSame(3, (int) $this->subscriptionFor('ordered')['{http://apple.com/ns/ical/}calendar-order']); } }