5d: Create a mock node
> TypeError: Return value of Drupal\my_module\Entity\Post::getTitle() > must be of the type string, null returned
This commit is contained in:
parent
0b4c648ac6
commit
bd68420fc1
|
@ -3,12 +3,15 @@
|
|||
namespace Drupal\Tests\my_module\Unit\Entity;
|
||||
|
||||
use Drupal\my_module\Entity\Post;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
class PostTest extends UnitTestCase {
|
||||
|
||||
/** @test */
|
||||
public function it_returns_the_title() {
|
||||
$node = $this->createMock(NodeInterface::class);
|
||||
|
||||
$post = new Post($node);
|
||||
|
||||
$this->assertSame('Test post', $post->getTitle());
|
||||
|
|
Loading…
Reference in a new issue