diff --git a/web/modules/custom/my_module/src/Entity/Post.php b/web/modules/custom/my_module/src/Entity/Post.php index 315c676..b3cc15b 100644 --- a/web/modules/custom/my_module/src/Entity/Post.php +++ b/web/modules/custom/my_module/src/Entity/Post.php @@ -2,8 +2,16 @@ namespace Drupal\my_module\Entity; +use Drupal\node\NodeInterface; + class Post { + private $node; + + public function __construct(NodeInterface $node) { + $this->node = $node; + } + public function getTitle(): string { return ''; } diff --git a/web/modules/custom/my_module/tests/src/Unit/Entity/PostTest.php b/web/modules/custom/my_module/tests/src/Unit/Entity/PostTest.php index 254408a..841dd29 100644 --- a/web/modules/custom/my_module/tests/src/Unit/Entity/PostTest.php +++ b/web/modules/custom/my_module/tests/src/Unit/Entity/PostTest.php @@ -9,7 +9,7 @@ class PostTest extends UnitTestCase { /** @test */ public function it_returns_the_title() { - $post = new Post(); + $post = new Post($node); $this->assertSame('Test post', $post->getTitle()); }