From f41f4e8b3dbe1d9b2c6b13019955367164b163a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 21 Jun 2023 20:33:59 +0200 Subject: [PATCH] fixup! fixup! fixup! fixup! fix: Delete inactive sessions in one query --- tests/unit/Db/SessionMapperTest.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/unit/Db/SessionMapperTest.php b/tests/unit/Db/SessionMapperTest.php index 2bed03465e3..77dc17f6a8f 100644 --- a/tests/unit/Db/SessionMapperTest.php +++ b/tests/unit/Db/SessionMapperTest.php @@ -77,11 +77,11 @@ public function testDeleteInactiveWithoutStepsKeep() { self::assertCount(0, $this->sessionMapper->findAll(2)); } - public function testDeleteInactiveWithoutSteps1010() { + public function testDeleteInactiveWithoutStepsMultiple() { $this->sessionMapper->deleteByDocumentId(1); - \OC::$server->getDatabaseConnection()->beginTransaction(); - for ($i = 0;$i < 1010;$i++) { + $count = 10; + for ($i = 0;$i < $count;$i++) { $this->sessionMapper->insert(Session::fromParams([ 'userId' => 'admin', 'documentId' => 1, @@ -90,15 +90,11 @@ public function testDeleteInactiveWithoutSteps1010() { 'color' => '00ff00', ])); } - \OC::$server->getDatabaseConnection()->commit(); - self::assertCount(1010, $this->sessionMapper->findAll(1)); + self::assertCount($count, $this->sessionMapper->findAll(1)); - sleep(1); - - \OC::$server->getDatabaseConnection()->beginTransaction(); - $this->sessionMapper->deleteInactiveWithoutSteps(1); - \OC::$server->getDatabaseConnection()->commit(); + $deleted = $this->sessionMapper->deleteInactiveWithoutSteps(); + self::assertEquals($count, $deleted); self::assertCount(0, $this->sessionMapper->findAll(1)); }