From ce48a7e0175a38e9cae04ea7da24e533e3b807db Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 27 Oct 2023 11:50:27 +0200 Subject: [PATCH] fixup! fix(provisioning): Clean up orphaned accounts Signed-off-by: Christoph Wurst --- lib/Db/MailAccount.php | 2 +- tests/Integration/Db/MailAccountMapperTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Db/MailAccount.php b/lib/Db/MailAccount.php index 3744b1414a..c7470eda44 100644 --- a/lib/Db/MailAccount.php +++ b/lib/Db/MailAccount.php @@ -65,7 +65,7 @@ * @method string getEditorMode() * @method void setEditorMode(string $editorMode) * @method int|null getProvisioningId() - * @method void setProvisioningId(int $provisioningId) + * @method void setProvisioningId(int|null $provisioningId) * @method int getOrder() * @method void setOrder(int $order) * @method bool|null getShowSubscribedOnly() diff --git a/tests/Integration/Db/MailAccountMapperTest.php b/tests/Integration/Db/MailAccountMapperTest.php index ab78297db8..322432b0c0 100644 --- a/tests/Integration/Db/MailAccountMapperTest.php +++ b/tests/Integration/Db/MailAccountMapperTest.php @@ -28,10 +28,13 @@ use OC; use OCA\Mail\Db\MailAccount; use OCA\Mail\Db\MailAccountMapper; +use OCP\AppFramework\Db\DoesNotExistException; use OCP\IDBConnection; +use function random_int; /** * @group DB + * @covers \OCA\Mail\Db\MailAccountMapper */ class MailAccountMapperTest extends TestCase { use DatabaseTransaction; @@ -106,4 +109,14 @@ public function testSave() { $this->assertNotNull($b->getId()); $this->assertEquals($b->getId(), $c->getId()); } + + public function testDeleteProvisionedOrphans(): void { + $this->account->setProvisioningId(random_int(1, 10000)); + $this->mapper->insert($this->account); + + $this->mapper->deleteProvisionedOrphanAccounts(); + + $this->expectException(DoesNotExistException::class); + $this->mapper->findById($this->account->getId()); + } }