[TESTS] Merge datafixtures to allow for using the correct ID in notes, and add group_inbox

This commit is contained in:
Hugo Sales 2021-05-06 21:53:25 +00:00
parent e1a1d01844
commit 45f54e615c
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 12 additions and 17 deletions

View File

@ -2,24 +2,35 @@
namespace App\DataFixtures;
use App\Entity\GroupInbox;
use App\Entity\GSActor;
use App\Entity\LocalGroup;
use App\Entity\LocalUser;
use App\Entity\Note;
use App\Util\Nickname;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class NicknameFixtures extends Fixture
class CoreFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
$actors = [];
$local_entities = [];
foreach ([LocalUser::class => ['taken_user', 'setId'], LocalGroup::class => ['taken_group', 'setGroupId']] as $entity => [$nick, $method]) {
$actor = GSActor::create(['nickname' => $nick, 'normalized_nickname' => Nickname::normalize($nick, check_already_used: false)]);
$manager->persist($actor);
$ent = $entity::create(['nickname' => $nick]);
$ent->{$method}($actor->getId());
$local_entities[$nick] = $ent;
$manager->persist($ent);
$actors[$nick] = $actor;
}
$note = Note::create(['gsactor_id' => $actors['taken_user']->getId(), 'content' => 'some content']);
$manager->persist($note);
$manager->persist(GroupInbox::create(['group_id' => $local_entities['taken_group']->getGroupId(), 'activity_id' => $note->getId()]));
$manager->flush();
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace App\DataFixtures;
use App\Entity\Note;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class NoteFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
$manager->persist(Note::create(['gsactor_id' => 1, 'content' => 'some content']));
$manager->flush();
}
}