Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test samples for pending PR. #1352

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/Feature/PhotosAddTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testSimpleUpload(): void
'original' => [
'width' => 6720,
'height' => 4480,
'filesize' => 21104156,
'filesize' => 21106422,
],
],
]);
Expand Down Expand Up @@ -159,11 +159,11 @@ public function testImport()
$num_before_import = $ids_before_import->count();

// upload the photo
copy(base_path('tests/Samples/night.jpg'), base_path('public/uploads/import/night.jpg'));
$this->photos_tests->import(base_path('public/uploads/import/'));
copy(base_path(static::SAMPLE_FILE_NIGHT_IMAGE), static::importPath('night.jpg'));
$this->photos_tests->import(static::importPath());

// check if the file is still there (without symlinks the photo would have been deleted)
static::assertEquals(true, file_exists('public/uploads/import/night.jpg'));
static::assertEquals(true, file_exists(static::importPath('night.jpg')));

$response = $this->albums_tests->get('recent');
$responseObj = json_decode($response->getContent());
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/PhotosOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testManyFunctionsAtOnce(): void
'original' => [
'width' => 6720,
'height' => 4480,
'filesize' => 21104156,
'filesize' => 21106422,
],
],
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/PhotosRotateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testRotate(): void
'original' => [
'width' => 6720,
'height' => 4480,
'filesize' => 21104156,
'filesize' => 21106422,
],
],
]);
Expand Down
Binary file added tests/Samples/gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/google_motion_photo_broken.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/Samples/night.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/orientation-180.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/orientation-270.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/orientation-90.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/orientation-hflip.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/orientation-vflip.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/pdf.pdf
Binary file not shown.
Binary file added tests/Samples/png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Samples/tiff.tif
Binary file not shown.
Binary file added tests/Samples/webp.webp
Binary file not shown.
Binary file added tests/Samples/xcf.xcf
Binary file not shown.
62 changes: 53 additions & 9 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,59 @@ abstract class TestCase extends BaseTestCase
{
use CreatesApplication;

public const SAMPLE_FILE_NIGHT_IMAGE = 'tests/Samples/night.jpg';
public const PATH_IMPORT_DIR = 'uploads/import/';

public const MIME_TYPE_APP_PDF = 'application/pdf';
public const MIME_TYPE_IMG_GIF = 'image/gif';
public const MIME_TYPE_IMG_JPEG = 'image/jpeg';
public const MIME_TYPE_IMG_PNG = 'image/png';
public const MIME_TYPE_IMG_TIFF = 'image/tiff';
public const MIME_TYPE_IMG_WEBP = 'image/webp';
public const MIME_TYPE_IMG_XCF = 'image/x-xcf';
public const MIME_TYPE_VID_MP4 = 'video/mp4';
public const MIME_TYPE_VID_QUICKTIME = 'video/quicktime';

public const SAMPLE_DOWNLOAD_JPG = 'https://github.com/LycheeOrg/Lychee/raw/master/tests/Samples/mongolia.jpeg';
public const SAMPLE_DOWNLOAD_TIFF = 'https://github.com/LycheeOrg/Lychee/raw/master/tests/Samples/tiff.tif';

public const SAMPLE_FILE_GAMING_VIDEO = 'tests/Samples/gaming.mp4';
public const SAMPLE_FILE_GIF = 'tests/Samples/gif.gif';
public const SAMPLE_FILE_GMP_BROKEN_IMAGE = 'tests/Samples/google_motion_photo_broken.jpg';
public const SAMPLE_FILE_GMP_IMAGE = 'tests/Samples/google_motion_photo.jpg';
public const SAMPLE_FILE_MONGOLIA_IMAGE = 'tests/Samples/mongolia.jpeg';
public const SAMPLE_FILE_NIGHT_IMAGE = 'tests/Samples/night.jpg';
public const SAMPLE_FILE_ORIENTATION_180 = 'tests/Samples/orientation-180.jpg';
public const SAMPLE_FILE_ORIENTATION_270 = 'tests/Samples/orientation-270.jpg';
public const SAMPLE_FILE_ORIENTATION_90 = 'tests/Samples/orientation-90.jpg';
public const SAMPLE_FILE_ORIENTATION_HFLIP = 'tests/Samples/orientation-hflip.jpg';
public const SAMPLE_FILE_ORIENTATION_VFLIP = 'tests/Samples/orientation-vflip.jpg';
public const SAMPLE_FILE_PDF = 'tests/Samples/pdf.pdf';
public const SAMPLE_FILE_PNG = 'tests/Samples/png.png';
public const SAMPLE_FILE_TIFF = 'tests/Samples/tiff.tif';
public const SAMPLE_FILE_TRAIN_IMAGE = 'tests/Samples/train.jpg';
public const SAMPLE_FILE_TRAIN_VIDEO = 'tests/Samples/train.mov';
public const SAMPLE_FILE_GMP_IMAGE = 'tests/Samples/google_motion_photo.jpg';
public const SAMPLE_FILE_GAMING_VIDEO = 'tests/Samples/gaming.mp4';
public const SAMPLE_FILE_WEBP = 'tests/Samples/webp.webp';
public const SAMPLE_FILE_XCF = 'tests/Samples/xcf.xcf';

public const SAMPLE_FILES_2_MIME = [
self::SAMPLE_FILE_NIGHT_IMAGE => 'image/jpeg',
self::SAMPLE_FILE_MONGOLIA_IMAGE => 'image/jpeg',
self::SAMPLE_FILE_TRAIN_IMAGE => 'image/jpeg',
self::SAMPLE_FILE_TRAIN_VIDEO => 'video/quicktime',
self::SAMPLE_FILE_GMP_IMAGE => 'image/jpeg',
self::SAMPLE_FILE_GAMING_VIDEO => 'video/mp4',
self::SAMPLE_FILE_GAMING_VIDEO => self::MIME_TYPE_VID_MP4,
self::SAMPLE_FILE_GIF => self::MIME_TYPE_IMG_GIF,
self::SAMPLE_FILE_GMP_BROKEN_IMAGE => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_GMP_IMAGE => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_MONGOLIA_IMAGE => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_NIGHT_IMAGE => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_ORIENTATION_180 => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_ORIENTATION_270 => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_ORIENTATION_90 => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_ORIENTATION_HFLIP => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_ORIENTATION_VFLIP => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_PDF => self::MIME_TYPE_APP_PDF,
self::SAMPLE_FILE_PNG => self::MIME_TYPE_IMG_PNG,
self::SAMPLE_FILE_TIFF => self::MIME_TYPE_IMG_TIFF,
self::SAMPLE_FILE_TRAIN_IMAGE => self::MIME_TYPE_IMG_JPEG,
self::SAMPLE_FILE_TRAIN_VIDEO => self::MIME_TYPE_VID_QUICKTIME,
self::SAMPLE_FILE_WEBP => self::MIME_TYPE_IMG_WEBP,
self::SAMPLE_FILE_XCF => self::MIME_TYPE_IMG_XCF,
];

/**
Expand Down Expand Up @@ -99,4 +138,9 @@ protected static function createUploadedFile(string $sampleFilePath): UploadedFi
true
);
}

protected static function importPath(string $path = ''): string
{
return public_path(self::PATH_IMPORT_DIR . $path);
}
}