mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-30 07:32:39 +01:00
Fixed failing tests after conversion changes
This commit is contained in:
parent
ba25dda031
commit
388343aeb0
@ -99,8 +99,7 @@ class Cloner
|
|||||||
|
|
||||||
// Add a cover to the data if existing on the original entity
|
// Add a cover to the data if existing on the original entity
|
||||||
if ($entity->cover instanceof Image) {
|
if ($entity->cover instanceof Image) {
|
||||||
$tmpImgFile = tmpfile();
|
$uploadedFile = $this->imageToUploadedFile($entity->cover);
|
||||||
$uploadedFile = $this->imageToUploadedFile($entity->cover, $tmpImgFile);
|
|
||||||
$inputData['image'] = $uploadedFile;
|
$inputData['image'] = $uploadedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,10 +122,10 @@ class Cloner
|
|||||||
* Convert an image instance to an UploadedFile instance to mimic
|
* Convert an image instance to an UploadedFile instance to mimic
|
||||||
* a file being uploaded.
|
* a file being uploaded.
|
||||||
*/
|
*/
|
||||||
protected function imageToUploadedFile(Image $image, &$tmpFile): ?UploadedFile
|
protected function imageToUploadedFile(Image $image,): ?UploadedFile
|
||||||
{
|
{
|
||||||
$imgData = $this->imageService->getImageData($image);
|
$imgData = $this->imageService->getImageData($image);
|
||||||
$tmpImgFilePath = stream_get_meta_data($tmpFile)['uri'];
|
$tmpImgFilePath = tempnam(sys_get_temp_dir(), 'bs_cover_clone_');
|
||||||
file_put_contents($tmpImgFilePath, $imgData);
|
file_put_contents($tmpImgFilePath, $imgData);
|
||||||
|
|
||||||
return new UploadedFile($tmpImgFilePath, basename($image->path));
|
return new UploadedFile($tmpImgFilePath, basename($image->path));
|
||||||
|
@ -87,6 +87,7 @@ class BookshelfController extends Controller
|
|||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
'description' => ['string', 'max:1000'],
|
'description' => ['string', 'max:1000'],
|
||||||
'image' => array_merge(['nullable'], $this->getImageValidationRules()),
|
'image' => array_merge(['nullable'], $this->getImageValidationRules()),
|
||||||
|
'tags' => ['array'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$bookIds = explode(',', $request->get('books', ''));
|
$bookIds = explode(',', $request->get('books', ''));
|
||||||
@ -163,6 +164,7 @@ class BookshelfController extends Controller
|
|||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
'description' => ['string', 'max:1000'],
|
'description' => ['string', 'max:1000'],
|
||||||
'image' => array_merge(['nullable'], $this->getImageValidationRules()),
|
'image' => array_merge(['nullable'], $this->getImageValidationRules()),
|
||||||
|
'tags' => ['array'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->has('image_reset')) {
|
if ($request->has('image_reset')) {
|
||||||
|
@ -290,6 +290,7 @@ class BookTest extends TestCase
|
|||||||
|
|
||||||
/** @var Book $copy */
|
/** @var Book $copy */
|
||||||
$copy = Book::query()->where('name', '=', 'My copy book')->first();
|
$copy = Book::query()->where('name', '=', 'My copy book')->first();
|
||||||
|
|
||||||
$this->assertNotNull($copy->cover);
|
$this->assertNotNull($copy->cover);
|
||||||
$this->assertNotEquals($book->cover->id, $copy->cover->id);
|
$this->assertNotEquals($book->cover->id, $copy->cover->id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user