diff --git a/web/modules/custom/example/tests/src/Functional/BlogPageTest.php b/web/modules/custom/example/tests/src/Functional/BlogPageTest.php index 3d45b92..21acbef 100644 --- a/web/modules/custom/example/tests/src/Functional/BlogPageTest.php +++ b/web/modules/custom/example/tests/src/Functional/BlogPageTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\example\Functional; +use Drupal\example\Builder\PostBuilder; use Drupal\Tests\BrowserTestBase; use Symfony\Component\HttpFoundation\Response; @@ -33,4 +34,28 @@ class BlogPageTest extends BrowserTestBase { $assert->pageTextContains('Third post'); } + public function testOnlyPublishedNodesAreShown(): void { + PostBuilder::create() + ->setTitle('Post one') + ->isPublished() + ->getPost(); + + PostBuilder::create() + ->setTitle('Post two') + ->isNotPublished() + ->getPost(); + + PostBuilder::create() + ->setTitle('Post three') + ->isPublished() + ->getPost(); + + $this->drupalGet('/blog'); + + $assert = $this->assertSession(); + $assert->pageTextContains('Post one'); + $assert->pageTextNotContains('Post two'); + $assert->pageTextContains('Post three'); + } + }