From 29d77b446f00220440b4caebab305ee3d3031d14 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Tue, 3 Aug 2021 17:51:58 +0000 Subject: [PATCH] [TESTS] Add a sample image to the test dataset --- src/DataFixtures/CoreFixtures.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/DataFixtures/CoreFixtures.php b/src/DataFixtures/CoreFixtures.php index 6d39642e14..c6372a480f 100644 --- a/src/DataFixtures/CoreFixtures.php +++ b/src/DataFixtures/CoreFixtures.php @@ -2,15 +2,19 @@ namespace App\DataFixtures; +use App\Core\DB\DB; +use App\Core\GSFile; use App\Core\VisibilityScope; use App\Entity\GroupInbox; use App\Entity\GSActor; use App\Entity\LocalGroup; use App\Entity\LocalUser; use App\Entity\Note; +use App\Util\Common; use App\Util\Nickname; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; +use Symfony\Component\HttpFoundation\File\File; class CoreFixtures extends Fixture { @@ -39,5 +43,13 @@ class CoreFixtures extends Fixture $manager->persist(GroupInbox::create(['group_id' => $local_entities['taken_group']->getGroupId(), 'activity_id' => $note->getId()])); $manager->flush(); + + DB::setManager($manager); + $filepath = INSTALLDIR . '/tests/Media/sample-uploads/image.jpeg'; + $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: '1x1 JPEG image title', actor_id: $actors['taken_user']->getId()); + $manager->flush(); } }