diff --git a/CHANGELOG.md b/CHANGELOG.md index a3ce452d..e641d3ec 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +* [PR-395](https://github.com/itk-dev/hoeringsportal/pull/395) + Project fixtures * [PR-398](https://github.com/itk-dev/hoeringsportal/pull/398) Added Deskpro test data * [pr-394](https://github.com/itk-dev/hoeringsportal/pull/394) diff --git a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.info.yml b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.info.yml new file mode 100644 index 00000000..1189e366 --- /dev/null +++ b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.info.yml @@ -0,0 +1,8 @@ +name: Hoeringsportal project fixtures +type: module +description: 'Provides project fixtures for the site.' +core_version_requirement: ^10 +package: ITK +dependencies: + - content_fixtures:content_fixtures + - hoeringsportal_base_fixtures:hoeringsportal_base_fixtures diff --git a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml new file mode 100644 index 00000000..9ed174f1 --- /dev/null +++ b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml @@ -0,0 +1,4 @@ +services: + Drupal\hoeringsportal_project_fixtures\Fixture\ProjectMainPageFixture: + tags: + - { name: content_fixture } diff --git a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php new file mode 100644 index 00000000..32ae1f32 --- /dev/null +++ b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php @@ -0,0 +1,125 @@ + 'project_main_page', + ]) + ->setTitle('Project') + ->set('field_short_description', 'This is the first project') + ->set( + 'field_project_image', + [ + ['target_id' => $this->getReference('media:Medium1')->id()], + ] + ) + ->set( + 'body', + [ + 'value' => <<<'BODY' +

This project is the very first project, and will focus on some stuff.

+BODY, + 'format' => 'filtered_html', + ], + ); + + $paragraph = Paragraph::create([ + 'type' => 'image', + ]) + ->set( + 'field_paragraph_image', + [ + ['target_id' => $this->getReference('media:Medium2')->id()], + ] + ); + $paragraph->save(); + $entity->field_content_sections->appendItem([ + 'target_id' => $paragraph->id(), + 'target_revision_id' => $paragraph->getRevisionId(), + ]); + + $paragraph = Paragraph::create([ + 'type' => 'info_box', + ]) + ->set('field_paragraph_title', 'Important!') + ->set( + 'field_content_block_text', + [ + 'value' => <<<'BODY' +

Beware that this is the first project.

+BODY, + 'format' => 'filtered_html', + ] + ); + $paragraph->save(); + $entity->field_content_sections->appendItem([ + 'target_id' => $paragraph->id(), + 'target_revision_id' => $paragraph->getRevisionId(), + ]); + + $entity->save(); + $this->addReference('node:project_main_page:1', $entity); + + $entity = $entity->createDuplicate(); + $entity + ->setTitle('Another project') + ->set('field_short_description', 'We have more than one project') + ->set( + 'field_project_image', + [ + ['target_id' => $this->getReference('media:Map1')->id()], + ] + ) + ->set( + 'body', + [ + 'value' => <<<'BODY' +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus accumsan ante sit amet fermentum. Aliquam aliquet massa ut enim vulputate feugiat. Maecenas tincidunt risus rhoncus, interdum neque ac, aliquet ex. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras commodo, odio id scelerisque pulvinar, erat neque fringilla purus, non faucibus metus nibh ullamcorper arcu. In posuere magna ante, in cursus velit lacinia eu. Sed viverra blandit sem. Donec quam orci, tincidunt eget porttitor at, luctus eu est. In sed nulla mauris. Etiam arcu augue, accumsan vitae magna vel, interdum imperdiet magna.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus accumsan ante sit amet fermentum. Aliquam aliquet massa ut enim vulputate feugiat. Maecenas tincidunt risus rhoncus, interdum neque ac, aliquet ex. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras commodo, odio id scelerisque pulvinar, erat neque fringilla purus, non faucibus metus nibh ullamcorper arcu. In posuere magna ante, in cursus velit lacinia eu. Sed viverra blandit sem. Donec quam orci, tincidunt eget porttitor at, luctus eu est. In sed nulla mauris. Etiam arcu augue, accumsan vitae magna vel, interdum imperdiet magna. +

+BODY, + 'format' => 'filtered_html', + ], + ); + $entity->save(); + $this->addReference('node:project_main_page:2', $entity); + } + + /** + * {@inheritdoc} + */ + public function getDependencies() { + return [ + MediaFixture::class, + ParagraphFixture::class, + ]; + } + + /** + * {@inheritdoc} + */ + public function getGroups() { + return ['node', 'project']; + } + +}