mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-27 16:36:00 +00:00
Move fixtures out of src
This commit is contained in:
parent
ce286d7f7b
commit
7d20756b7b
13 changed files with 4 additions and 2 deletions
53
fixtures/AnnotationFixtures.php
Normal file
53
fixtures/AnnotationFixtures.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
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)
|
||||
{
|
||||
$annotation1 = new Annotation($this->getReference('admin-user', User::class));
|
||||
$annotation1->setEntry($this->getReference('entry1', Entry::class));
|
||||
$annotation1->setText('This is my annotation /o/');
|
||||
$annotation1->setQuote('content');
|
||||
|
||||
$manager->persist($annotation1);
|
||||
|
||||
$this->addReference('annotation1', $annotation1);
|
||||
|
||||
$annotation2 = new Annotation($this->getReference('admin-user', User::class));
|
||||
$annotation2->setEntry($this->getReference('entry2', Entry::class));
|
||||
$annotation2->setText('This is my 2nd annotation /o/');
|
||||
$annotation2->setQuote('content');
|
||||
|
||||
$manager->persist($annotation2);
|
||||
|
||||
$this->addReference('annotation2', $annotation2);
|
||||
|
||||
$annotation3 = new Annotation($this->getReference('bob-user', User::class));
|
||||
$annotation3->setEntry($this->getReference('entry3', Entry::class));
|
||||
$annotation3->setText('This is my first annotation !');
|
||||
$annotation3->setQuote('content');
|
||||
|
||||
$manager->persist($annotation3);
|
||||
|
||||
$this->addReference('annotation3', $annotation3);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
EntryFixtures::class,
|
||||
UserFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
64
fixtures/ConfigFixtures.php
Normal file
64
fixtures/ConfigFixtures.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\Entity\Config;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
class ConfigFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$adminConfig = new Config($this->getReference('admin-user', User::class));
|
||||
|
||||
$adminConfig->setItemsPerPage(30);
|
||||
$adminConfig->setReadingSpeed(200);
|
||||
$adminConfig->setLanguage('en');
|
||||
$adminConfig->setPocketConsumerKey('xxxxx');
|
||||
$adminConfig->setActionMarkAsRead(0);
|
||||
$adminConfig->setListMode(0);
|
||||
$adminConfig->setDisplayThumbnails(0);
|
||||
|
||||
$manager->persist($adminConfig);
|
||||
|
||||
$this->addReference('admin-config', $adminConfig);
|
||||
|
||||
$bobConfig = new Config($this->getReference('bob-user', User::class));
|
||||
$bobConfig->setItemsPerPage(10);
|
||||
$bobConfig->setReadingSpeed(200);
|
||||
$bobConfig->setLanguage('fr');
|
||||
$bobConfig->setPocketConsumerKey(null);
|
||||
$bobConfig->setActionMarkAsRead(1);
|
||||
$bobConfig->setListMode(1);
|
||||
$bobConfig->setDisplayThumbnails(1);
|
||||
|
||||
$manager->persist($bobConfig);
|
||||
|
||||
$this->addReference('bob-config', $bobConfig);
|
||||
|
||||
$emptyConfig = new Config($this->getReference('empty-user', User::class));
|
||||
$emptyConfig->setItemsPerPage(10);
|
||||
$emptyConfig->setReadingSpeed(100);
|
||||
$emptyConfig->setLanguage('en');
|
||||
$emptyConfig->setPocketConsumerKey(null);
|
||||
$emptyConfig->setActionMarkAsRead(0);
|
||||
$emptyConfig->setListMode(0);
|
||||
$emptyConfig->setDisplayThumbnails(0);
|
||||
|
||||
$manager->persist($emptyConfig);
|
||||
|
||||
$this->addReference('empty-config', $emptyConfig);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
UserFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
150
fixtures/EntryFixtures.php
Normal file
150
fixtures/EntryFixtures.php
Normal file
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\Entity\Entry;
|
||||
use Wallabag\Entity\Tag;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
class EntryFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$now = new \DateTime();
|
||||
|
||||
$entries = [
|
||||
'entry1' => [
|
||||
'user' => 'admin-user',
|
||||
'url' => 'http://0.0.0.0/entry1',
|
||||
'reading_time' => 11,
|
||||
'domain' => 'domain.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry1',
|
||||
'content' => 'This is my content /o/',
|
||||
'language' => 'en',
|
||||
'tags' => ['foo-tag', 'baz-tag'],
|
||||
],
|
||||
'entry2' => [
|
||||
'user' => 'admin-user',
|
||||
'url' => 'http://0.0.0.0/entry2',
|
||||
'reading_time' => 1,
|
||||
'domain' => 'domain.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry2',
|
||||
'content' => 'This is my content /o/',
|
||||
'origin' => 'ftp://oneftp.tld',
|
||||
'language' => 'fr',
|
||||
],
|
||||
'entry3' => [
|
||||
'user' => 'bob-user',
|
||||
'url' => 'http://0.0.0.0/entry3',
|
||||
'reading_time' => 1,
|
||||
'domain' => 'domain.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry3',
|
||||
'content' => 'This is my content /o/',
|
||||
'language' => 'en',
|
||||
'tags' => ['foo-tag', 'bar-tag', 'bob-tag'],
|
||||
],
|
||||
'entry4' => [
|
||||
'user' => 'admin-user',
|
||||
'url' => 'http://0.0.0.0/entry4',
|
||||
'reading_time' => 12,
|
||||
'domain' => 'domain.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry4',
|
||||
'content' => 'This is my content /o/',
|
||||
'language' => 'en',
|
||||
'tags' => ['foo-tag', 'bar-tag'],
|
||||
],
|
||||
'entry5' => [
|
||||
'user' => 'admin-user',
|
||||
'url' => 'http://0.0.0.0/entry5',
|
||||
'reading_time' => 12,
|
||||
'domain' => 'domain.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry5',
|
||||
'content' => 'This is my content /o/',
|
||||
'language' => 'fr',
|
||||
'starred' => true,
|
||||
'starred_at' => $now,
|
||||
'preview' => 'http://0.0.0.0/image.jpg',
|
||||
],
|
||||
'entry6' => [
|
||||
'user' => 'admin-user',
|
||||
'url' => 'http://0.0.0.0/entry6',
|
||||
'reading_time' => 12,
|
||||
'domain' => 'domain.io',
|
||||
'mime' => 'text/html',
|
||||
'title' => 'test title entry6',
|
||||
'content' => 'This is my content /o/',
|
||||
'language' => 'de',
|
||||
'archived' => true,
|
||||
'archived_at' => $now,
|
||||
'tags' => ['bar-tag'],
|
||||
'is_not_parsed' => true,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($entries as $reference => $item) {
|
||||
$entry = new Entry($this->getReference($item['user'], User::class));
|
||||
$entry->setUrl($item['url']);
|
||||
$entry->setReadingTime($item['reading_time']);
|
||||
$entry->setDomainName($item['domain']);
|
||||
$entry->setMimetype($item['mime']);
|
||||
$entry->setTitle($item['title']);
|
||||
$entry->setContent($item['content']);
|
||||
$entry->setLanguage($item['language']);
|
||||
|
||||
if (isset($item['tags'])) {
|
||||
foreach ($item['tags'] as $tag) {
|
||||
$entry->addTag($this->getReference($tag, Tag::class));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($item['origin'])) {
|
||||
$entry->setOriginUrl($item['origin']);
|
||||
}
|
||||
|
||||
if (isset($item['starred'])) {
|
||||
$entry->setStarred($item['starred']);
|
||||
}
|
||||
|
||||
if (isset($item['starred_at'])) {
|
||||
$entry->setStarredAt($item['starred_at']);
|
||||
}
|
||||
|
||||
if (isset($item['archived'])) {
|
||||
$entry->setArchived($item['archived']);
|
||||
}
|
||||
|
||||
if (isset($item['archived_at'])) {
|
||||
$entry->setArchivedAt($item['archived_at']);
|
||||
}
|
||||
|
||||
if (isset($item['preview'])) {
|
||||
$entry->setPreviewPicture($item['preview']);
|
||||
}
|
||||
|
||||
if (isset($item['is_not_parsed'])) {
|
||||
$entry->setNotParsed($item['is_not_parsed']);
|
||||
}
|
||||
|
||||
$manager->persist($entry);
|
||||
$this->addReference($reference, $entry);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
UserFixtures::class,
|
||||
TagFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
33
fixtures/IgnoreOriginInstanceRuleFixtures.php
Normal file
33
fixtures/IgnoreOriginInstanceRuleFixtures.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Wallabag\Entity\IgnoreOriginInstanceRule;
|
||||
|
||||
class IgnoreOriginInstanceRuleFixtures extends Fixture implements ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
public function setContainer(?ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
foreach ($this->container->getParameter('wallabag.default_ignore_origin_instance_rules') as $ignore_origin_instance_rule) {
|
||||
$newIgnoreOriginInstanceRule = new IgnoreOriginInstanceRule();
|
||||
$newIgnoreOriginInstanceRule->setRule($ignore_origin_instance_rule['rule']);
|
||||
$manager->persist($newIgnoreOriginInstanceRule);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
30
fixtures/IgnoreOriginUserRuleFixtures.php
Normal file
30
fixtures/IgnoreOriginUserRuleFixtures.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\Entity\IgnoreOriginUserRule;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
class IgnoreOriginUserRuleFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$rule = new IgnoreOriginUserRule();
|
||||
$rule->setRule('host = "example.fr"');
|
||||
$rule->setConfig($this->getReference('admin-user', User::class)->getConfig());
|
||||
|
||||
$manager->persist($rule);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
UserFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
35
fixtures/InternalSettingFixtures.php
Normal file
35
fixtures/InternalSettingFixtures.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Wallabag\Entity\InternalSetting;
|
||||
|
||||
class InternalSettingFixtures extends Fixture implements ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
public function setContainer(?ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
foreach ($this->container->getParameter('wallabag.default_internal_settings') as $setting) {
|
||||
$newSetting = new InternalSetting();
|
||||
$newSetting->setName($setting['name']);
|
||||
$newSetting->setValue($setting['value']);
|
||||
$newSetting->setSection($setting['section']);
|
||||
$manager->persist($newSetting);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
51
fixtures/SiteCredentialFixtures.php
Normal file
51
fixtures/SiteCredentialFixtures.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Wallabag\Entity\SiteCredential;
|
||||
use Wallabag\Entity\User;
|
||||
use Wallabag\Helper\CryptoProxy;
|
||||
|
||||
class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface, ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
public function setContainer(?ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$credential = new SiteCredential($this->getReference('admin-user', User::class));
|
||||
$credential->setHost('.super.com');
|
||||
$credential->setUsername($this->container->get(CryptoProxy::class)->crypt('.super'));
|
||||
$credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar'));
|
||||
|
||||
$manager->persist($credential);
|
||||
|
||||
$credential = new SiteCredential($this->getReference('admin-user', User::class));
|
||||
$credential->setHost('paywall.example.com');
|
||||
$credential->setUsername($this->container->get(CryptoProxy::class)->crypt('paywall.example'));
|
||||
$credential->setPassword($this->container->get(CryptoProxy::class)->crypt('bar'));
|
||||
|
||||
$manager->persist($credential);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
UserFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
32
fixtures/TagFixtures.php
Normal file
32
fixtures/TagFixtures.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\Entity\Tag;
|
||||
|
||||
class TagFixtures extends Fixture
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$tags = [
|
||||
'foo-bar-tag' => 'foo bar', // tag used for EntryControllerTest
|
||||
'bar-tag' => 'bar',
|
||||
'baz-tag' => 'baz', // tag used for ExportControllerTest
|
||||
'foo-tag' => 'foo',
|
||||
'bob-tag' => 'bob', // tag used for TagRestControllerTest
|
||||
];
|
||||
|
||||
foreach ($tags as $reference => $label) {
|
||||
$tag = new Tag();
|
||||
$tag->setLabel($label);
|
||||
|
||||
$manager->persist($tag);
|
||||
|
||||
$this->addReference($reference, $tag);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
67
fixtures/TaggingRuleFixtures.php
Normal file
67
fixtures/TaggingRuleFixtures.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\Entity\Config;
|
||||
use Wallabag\Entity\TaggingRule;
|
||||
|
||||
class TaggingRuleFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$tr1 = new TaggingRule();
|
||||
$tr1->setRule('content matches "spurs"');
|
||||
$tr1->setTags(['sport']);
|
||||
$tr1->setConfig($this->getReference('admin-config', Config::class));
|
||||
|
||||
$manager->persist($tr1);
|
||||
|
||||
$tr2 = new TaggingRule();
|
||||
$tr2->setRule('content matches "basket"');
|
||||
$tr2->setTags(['sport']);
|
||||
$tr2->setConfig($this->getReference('admin-config', Config::class));
|
||||
|
||||
$manager->persist($tr2);
|
||||
|
||||
$tr3 = new TaggingRule();
|
||||
|
||||
$tr3->setRule('title matches "wallabag"');
|
||||
$tr3->setTags(['wallabag']);
|
||||
$tr3->setConfig($this->getReference('admin-config', Config::class));
|
||||
|
||||
$manager->persist($tr3);
|
||||
|
||||
$tr4 = new TaggingRule();
|
||||
$tr4->setRule('content notmatches "basket"');
|
||||
$tr4->setTags(['foot']);
|
||||
$tr4->setConfig($this->getReference('admin-config', Config::class));
|
||||
|
||||
$manager->persist($tr4);
|
||||
|
||||
$tr5 = new TaggingRule();
|
||||
$tr5->setRule('readingTime <= 5');
|
||||
$tr5->setTags(['shortread']);
|
||||
$tr5->setConfig($this->getReference('empty-config', Config::class));
|
||||
|
||||
$manager->persist($tr5);
|
||||
|
||||
$tr6 = new TaggingRule();
|
||||
$tr6->setRule('readingTime > 5');
|
||||
$tr6->setTags(['longread']);
|
||||
$tr6->setConfig($this->getReference('empty-config', Config::class));
|
||||
|
||||
$manager->persist($tr6);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
ConfigFixtures::class,
|
||||
];
|
||||
}
|
||||
}
|
49
fixtures/UserFixtures.php
Normal file
49
fixtures/UserFixtures.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
class UserFixtures extends Fixture
|
||||
{
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$userAdmin = new User();
|
||||
$userAdmin->setName('Big boss');
|
||||
$userAdmin->setEmail('bigboss@wallabag.org');
|
||||
$userAdmin->setUsername('admin');
|
||||
$userAdmin->setPlainPassword('mypassword');
|
||||
$userAdmin->setEnabled(true);
|
||||
$userAdmin->addRole('ROLE_SUPER_ADMIN');
|
||||
|
||||
$manager->persist($userAdmin);
|
||||
|
||||
$this->addReference('admin-user', $userAdmin);
|
||||
|
||||
$bobUser = new User();
|
||||
$bobUser->setName('Bobby');
|
||||
$bobUser->setEmail('bobby@wallabag.org');
|
||||
$bobUser->setUsername('bob');
|
||||
$bobUser->setPlainPassword('mypassword');
|
||||
$bobUser->setEnabled(true);
|
||||
|
||||
$manager->persist($bobUser);
|
||||
|
||||
$this->addReference('bob-user', $bobUser);
|
||||
|
||||
$emptyUser = new User();
|
||||
$emptyUser->setName('Empty');
|
||||
$emptyUser->setEmail('empty@wallabag.org');
|
||||
$emptyUser->setUsername('empty');
|
||||
$emptyUser->setPlainPassword('mypassword');
|
||||
$emptyUser->setEnabled(true);
|
||||
|
||||
$manager->persist($emptyUser);
|
||||
|
||||
$this->addReference('empty-user', $emptyUser);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue