[TESTS] Add a sample image to the test dataset

This commit is contained in:
Hugo Sales 2021-08-03 17:51:58 +00:00
parent 647e4c03b3
commit 29d77b446f
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -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();
}
}