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)); }