[TESTS] Cleanup attachment test data
@ -4,9 +4,9 @@ namespace App\DataFixtures;
|
|||||||
|
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\GSFile;
|
use App\Core\GSFile;
|
||||||
use App\Util\Common;
|
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Functional as F;
|
||||||
use Symfony\Component\HttpFoundation\File\File;
|
use Symfony\Component\HttpFoundation\File\File;
|
||||||
|
|
||||||
class MediaFixtures extends Fixture
|
class MediaFixtures extends Fixture
|
||||||
@ -14,37 +14,17 @@ class MediaFixtures extends Fixture
|
|||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
DB::setManager($manager);
|
DB::setManager($manager);
|
||||||
$actor = DB::findOneBy('local_user', ['nickname' => 'taken_user']);
|
F\map(glob(INSTALLDIR . '/tests/sample-uploads/*'),
|
||||||
$store = function (string $filepath, string $title) use ($actor) {
|
function (string $filepath) {
|
||||||
$copy_filepath = $filepath . '.copy';
|
$copy_filepath = str_replace('.', '.copy.', $filepath);
|
||||||
copy($filepath, $copy_filepath);
|
copy($filepath, $copy_filepath);
|
||||||
$file = new File($copy_filepath, checkPath: true);
|
$file = new File($copy_filepath, checkPath: true);
|
||||||
GSFile::validateAndStoreFileAsAttachment($file, dest_dir: Common::config('attachments', 'dir') . 'test/', title: $title, actor_id: $actor->getId());
|
try {
|
||||||
};
|
GSFile::sanitizeAndStoreFileAsAttachment($file);
|
||||||
|
} catch (\Jcupitt\Vips\Exception $e) {
|
||||||
$test_files = [
|
echo "Could not save file {$copy_filepath}";
|
||||||
'image.png' => 'image/png',
|
}
|
||||||
'image.gif' => 'image/gif',
|
});
|
||||||
'image.jpg' => 'image/jpeg',
|
|
||||||
'image.jpeg' => 'image/jpeg',
|
|
||||||
'office.pdf' => 'application/pdf',
|
|
||||||
'wordproc.odt' => 'application/vnd.oasis.opendocument.text',
|
|
||||||
'wordproc.ott' => 'application/vnd.oasis.opendocument.text-template',
|
|
||||||
'wordproc.doc' => 'application/msword',
|
|
||||||
'wordproc.docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
||||||
'wordproc.rtf' => 'text/rtf',
|
|
||||||
'spreadsheet.ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
|
||||||
'spreadsheet.ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
|
|
||||||
'spreadsheet.xls' => 'application/vnd.ms-excel',
|
|
||||||
'spreadsheet.xlt' => 'application/vnd.ms-excel',
|
|
||||||
'spreadsheet.xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
'presentation.odp' => 'application/vnd.oasis.opendocument.presentation',
|
|
||||||
'presentation.otp' => 'application/vnd.oasis.opendocument.presentation-template',
|
|
||||||
'presentation.ppt' => 'application/vnd.ms-powerpoint',
|
|
||||||
'presentation.pptx' => 'application/zip', //"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
||||||
];
|
|
||||||
|
|
||||||
$store(INSTALLDIR . '/tests/Media/sample-uploads/image.jpeg', '1x1 JPEG image title');
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 35 B After Width: | Height: | Size: 35 B |
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 159 B |