mirror of
https://github.com/wallabag/wallabag.git
synced 2026-10-08 19:49:11 +02:00
Introduces a fixtures/ directory at the repo root with seven Doctrine fixture classes (UserFixtures, ConfigFixtures, TagFixtures, TaggingRuleFixtures, IgnoreOriginUserRuleFixtures, EntryFixtures, AnnotationFixtures) under the Wallabag\Fixtures\ namespace. The fixture classes are registered as doctrine.fixture.orm services only in the dev environment. AppKernel loads services_dev.yml exclusively when the environment is dev, keeping the test environment completely unaffected. UserFixtures resolves an existing user from the database if one is present (install-command path) or creates a default wallabag/wallabag admin and dispatches USER_CREATED (standalone path, which triggers CreateConfigListener to set up the matching Config). ConfigFixtures follows the same pattern, finding or creating the Config record. EntryFixtures fetches each of 25 real wallabag-related URLs via ContentProxy so every entry is fully populated — title, content, language, reading time, domain, preview picture, and automatic tags applied by the configured TaggingRuleFixtures rules.
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Wallabag\Fixtures;
|
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
use FOS\UserBundle\Event\UserEvent;
|
|
use FOS\UserBundle\FOSUserEvents;
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
use Wallabag\Entity\User;
|
|
|
|
class UserFixtures extends Fixture
|
|
{
|
|
public function __construct(
|
|
private readonly EventDispatcherInterface $dispatcher,
|
|
) {
|
|
}
|
|
|
|
public function load(ObjectManager $manager): void
|
|
{
|
|
$user = $manager->getRepository(User::class)->findOneBy([], ['id' => 'ASC']);
|
|
|
|
if (!$user) {
|
|
$user = new User();
|
|
$user->setUsername('wallabag');
|
|
$user->setPlainPassword('wallabag');
|
|
$user->setEmail('wallabag@wallabag.io');
|
|
$user->setEnabled(true);
|
|
$user->addRole('ROLE_SUPER_ADMIN');
|
|
|
|
$manager->persist($user);
|
|
$manager->flush();
|
|
|
|
$this->dispatcher->dispatch(new UserEvent($user), FOSUserEvents::USER_CREATED);
|
|
}
|
|
|
|
$this->addReference('dev-user', $user);
|
|
}
|
|
}
|