Skip to content

Commit

Permalink
test(Behat): remove table from collection manager upon delete
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz authored and backportbot[bot] committed Oct 16, 2024
1 parent e0c7614 commit ad3af8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/integration/features/bootstrap/CollectionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

/**
Expand Down Expand Up @@ -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']);
}
}

/**
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit ad3af8f

Please sign in to comment.