Files
wallabag-mirror/fixtures/AnnotationFixtures.php
Yassine Guedidi b2d99779b6 Add dev fixtures for local development
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.
2026-03-16 14:53:14 +01:00

67 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Wallabag\Fixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Wallabag\Entity\Annotation;
use Wallabag\Entity\Entry;
use Wallabag\Entity\User;
class AnnotationFixtures extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
$user = $this->getReference('dev-user', User::class);
$annotation1 = new Annotation($user);
$annotation1->setEntry($this->getReference('entry-0', Entry::class));
$annotation1->setText('Very impressive!!');
$annotation1->setQuote('That is about 2.69 a day!');
$annotation1->setRanges([[
'start' => '/p[1]',
'startOffset' => '173',
'end' => '/p[1]',
'endOffset' => '198',
]]);
$manager->persist($annotation1);
$annotation2 = new Annotation($user);
$annotation2->setEntry($this->getReference('entry-2', Entry::class));
$annotation2->setText('Un bel âge ! Bravo !');
$annotation2->setQuote('J’ai eu 40 ans.');
$annotation2->setRanges([[
'start' => '/main[1]/article[1]/ul[1]/li[1]',
'startOffset' => '0',
'end' => '/main[1]/article[1]/ul[1]/li[1]',
'endOffset' => '15',
]]);
$manager->persist($annotation2);
$annotation3 = new Annotation($user);
$annotation3->setEntry($this->getReference('entry-5', Entry::class));
$annotation3->setText('It\'s wallabag, not Wallabag!');
$annotation3->setQuote('Wallabag');
$annotation3->setRanges([[
'start' => '/h2[1]',
'startOffset' => '0',
'end' => '/h2[1]',
'endOffset' => '8',
]]);
$manager->persist($annotation3);
$manager->flush();
}
public function getDependencies(): array
{
return [
EntryFixtures::class,
];
}
}