5c: Add the node as a constructor argument
> Undefined variable: node
This commit is contained in:
parent
1fe7119b5d
commit
61664cb263
|
@ -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 '';
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue