From 1fe63e7326426d3234123d8634b67e8017599f43 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 9 Jun 2025 00:51:41 +0100 Subject: [PATCH] Add initial PresentationCounter logic --- .../opd_presentations.info.yml | 5 ++ .../opd_presentations.services.yml | 2 + .../src/PresentationCounter.php | 13 +++++ .../src/Kernel/PresentationCounterTest.php | 49 +++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 modules/opd_presentations/opd_presentations.info.yml create mode 100644 modules/opd_presentations/opd_presentations.services.yml create mode 100644 modules/opd_presentations/src/PresentationCounter.php create mode 100644 modules/opd_presentations/tests/src/Kernel/PresentationCounterTest.php diff --git a/modules/opd_presentations/opd_presentations.info.yml b/modules/opd_presentations/opd_presentations.info.yml new file mode 100644 index 000000000..a0209fbb3 --- /dev/null +++ b/modules/opd_presentations/opd_presentations.info.yml @@ -0,0 +1,5 @@ +name: Presentations +description: Custom functionality for presentations. +core_version_requirement: ^11 +type: module +package: Custom diff --git a/modules/opd_presentations/opd_presentations.services.yml b/modules/opd_presentations/opd_presentations.services.yml new file mode 100644 index 000000000..e6b2fbe6c --- /dev/null +++ b/modules/opd_presentations/opd_presentations.services.yml @@ -0,0 +1,2 @@ +services: + Drupal\opd_presentations\PresentationCounter: {} diff --git a/modules/opd_presentations/src/PresentationCounter.php b/modules/opd_presentations/src/PresentationCounter.php new file mode 100644 index 000000000..28836bf34 --- /dev/null +++ b/modules/opd_presentations/src/PresentationCounter.php @@ -0,0 +1,13 @@ +createPresentation( + events: [ + Paragraph::create(['type' => 'event']), + ], + ); + + $counter = $this->container->get(PresentationCounter::class); + + $this->assertSame( + actual: $counter->getCount(), + expected: 1, + ); + } + + /** + * @param ParagraphInterface[] $events + */ + private function createPresentation(array $events): NodeInterface { + return $this->createNode([ + 'field_events' => $events, + 'type' => 'presentation', + ]); + } + +}