Skip to content

Commit 0249a3a

Browse files
committed
tests(Import): Add regression test for importing the same file twice
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 645d90d commit 0249a3a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/HtmlImportExportTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,33 @@ public function testImportFile(string $file): void {
112112
$this->assertEquals(1231231234, $firstBookmark->getAdded());
113113
}
114114

115+
/**
116+
* Re-importing the same file must not fail: every bookmark already exists,
117+
* so the importer takes the unique-constraint -> update path for each one.
118+
* This used to break the import transaction and raise a 500
119+
* ("cannot commit transaction - SQL statements in progress").
120+
*
121+
* @dataProvider importProvider
122+
* @param string $file
123+
* @throws DoesNotExistException
124+
* @throws MultipleObjectsReturnedException
125+
* @throws UnauthorizedAccessError
126+
* @throws AlreadyExistsError
127+
* @throws UserLimitExceededError
128+
* @throws HtmlParseError
129+
*/
130+
public function testReimportFile(string $file): void {
131+
$this->htmlImporter->importFile($this->userId, $file);
132+
// Second import hits the duplicate-URL update path for every bookmark
133+
$result = $this->htmlImporter->importFile($this->userId, $file);
134+
135+
$this->assertEmpty($result['errors']);
136+
137+
$firstBookmark = $this->bookmarkMapper->find($result['imported'][0]['children'][0]['id']);
138+
$this->assertSame('Title 0', $firstBookmark->getTitle());
139+
$this->assertSame('http://url0.net/', $firstBookmark->getUrl());
140+
}
141+
115142
/**
116143
* @dataProvider exportProvider
117144
* @param array $bookmarks

0 commit comments

Comments
 (0)