@@ -131,7 +131,7 @@ public function testExport(...$bookmarks): void {
131131 // Set up database
132132 for ($ i = 0 ; $ i < 4 ; $ i ++) {
133133 $ f = new Db \Folder ();
134- $ f ->setTitle ($ i );
134+ $ f ->setTitle (md5 ( $ i ) );
135135 $ f ->setUserId ($ this ->userId );
136136 $ f = $ this ->folderMapper ->insert ($ f );
137137 $ this ->treeMapper ->move (Db \TreeMapper::TYPE_FOLDER , $ f ->getId (), $ rootFolder ->getId ());
@@ -143,13 +143,32 @@ public function testExport(...$bookmarks): void {
143143
144144 $ exported = $ this ->htmlExporter ->exportFolder ($ this ->userId , $ rootFolder ->getId ());
145145
146- $ rootFolders = $ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_FOLDER , $ rootFolder ->getId ());
147- $ this ->assertCount (4 , $ rootFolders );
148- foreach ($ rootFolders as $ rootFolder ) {
149- foreach ($ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_BOOKMARK , $ rootFolder ->getId ()) as $ bookmark ) {
146+ $ exportedRootFolders = $ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_FOLDER , $ rootFolder ->getId ());
147+ $ this ->assertCount (4 , $ exportedRootFolders );
148+ foreach ($ exportedRootFolders as $ exportedRootFolder ) {
149+ foreach ($ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_BOOKMARK , $ exportedRootFolder ->getId ()) as $ bookmark ) {
150+ $ this ->assertStringContainsString ($ exportedRootFolder ->getTitle (), $ exported );
150151 $ this ->assertStringContainsString ($ bookmark ->getUrl (), $ exported );
151152 }
152153 }
154+
155+ $ f = new Db \Folder ();
156+ $ f ->setTitle ('Testimport ' );
157+ $ f ->setUserId ($ this ->userId );
158+ $ f = $ this ->folderMapper ->insert ($ f );
159+ $ this ->htmlImporter ->import ($ this ->userId , $ exported , $ f ->getId ());
160+ $ importedRootFolders = $ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_FOLDER , $ f ->getId ());
161+ foreach ($ importedRootFolders as $ i => $ importedRootFolder ) {
162+ $ exportedRootFolder = $ exportedRootFolders [$ i ];
163+ $ this ->assertEquals ($ importedRootFolder ->getTitle (), $ exportedRootFolder ->getTitle ());
164+ $ exportedBookmarks = $ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_BOOKMARK , $ exportedRootFolder ->getId ());
165+ foreach ($ this ->treeMapper ->findChildren (Db \TreeMapper::TYPE_BOOKMARK , $ importedRootFolder ->getId ()) as $ j => $ bookmark ) {
166+ $ this ->assertEquals ($ bookmark ->getUrl (), $ exportedBookmarks [$ j ]->getUrl ());
167+ $ this ->assertEquals ($ bookmark ->getTitle (), $ exportedBookmarks [$ j ]->getTitle ());
168+ $ this ->assertEquals ($ bookmark ->getDescription (), $ exportedBookmarks [$ j ]->getDescription ());
169+ $ this ->assertEquals ($ this ->tagMapper ->findByBookmark ($ bookmark ->getId ()), $ this ->tagMapper ->findByBookmark ($ exportedBookmarks [$ j ]->getId ()));
170+ }
171+ }
153172 }
154173
155174 public function importProvider (): array {
@@ -166,10 +185,10 @@ public function exportProvider(): array {
166185 return Db \Bookmark::fromArray ($ props );
167186 }, [
168187 ['url ' => 'https://google.com/ ' , 'title ' => 'Google ' , 'description ' => 'Search engine ' ],
169- ['url ' => 'https://nextcloud.com/ ' , 'title ' => 'Nextcloud ' , 'description ' => '' ],
188+ ['url ' => 'https://nextcloud.com/ ' , 'title ' => 'Nextcloud ' , 'description ' => 'cloud cloud cloud ' ],
170189 ['url ' => 'https://php.net/ ' , 'title ' => '' , 'description ' => '' ],
171- ['url ' => 'https://de.wikipedia.org/wiki/%C3%9C ' , 'title ' => '' , 'description ' => '' ],
172- ['url ' => 'https://github.com/nextcloud/bookmarks/projects/1 ' , 'title ' => '' , 'description ' => '' ],
190+ ['url ' => 'https://de.wikipedia.org/wiki/%C3%9C ' , 'title ' => '' , 'description ' => '<H1>Hello</H1> ' ],
191+ ['url ' => 'https://github.com/nextcloud/bookmarks/projects/1 ' , 'title ' => '' , 'description ' => '</DL> ' ],
173192 ]),
174193 ];
175194 }
0 commit comments