From 7ab3f9a6e7d4de36d6f5534fb28fa48c5bb6f767 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net>
Date: Mon, 17 Mar 2025 14:40:13 -0400
Subject: [PATCH 1/5] Add tests

---
 .../src/Functional/ComponentValidationTest.php      |   2 ++
 .../src/Functional/ComponentValidationTest.php      |   3 +++
 .../tests/src/ContentModelTestTrait.php             |   9 +++++++++
 ...upalCon-Atlanta .webp => DrupalCon-Atlanta.webp} | Bin
 .../content/media/drupalcon-atlanta-image.yml       |   2 +-
 .../src/Functional/ComponentValidationTest.php      |   2 ++
 .../src/Functional/ComponentValidationTest.php      |   2 ++
 .../src/Functional/ComponentValidationTest.php      |   2 ++
 .../src/Functional/ComponentValidationTest.php      |   3 +++
 .../src/Functional/ComponentValidationTest.php      |   2 ++
 10 files changed, 26 insertions(+), 1 deletion(-)
 rename recipes/drupal_cms_events/content/file/{DrupalCon-Atlanta .webp => DrupalCon-Atlanta.webp} (100%)

diff --git a/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php
index c6cc2cb2a..d59fa4340 100644
--- a/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php
@@ -36,6 +36,8 @@ class ComponentValidationTest extends BrowserTestBase {
     $this->applyRecipe($dir);
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
+
+    $this->assertFileExists('4bb02092-717b-44c8-9147-be3821c244c6');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php
index 17a6d24a8..0db9e98d2 100644
--- a/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php
@@ -36,6 +36,9 @@ class ComponentValidationTest extends BrowserTestBase {
     $this->applyRecipe($dir);
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
+
+    $this->assertFileExists('47b880a9-c2a4-4ed6-844d-95c6d6677004');
+    $this->assertFileExists('831ca26d-590c-4f34-8545-379e9d77106f');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php b/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
index 23f937d3f..e5ca2fde9 100644
--- a/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
+++ b/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
@@ -6,12 +6,21 @@ namespace Drupal\Tests\drupal_cms_content_type_base;
 
 use Drupal\Core\Entity\Display\EntityDisplayInterface;
 use Drupal\Core\Entity\EntityFieldManagerInterface;
+use Drupal\Core\Entity\EntityRepositoryInterface;
+use Drupal\file\FileInterface;
 use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface;
 use Drupal\Tests\BrowserTestBase;
 use PHPUnit\Framework\Assert;
 
 trait ContentModelTestTrait {
 
+  protected function assertFileExists(string $uuid): void {
+    $file = $this->container->get(EntityRepositoryInterface::class)
+      ->loadEntityByUuid('file', $uuid);
+    Assert::assertInstanceOf(FileInterface::class, $file, "There is no file with UUID '$uuid'.");
+    $this->assertFileExists($file->getFileUri());
+  }
+
   /**
    * Returns the weights of all components in a display.
    *
diff --git a/recipes/drupal_cms_events/content/file/DrupalCon-Atlanta .webp b/recipes/drupal_cms_events/content/file/DrupalCon-Atlanta.webp
similarity index 100%
rename from recipes/drupal_cms_events/content/file/DrupalCon-Atlanta .webp
rename to recipes/drupal_cms_events/content/file/DrupalCon-Atlanta.webp
diff --git a/recipes/drupal_cms_events/content/media/drupalcon-atlanta-image.yml b/recipes/drupal_cms_events/content/media/drupalcon-atlanta-image.yml
index 1fafdacdb..4aee2ea27 100644
--- a/recipes/drupal_cms_events/content/media/drupalcon-atlanta-image.yml
+++ b/recipes/drupal_cms_events/content/media/drupalcon-atlanta-image.yml
@@ -15,7 +15,7 @@ default:
       target_id: 1
   name:
     -
-      value: 'DrupalCon Atlanta.png'
+      value: 'DrupalCon-Atlanta.webp'
   created:
     -
       value: 1734408755
diff --git a/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php
index eb27c2647..43c8e18e2 100644
--- a/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php
@@ -37,6 +37,8 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
+    $this->assertFileExists('601c1f74-4633-4069-ae90-57c645568b1c');
+
     // The privacy settings should be available to anonymous users.
     $this->drupalPlaceBlock('system_menu_block:footer', ['label' => 'Footer']);
     $this->drupalGet('<front>');
diff --git a/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php
index 4a6f8f183..dbf0d89e6 100644
--- a/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php
@@ -41,6 +41,8 @@ class ComponentValidationTest extends BrowserTestBase {
     $this->applyRecipe($dir);
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
+
+    $this->assertFileExists('f57ca5cc-9336-44d5-b847-b24876ffd1f6');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php
index adf56b527..f0f5c2394 100644
--- a/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php
@@ -36,6 +36,8 @@ class ComponentValidationTest extends BrowserTestBase {
     $this->applyRecipe($dir);
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
+
+    $this->assertFileExists('5a635060-8540-4be7-bad9-8a51414731ad');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php
index 230c1b6b9..dd38b873d 100644
--- a/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php
@@ -36,6 +36,9 @@ class ComponentValidationTest extends BrowserTestBase {
     $this->applyRecipe($dir);
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
+
+    $this->assertFileExists('47b880a9-c2a4-4ed6-844d-95c6d6677004');
+    $this->assertFileExists('671c51f9-7a67-40ce-82de-750f53892f26');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
index 78980891e..829945627 100644
--- a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
@@ -65,6 +65,8 @@ class ComponentValidationTest extends BrowserTestBase {
     $dir = InstalledVersions::getInstallPath('drupal/drupal_cms_starter');
     $this->applyRecipe($dir);
 
+    $this->assertFileExists('05439bd3-1c60-4e1a-8719-e9da071e88e4');
+
     // The front page should be accessible to everyone.
     $this->drupalGet('<front>');
     $assert_session = $this->assertSession();
-- 
GitLab


From 09fb27b318a162d1bb40c1b714ca9d9c601e9659 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net>
Date: Mon, 17 Mar 2025 14:47:11 -0400
Subject: [PATCH 2/5] Fix wrong name

---
 .../tests/src/Functional/ComponentValidationTest.php   |  2 +-
 .../tests/src/Functional/ComponentValidationTest.php   |  4 ++--
 .../tests/src/ContentModelTestTrait.php                | 10 ++++++++--
 .../tests/src/Functional/ComponentValidationTest.php   |  2 +-
 .../tests/src/Functional/ComponentValidationTest.php   |  2 +-
 .../tests/src/Functional/ComponentValidationTest.php   |  2 +-
 .../tests/src/Functional/ComponentValidationTest.php   |  4 ++--
 .../tests/src/Functional/ContentMetaTagsTest.php       |  2 +-
 .../tests/src/Functional/ComponentValidationTest.php   |  2 +-
 9 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php
index d59fa4340..ea008a8df 100644
--- a/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_blog/tests/src/Functional/ComponentValidationTest.php
@@ -37,7 +37,7 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('4bb02092-717b-44c8-9147-be3821c244c6');
+    $this->ensureFileExists('4bb02092-717b-44c8-9147-be3821c244c6');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php
index 0db9e98d2..ccb627f7b 100644
--- a/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_case_study/tests/src/Functional/ComponentValidationTest.php
@@ -37,8 +37,8 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('47b880a9-c2a4-4ed6-844d-95c6d6677004');
-    $this->assertFileExists('831ca26d-590c-4f34-8545-379e9d77106f');
+    $this->ensureFileExists('47b880a9-c2a4-4ed6-844d-95c6d6677004');
+    $this->ensureFileExists('831ca26d-590c-4f34-8545-379e9d77106f');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php b/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
index e5ca2fde9..cea04f5bb 100644
--- a/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
+++ b/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
@@ -14,11 +14,17 @@ use PHPUnit\Framework\Assert;
 
 trait ContentModelTestTrait {
 
-  protected function assertFileExists(string $uuid): void {
+  /**
+   * Ensures that the file associated with a file entity, actually exists.
+   *
+   * @param string $uuid
+   *   The UUID of a file entity.
+   */
+  protected function ensureFileExists(string $uuid): void {
     $file = $this->container->get(EntityRepositoryInterface::class)
       ->loadEntityByUuid('file', $uuid);
     Assert::assertInstanceOf(FileInterface::class, $file, "There is no file with UUID '$uuid'.");
-    $this->assertFileExists($file->getFileUri());
+    $this->ensureFileExists($file->getFileUri());
   }
 
   /**
diff --git a/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php
index 43c8e18e2..4c62d2315 100644
--- a/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_events/tests/src/Functional/ComponentValidationTest.php
@@ -37,7 +37,7 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('601c1f74-4633-4069-ae90-57c645568b1c');
+    $this->ensureFileExists('601c1f74-4633-4069-ae90-57c645568b1c');
 
     // The privacy settings should be available to anonymous users.
     $this->drupalPlaceBlock('system_menu_block:footer', ['label' => 'Footer']);
diff --git a/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php
index dbf0d89e6..329606c3f 100644
--- a/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_news/tests/src/Functional/ComponentValidationTest.php
@@ -42,7 +42,7 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('f57ca5cc-9336-44d5-b847-b24876ffd1f6');
+    $this->ensureFileExists('f57ca5cc-9336-44d5-b847-b24876ffd1f6');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php
index f0f5c2394..e8d79bb62 100644
--- a/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_person/tests/src/Functional/ComponentValidationTest.php
@@ -37,7 +37,7 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('5a635060-8540-4be7-bad9-8a51414731ad');
+    $this->ensureFileExists('5a635060-8540-4be7-bad9-8a51414731ad');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php
index dd38b873d..f56e8e1dc 100644
--- a/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_project/tests/src/Functional/ComponentValidationTest.php
@@ -37,8 +37,8 @@ class ComponentValidationTest extends BrowserTestBase {
     // Apply it again to prove that it is idempotent.
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('47b880a9-c2a4-4ed6-844d-95c6d6677004');
-    $this->assertFileExists('671c51f9-7a67-40ce-82de-750f53892f26');
+    $this->ensureFileExists('47b880a9-c2a4-4ed6-844d-95c6d6677004');
+    $this->ensureFileExists('671c51f9-7a67-40ce-82de-750f53892f26');
   }
 
   public function testContentModel(): void {
diff --git a/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php b/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php
index 961b20e44..c9ce6e639 100644
--- a/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php
+++ b/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php
@@ -29,7 +29,7 @@ class ContentMetaTagsTest extends BrowserTestBase {
 
     $uri = uniqid('public://') .  '.' . $extension;
     $uri = $random->image($uri, '100x100', '200x200');
-    $this->assertFileExists($uri);
+    $this->ensureFileExists($uri);
     $file = File::create(['uri' => $uri]);
     $file->save();
 
diff --git a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
index 829945627..68039364d 100644
--- a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
@@ -65,7 +65,7 @@ class ComponentValidationTest extends BrowserTestBase {
     $dir = InstalledVersions::getInstallPath('drupal/drupal_cms_starter');
     $this->applyRecipe($dir);
 
-    $this->assertFileExists('05439bd3-1c60-4e1a-8719-e9da071e88e4');
+    $this->ensureFileExists('05439bd3-1c60-4e1a-8719-e9da071e88e4');
 
     // The front page should be accessible to everyone.
     $this->drupalGet('<front>');
-- 
GitLab


From d1b3b1099e7c17f82fc88b20fe409a761e42c7ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net>
Date: Mon, 17 Mar 2025 14:58:08 -0400
Subject: [PATCH 3/5] Fix bad call

---
 .../tests/src/ContentModelTestTrait.php                         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php b/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
index cea04f5bb..80cd22415 100644
--- a/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
+++ b/recipes/drupal_cms_content_type_base/tests/src/ContentModelTestTrait.php
@@ -24,7 +24,7 @@ trait ContentModelTestTrait {
     $file = $this->container->get(EntityRepositoryInterface::class)
       ->loadEntityByUuid('file', $uuid);
     Assert::assertInstanceOf(FileInterface::class, $file, "There is no file with UUID '$uuid'.");
-    $this->ensureFileExists($file->getFileUri());
+    Assert::assertFileExists($file->getFileUri());
   }
 
   /**
-- 
GitLab


From b138ffcc8c24268ba5ff6b94a2f4d9728dd20246 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net>
Date: Mon, 17 Mar 2025 15:17:12 -0400
Subject: [PATCH 4/5] For fucks sake

---
 .../tests/src/Functional/ContentMetaTagsTest.php                | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php b/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php
index c9ce6e639..961b20e44 100644
--- a/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php
+++ b/recipes/drupal_cms_seo_tools/tests/src/Functional/ContentMetaTagsTest.php
@@ -29,7 +29,7 @@ class ContentMetaTagsTest extends BrowserTestBase {
 
     $uri = uniqid('public://') .  '.' . $extension;
     $uri = $random->image($uri, '100x100', '200x200');
-    $this->ensureFileExists($uri);
+    $this->assertFileExists($uri);
     $file = File::create(['uri' => $uri]);
     $file->save();
 
-- 
GitLab


From fb464c3122fae7e85630f931b74b8971a72aa873 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= <adam@phenaproxima.net>
Date: Mon, 17 Mar 2025 15:31:13 -0400
Subject: [PATCH 5/5] Missed a spot

---
 .../tests/src/Functional/ComponentValidationTest.php           | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
index 68039364d..b3b38e6ac 100644
--- a/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
+++ b/recipes/drupal_cms_starter/tests/src/Functional/ComponentValidationTest.php
@@ -9,6 +9,7 @@ use Composer\InstalledVersions;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\State\StateInterface;
 use Drupal\Tests\BrowserTestBase;
+use Drupal\Tests\drupal_cms_content_type_base\ContentModelTestTrait;
 use Symfony\Component\Process\PhpExecutableFinder;
 use Symfony\Component\Process\Process;
 
@@ -17,6 +18,8 @@ use Symfony\Component\Process\Process;
  */
 class ComponentValidationTest extends BrowserTestBase {
 
+  use ContentModelTestTrait;
+
   /**
    * {@inheritdoc}
    */
-- 
GitLab