From 1be8440519a96ca3a366998ebaf696df2c304305 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 14 Nov 2020 09:35:10 +0000 Subject: [PATCH] 4h: Ensure that only articles are returned --- .../tests/src/Kernel/ArticleRepositoryTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 3d44d60..de9c7eb 100644 --- a/web/modules/custom/my_module/tests/src/Kernel/ArticleRepositoryTest.php +++ b/web/modules/custom/my_module/tests/src/Kernel/ArticleRepositoryTest.php @@ -27,6 +27,18 @@ class ArticleRepositoryTest extends EntityKernelTestBase { $this->assertSame('Test post', $articles[1]->label()); } + /** @test */ + public function nodes_that_are_not_articles_are_not_returned() { + $this->createNode(['type' => 'article'])->save(); + $this->createNode(['type' => 'article'])->save(); + $this->createNode(['type' => 'article'])->save(); + + $repository = $this->container->get(ArticleRepository::class); + $articles = $repository->getAll(); + + $this->assertCount(3, $articles); + } + protected function setUp() { parent::setUp();