From 9aec3279454e31bca47154ad172d613395e69408 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Sat, 14 Nov 2020 09:46:05 +0000
Subject: [PATCH] 4l: Expect a custom Post class to be returned

---
 web/modules/custom/my_module/src/Entity/Post.php            | 5 +++++
 .../my_module/tests/src/Kernel/ArticleRepositoryTest.php    | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 web/modules/custom/my_module/src/Entity/Post.php

diff --git a/web/modules/custom/my_module/src/Entity/Post.php b/web/modules/custom/my_module/src/Entity/Post.php
new file mode 100644
index 0000000..9690518
--- /dev/null
+++ b/web/modules/custom/my_module/src/Entity/Post.php
@@ -0,0 +1,5 @@
+<?php
+
+namespace Drupal\my_module\Entity;
+
+class Post {}
diff --git a/web/modules/custom/my_module/tests/src/Kernel/ArticleRepositoryTest.php b/web/modules/custom/my_module/tests/src/Kernel/ArticleRepositoryTest.php
index f3af15e..443486b 100644
--- a/web/modules/custom/my_module/tests/src/Kernel/ArticleRepositoryTest.php
+++ b/web/modules/custom/my_module/tests/src/Kernel/ArticleRepositoryTest.php
@@ -4,6 +4,7 @@ namespace Drupal\Tests\my_module\Kernel;
 
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
+use Drupal\my_module\Entity\Post;
 use Drupal\my_module\Repository\ArticleRepository;
 use Drupal\node\NodeInterface;
 use Drupal\Tests\node\Traits\NodeCreationTrait;
@@ -23,9 +24,8 @@ class ArticleRepositoryTest extends EntityKernelTestBase {
 
     $this->assertCount(1, $articles);
     $this->assertIsObject($articles[1]);
-    $this->assertInstanceOf(NodeInterface::class, $articles[1]);
-    $this->assertSame('article', $articles[1]->bundle());
-    $this->assertSame('Test post', $articles[1]->label());
+    $this->assertInstanceOf(Post::class, $articles[1]);
+    $this->assertSame('Test post', $articles[1]->getTitle());
   }
 
   /** @test */