$version = trim(file_get_contents(base_path('version')));
$this->assertEquals($version, $zip->data['instance']['version']);
- $instanceId = decrypt($zip->data['instance']['id_ciphertext']);
- $this->assertEquals('bookstack', $instanceId);
+ $zipInstanceId = $zip->data['instance']['id'];
+ $instanceId = setting('instance-id');
+ $this->assertNotEmpty($instanceId);
+ $this->assertEquals($instanceId, $zipInstanceId);
}
public function test_page_export()
[
'name' => 'Exporty',
'value' => 'Content',
- 'order' => 1,
],
[
'name' => 'Another',
'value' => '',
- 'order' => 2,
]
], $pageData['tags']);
}
$attachmentData = $pageData['attachments'][0];
$this->assertEquals('PageAttachmentExport.txt', $attachmentData['name']);
$this->assertEquals($attachment->id, $attachmentData['id']);
- $this->assertEquals(1, $attachmentData['order']);
$this->assertArrayNotHasKey('link', $attachmentData);
$this->assertNotEmpty($attachmentData['file']);
$attachmentData = $pageData['attachments'][0];
$this->assertEquals('My link attachment for export', $attachmentData['name']);
$this->assertEquals($attachment->id, $attachmentData['id']);
- $this->assertEquals(1, $attachmentData['order']);
$this->assertEquals('https://example.com/cats', $attachmentData['link']);
$this->assertArrayNotHasKey('file', $attachmentData);
}
$this->assertStringContainsString('href="[[bsexport:book:' . $book->id . ']]?view=true"', $pageData['html']);
}
+ public function test_book_and_chapter_description_links_to_images_in_pages_are_converted()
+ {
+ $book = $this->entities->bookHasChaptersAndPages();
+ $chapter = $book->chapters()->first();
+ $page = $chapter->pages()->first();
+
+ $this->asEditor();
+ $this->files->uploadGalleryImageToPage($this, $page);
+ /** @var Image $image */
+ $image = Image::query()->where('type', '=', 'gallery')
+ ->where('uploaded_to', '=', $page->id)->first();
+
+ $book->description_html = '<p><a href="' . $image->url . '">Link to image</a></p>';
+ $book->save();
+ $chapter->description_html = '<p><a href="' . $image->url . '">Link to image</a></p>';
+ $chapter->save();
+
+ $zipResp = $this->get($book->getUrl("/export/zip"));
+ $zip = $this->extractZipResponse($zipResp);
+ $bookData = $zip->data['book'];
+ $chapterData = $bookData['chapters'][0];
+
+ $this->assertStringContainsString('href="[[bsexport:image:' . $image->id . ']]"', $bookData['description_html']);
+ $this->assertStringContainsString('href="[[bsexport:image:' . $image->id . ']]"', $chapterData['description_html']);
+ }
+
+ public function test_image_links_are_handled_when_using_external_storage_url()
+ {
+ $page = $this->entities->page();
+
+ $this->asEditor();
+ $this->files->uploadGalleryImageToPage($this, $page);
+ /** @var Image $image */
+ $image = Image::query()->where('type', '=', 'gallery')
+ ->where('uploaded_to', '=', $page->id)->first();
+
+ config()->set('filesystems.url', 'https://i.example.com/content');
+
+ $storageUrl = 'https://i.example.com/content/' . ltrim($image->path, '/');
+ $page->html = '<p><a href="' . $image->url . '">Original URL</a><a href="' . $storageUrl . '">Storage URL</a></p>';
+ $page->save();
+
+ $zipResp = $this->get($page->getUrl("/export/zip"));
+ $zip = $this->extractZipResponse($zipResp);
+ $pageData = $zip->data['page'];
+
+ $ref = '[[bsexport:image:' . $image->id . ']]';
+ $this->assertStringContainsString("<a href=\"{$ref}\">Original URL</a><a href=\"{$ref}\">Storage URL</a>", $pageData['html']);
+ }
+
public function test_cross_reference_links_external_to_export_are_not_converted()
{
$page = $this->entities->page();