From 09d4c662bebe35f6e09bb7aa76d2948bb590fc2f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 8 Aug 2023 12:00:00 +0100 Subject: [PATCH] feat(blog): add the initial blog page --- .../custom/my_module/my_module.info.yml | 3 ++ .../custom/my_module/my_module.routing.yml | 7 ++++ .../src/Controller/BlogPageController.php | 22 +++++++++++++ .../tests/src/Functional/BlogPageTest.php | 33 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 web/modules/custom/my_module/my_module.info.yml create mode 100644 web/modules/custom/my_module/my_module.routing.yml create mode 100644 web/modules/custom/my_module/src/Controller/BlogPageController.php create mode 100644 web/modules/custom/my_module/tests/src/Functional/BlogPageTest.php diff --git a/web/modules/custom/my_module/my_module.info.yml b/web/modules/custom/my_module/my_module.info.yml new file mode 100644 index 0000000..60e27aa --- /dev/null +++ b/web/modules/custom/my_module/my_module.info.yml @@ -0,0 +1,3 @@ +name: My Module +type: module +core_version_requirement: ^10 diff --git a/web/modules/custom/my_module/my_module.routing.yml b/web/modules/custom/my_module/my_module.routing.yml new file mode 100644 index 0000000..9683277 --- /dev/null +++ b/web/modules/custom/my_module/my_module.routing.yml @@ -0,0 +1,7 @@ +blog.page: + path: /blog + defaults: + _controller: Drupal\my_module\Controller\BlogPageController + _title: Blog + requirements: + _permission: access content diff --git a/web/modules/custom/my_module/src/Controller/BlogPageController.php b/web/modules/custom/my_module/src/Controller/BlogPageController.php new file mode 100644 index 0000000..ae4d46a --- /dev/null +++ b/web/modules/custom/my_module/src/Controller/BlogPageController.php @@ -0,0 +1,22 @@ + + */ + public function __invoke(): array { + return [ + '#markup' => $this->t('Welcome to my blog!'), + ]; + } + +} diff --git a/web/modules/custom/my_module/tests/src/Functional/BlogPageTest.php b/web/modules/custom/my_module/tests/src/Functional/BlogPageTest.php new file mode 100644 index 0000000..1405f0e --- /dev/null +++ b/web/modules/custom/my_module/tests/src/Functional/BlogPageTest.php @@ -0,0 +1,33 @@ +drupalGet('/blog'); + + $assert = $this->assertSession(); + + $assert->statusCodeEquals(Response::HTTP_OK); + $assert->responseContains('

Blog

'); + $assert->pageTextContains('Welcome to my blog!'); + } + +}