mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-23 08:06:33 +00:00
fixtures: refactor EntryData, TagData, add a new tag
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
4d0c632c70
commit
bafb9744c8
2 changed files with 112 additions and 108 deletions
|
@ -14,97 +14,112 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
|
|||
*/
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$entry1 = new Entry($this->getReference('admin-user'));
|
||||
$entry1->setUrl('http://0.0.0.0/entry1');
|
||||
$entry1->setReadingTime(11);
|
||||
$entry1->setDomainName('domain.io');
|
||||
$entry1->setMimetype('text/html');
|
||||
$entry1->setTitle('test title entry1');
|
||||
$entry1->setContent('This is my content /o/');
|
||||
$entry1->setLanguage('en');
|
||||
$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,
|
||||
'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,
|
||||
'tags' => ['bar-tag'],
|
||||
],
|
||||
];
|
||||
|
||||
$entry1->addTag($this->getReference('foo-tag'));
|
||||
$entry1->addTag($this->getReference('baz-tag'));
|
||||
foreach ($entries as $reference => $item) {
|
||||
$entry = new Entry($this->getReference($item['user']));
|
||||
$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']);
|
||||
|
||||
$manager->persist($entry1);
|
||||
if (isset($item['tags'])) {
|
||||
foreach ($item['tags'] as $tag) {
|
||||
$entry->addTag($this->getReference($tag));
|
||||
}
|
||||
}
|
||||
|
||||
$this->addReference('entry1', $entry1);
|
||||
if (isset($item['origin'])) {
|
||||
$entry->setOriginUrl($item['origin']);
|
||||
}
|
||||
|
||||
$entry2 = new Entry($this->getReference('admin-user'));
|
||||
$entry2->setUrl('http://0.0.0.0/entry2');
|
||||
$entry2->setReadingTime(1);
|
||||
$entry2->setDomainName('domain.io');
|
||||
$entry2->setMimetype('text/html');
|
||||
$entry2->setTitle('test title entry2');
|
||||
$entry2->setContent('This is my content /o/');
|
||||
$entry2->setOriginUrl('ftp://oneftp.tld');
|
||||
$entry2->setLanguage('fr');
|
||||
if (isset($item['starred'])) {
|
||||
$entry->setStarred($item['starred']);
|
||||
}
|
||||
|
||||
$manager->persist($entry2);
|
||||
if (isset($item['archived'])) {
|
||||
$entry->setArchived($item['archived']);
|
||||
}
|
||||
|
||||
$this->addReference('entry2', $entry2);
|
||||
if (isset($item['preview'])) {
|
||||
$entry->setPreviewPicture($item['preview']);
|
||||
}
|
||||
|
||||
$entry3 = new Entry($this->getReference('bob-user'));
|
||||
$entry3->setUrl('http://0.0.0.0/entry3');
|
||||
$entry3->setReadingTime(1);
|
||||
$entry3->setDomainName('domain.io');
|
||||
$entry3->setMimetype('text/html');
|
||||
$entry3->setTitle('test title entry3');
|
||||
$entry3->setContent('This is my content /o/');
|
||||
$entry3->setLanguage('en');
|
||||
|
||||
$entry3->addTag($this->getReference('foo-tag'));
|
||||
$entry3->addTag($this->getReference('bar-tag'));
|
||||
|
||||
$manager->persist($entry3);
|
||||
|
||||
$this->addReference('entry3', $entry3);
|
||||
|
||||
$entry4 = new Entry($this->getReference('admin-user'));
|
||||
$entry4->setUrl('http://0.0.0.0/entry4');
|
||||
$entry4->setReadingTime(12);
|
||||
$entry4->setDomainName('domain.io');
|
||||
$entry4->setMimetype('text/html');
|
||||
$entry4->setTitle('test title entry4');
|
||||
$entry4->setContent('This is my content /o/');
|
||||
$entry4->setLanguage('en');
|
||||
|
||||
$entry4->addTag($this->getReference('foo-tag'));
|
||||
$entry4->addTag($this->getReference('bar-tag'));
|
||||
|
||||
$manager->persist($entry4);
|
||||
|
||||
$this->addReference('entry4', $entry4);
|
||||
|
||||
$entry5 = new Entry($this->getReference('admin-user'));
|
||||
$entry5->setUrl('http://0.0.0.0/entry5');
|
||||
$entry5->setReadingTime(12);
|
||||
$entry5->setDomainName('domain.io');
|
||||
$entry5->setMimetype('text/html');
|
||||
$entry5->setTitle('test title entry5');
|
||||
$entry5->setContent('This is my content /o/');
|
||||
$entry5->setStarred(true);
|
||||
$entry5->setLanguage('fr');
|
||||
$entry5->setPreviewPicture('http://0.0.0.0/image.jpg');
|
||||
|
||||
$manager->persist($entry5);
|
||||
|
||||
$this->addReference('entry5', $entry5);
|
||||
|
||||
$entry6 = new Entry($this->getReference('admin-user'));
|
||||
$entry6->setUrl('http://0.0.0.0/entry6');
|
||||
$entry6->setReadingTime(12);
|
||||
$entry6->setDomainName('domain.io');
|
||||
$entry6->setMimetype('text/html');
|
||||
$entry6->setTitle('test title entry6');
|
||||
$entry6->setContent('This is my content /o/');
|
||||
$entry6->setArchived(true);
|
||||
$entry6->setLanguage('de');
|
||||
$entry6->addTag($this->getReference('bar-tag'));
|
||||
|
||||
$manager->persist($entry6);
|
||||
|
||||
$this->addReference('entry6', $entry6);
|
||||
$manager->persist($entry);
|
||||
$this->addReference($reference, $entry);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
|
|
@ -14,33 +14,22 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
|
|||
*/
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$tag1 = new Tag();
|
||||
$tag1->setLabel('foo bar');
|
||||
$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
|
||||
];
|
||||
|
||||
$manager->persist($tag1);
|
||||
foreach ($tags as $reference => $label) {
|
||||
$tag = new Tag();
|
||||
$tag->setLabel($label);
|
||||
|
||||
$this->addReference('foo-bar-tag', $tag1);
|
||||
$manager->persist($tag);
|
||||
|
||||
$tag2 = new Tag();
|
||||
$tag2->setLabel('bar');
|
||||
|
||||
$manager->persist($tag2);
|
||||
|
||||
$this->addReference('bar-tag', $tag2);
|
||||
|
||||
$tag3 = new Tag();
|
||||
$tag3->setLabel('baz');
|
||||
|
||||
$manager->persist($tag3);
|
||||
|
||||
$this->addReference('baz-tag', $tag3);
|
||||
|
||||
$tag4 = new Tag();
|
||||
$tag4->setLabel('foo');
|
||||
|
||||
$manager->persist($tag4);
|
||||
|
||||
$this->addReference('foo-tag', $tag4);
|
||||
$this->addReference($reference, $tag);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue