From d4d4f4e950e61136dff199da8e330af6ff2474dd Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 14 Aug 2021 21:46:44 +0100 Subject: [PATCH] [TESTS] Cleanup attachment test data --- src/DataFixtures/MediaFixtures.php | 44 +++++------------- tests/Media/sample-uploads/image.jpeg | Bin 306 -> 0 bytes tests/Media/sample-uploads/presentation.pot | Bin 71168 -> 0 bytes tests/Media/sample-uploads/presentation.pptx | Bin 5790 -> 0 bytes tests/{Media => }/sample-uploads/image.gif | Bin tests/{Media => }/sample-uploads/image.jpg | Bin tests/{Media => }/sample-uploads/image.png | Bin tests/{Media => }/sample-uploads/office.pdf | Bin .../sample-uploads/presentation.odp | Bin .../sample-uploads/presentation.otp | Bin .../sample-uploads/presentation.potm | Bin .../sample-uploads/presentation.ppt | Bin .../sample-uploads/spreadsheet.ods | Bin .../sample-uploads/spreadsheet.ots | Bin .../sample-uploads/spreadsheet.xls | Bin .../sample-uploads/spreadsheet.xlsx | Bin .../sample-uploads/spreadsheet.xlt | Bin tests/{Media => }/sample-uploads/wordproc.doc | Bin .../{Media => }/sample-uploads/wordproc.docx | Bin tests/{Media => }/sample-uploads/wordproc.odt | Bin tests/{Media => }/sample-uploads/wordproc.ott | Bin tests/{Media => }/sample-uploads/wordproc.rtf | 0 22 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 tests/Media/sample-uploads/image.jpeg delete mode 100644 tests/Media/sample-uploads/presentation.pot delete mode 100644 tests/Media/sample-uploads/presentation.pptx rename tests/{Media => }/sample-uploads/image.gif (100%) rename tests/{Media => }/sample-uploads/image.jpg (100%) rename tests/{Media => }/sample-uploads/image.png (100%) rename tests/{Media => }/sample-uploads/office.pdf (100%) rename tests/{Media => }/sample-uploads/presentation.odp (100%) rename tests/{Media => }/sample-uploads/presentation.otp (100%) rename tests/{Media => }/sample-uploads/presentation.potm (100%) rename tests/{Media => }/sample-uploads/presentation.ppt (100%) rename tests/{Media => }/sample-uploads/spreadsheet.ods (100%) rename tests/{Media => }/sample-uploads/spreadsheet.ots (100%) rename tests/{Media => }/sample-uploads/spreadsheet.xls (100%) rename tests/{Media => }/sample-uploads/spreadsheet.xlsx (100%) rename tests/{Media => }/sample-uploads/spreadsheet.xlt (100%) rename tests/{Media => }/sample-uploads/wordproc.doc (100%) rename tests/{Media => }/sample-uploads/wordproc.docx (100%) rename tests/{Media => }/sample-uploads/wordproc.odt (100%) rename tests/{Media => }/sample-uploads/wordproc.ott (100%) rename tests/{Media => }/sample-uploads/wordproc.rtf (100%) diff --git a/src/DataFixtures/MediaFixtures.php b/src/DataFixtures/MediaFixtures.php index 6bd435c6b6..cc540761d0 100644 --- a/src/DataFixtures/MediaFixtures.php +++ b/src/DataFixtures/MediaFixtures.php @@ -4,9 +4,9 @@ namespace App\DataFixtures; use App\Core\DB\DB; use App\Core\GSFile; -use App\Util\Common; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; +use Functional as F; use Symfony\Component\HttpFoundation\File\File; class MediaFixtures extends Fixture @@ -14,37 +14,17 @@ class MediaFixtures extends Fixture public function load(ObjectManager $manager) { DB::setManager($manager); - $actor = DB::findOneBy('local_user', ['nickname' => 'taken_user']); - $store = function (string $filepath, string $title) use ($actor) { - $copy_filepath = $filepath . '.copy'; - copy($filepath, $copy_filepath); - $file = new File($copy_filepath, checkPath: true); - GSFile::validateAndStoreFileAsAttachment($file, dest_dir: Common::config('attachments', 'dir') . 'test/', title: $title, actor_id: $actor->getId()); - }; - - $test_files = [ - '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'); + F\map(glob(INSTALLDIR . '/tests/sample-uploads/*'), + function (string $filepath) { + $copy_filepath = str_replace('.', '.copy.', $filepath); + copy($filepath, $copy_filepath); + $file = new File($copy_filepath, checkPath: true); + try { + GSFile::sanitizeAndStoreFileAsAttachment($file); + } catch (\Jcupitt\Vips\Exception $e) { + echo "Could not save file {$copy_filepath}"; + } + }); $manager->flush(); } } diff --git a/tests/Media/sample-uploads/image.jpeg b/tests/Media/sample-uploads/image.jpeg deleted file mode 100644 index 21fcb5aef4f885ba2de26b136bec29a3056fcc86..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 306 zcmb7;NeaS15Ji94X}cvMu}st;rlY}oxDcE`@Ct&0Zbk53p1_5NaM*Yf+t!`B@)gwL z@oTVWdq;IToD4xk7`uXfARcU2i`{D3*>861&S)~5+ZzUu!t*>KU6WFlRiKq4^8HG{ zQLV-ibKGb*5FmVdKX1cKZZ!RX^~RQB=&=X)#B diff --git a/tests/Media/sample-uploads/presentation.pot b/tests/Media/sample-uploads/presentation.pot deleted file mode 100644 index f5124ffa2b25669b2b442452771f23de0a46e7a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 71168 zcmeI2dvF!y8OGl|dvXDSdy*(vMY2$;K~RH1FjXW#0I6J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b4;P{qU0wfZvSuW8-P~iD4BYOg1C=b4sih846#Ewh&YoTg7`iE zafri^zp)vPkSp8N_SUwQu7AzAaZo)J9`)e~LUVrqmX|iAerILgpNY5{)Q>Zmb*zTA zL#&5oe&vG`#OEHg*Fy;?0VSXWlzNt4 zKnW-TC7=Y9fD%vwNNt4 zKnW-TC7=Y9fD%vwNNt4 zKnW-TC7=Y9fD%vwNNt4 zKnW-TC7=Y9fD%vwNNt4 zKnW-TC7=Y9fD%vwNNt4 zKnW-TC7=Y9fD%vwNvzTS#wkZN!wG7aUgkX15I zu90O?=DpslKt{}pd9oh88fQe-1?LvZT`tWTG5tFoh|oEI+rc{j1OUM^HZJ$}kQ>9RC5Cn{*`r diff --git a/tests/Media/sample-uploads/presentation.pptx b/tests/Media/sample-uploads/presentation.pptx deleted file mode 100644 index 21ea61a1590f3895992071d93ce52573f2e247ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5790 zcma)A1yodP+oiihQly(1Ktx(PBrYLHk0783Gt|%^okKHH(jkI$Nemz$sf2)pGziiI z(joky-?v28z4!l~S?jE`&YH95efD~0?{~kNs^}OLC^$GcC<$eS5-3*+|Kc9xXld&N z1YBMtqZ^1?`3V$Uo0z|AObIduDmO6Zmb~_ohSysw>}ZmaoJ!sxS0IR}>6aXl6e1Rf ziMI>6b7XPfC;3{1YOR+XE2P1M+gHnK_EB`5G@hZm@WG*U6fhuK z&ypdhC39Dord8blBJf-+(^N!ZLNyc&@>@>#J99WOOA@--*ks^%)CmLn_j1$rkjZvY zGqagCt@!u)PLfgGS)-Z29Xd0B{4_ zZWx$2%?nd_BTEOCy{UZ2;tj@dFon z>*4~I4;2Z?`yksS+5EG2pHR()gJMwR5x%1>hM#W{u8AO`dWXvN>%lFPy8LzZcjmY1 z9SEXL0Ew_Xo5PI=1qWVHD0V0Io36CAradOU4toN84k#L(B9O?3QOcVeMo7q$$)3G7+CYThNd3cPK?feBGU3^dHR2dbNo%?)@+h zlo1rlDx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