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:
Oliver Davies 2020-11-14 10:03:34 +00:00
parent 0b4c648ac6
commit bd68420fc1

View file

@ -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());