From ad3af8fb2bc282861469045f75ff79febc8220ad Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 15 Oct 2024 16:05:13 +0200 Subject: [PATCH] test(Behat): remove table from collection manager upon delete Signed-off-by: Arthur Schiwon --- .../features/bootstrap/CollectionManager.php | 3 ++- .../integration/features/bootstrap/FeatureContext.php | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/integration/features/bootstrap/CollectionManager.php b/tests/integration/features/bootstrap/CollectionManager.php index 0fd53a581..4e1bf3111 100644 --- a/tests/integration/features/bootstrap/CollectionManager.php +++ b/tests/integration/features/bootstrap/CollectionManager.php @@ -44,7 +44,8 @@ public function forget(string $type, int $id, ?string $alias = null): void { if ($alias) { unset($this->mapByAlias[$this->makeKey($type, $alias)]); } - unset($this->itemsById[$this->makeKey($type, $id)]); + $idKey = $this->makeKey($type, $id); + unset($this->cleanUp[$idKey], $this->itemsById[$idKey]); } public function cleanUp(): void { diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index fe0843d78..e3b2f1128 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -318,6 +318,9 @@ public function transferTableV2(string $user, string $newUser, string $tableName Assert::assertEquals(200, $this->response->getStatusCode()); Assert::assertEquals($updatedTable['ownership'], $newUser); + $this->collectionManager->update($updatedTable, 'table', $updatedTable['id'], function () use ($newUser, $tableName): void { + $this->deleteTableV2($newUser, $tableName); + }); } /** @@ -367,6 +370,9 @@ public function deleteTableV2(string $user, string $tableName): void { Assert::assertEquals(404, $this->response->getStatusCode()); unset($this->tableIds[$tableName]); + if ($table = $this->collectionManager->getByAlias('table', $tableName)) { + $this->collectionManager->forget('table', $table['id']); + } } /** @@ -915,6 +921,10 @@ public function deleteTable(string $user, string $keyword): void { Assert::assertEquals($deletedTable['title'], $table['title']); Assert::assertEquals($deletedTable['id'], $table['id']); + if ($tableItem = $this->collectionManager->getById('table', $table['id'])) { + $this->collectionManager->forget('table', $tableItem['id']); + } + $this->sendRequest( 'GET', '/apps/tables/api/1/tables/'.$deletedTable['id'],