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;
|
namespace Drupal\my_module\Entity;
|
||||||
|
|
||||||
|
use Drupal\node\NodeInterface;
|
||||||
|
|
||||||
class Post {
|
class Post {
|
||||||
|
|
||||||
|
private $node;
|
||||||
|
|
||||||
|
public function __construct(NodeInterface $node) {
|
||||||
|
$this->node = $node;
|
||||||
|
}
|
||||||
|
|
||||||
public function getTitle(): string {
|
public function getTitle(): string {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class PostTest extends UnitTestCase {
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_returns_the_title() {
|
public function it_returns_the_title() {
|
||||||
$post = new Post();
|
$post = new Post($node);
|
||||||
|
|
||||||
$this->assertSame('Test post', $post->getTitle());
|
$this->assertSame('Test post', $post->getTitle());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue