Only articles should be used for Posts
An Exception should be thrown if the node passed to the `Post` entity is not an article. > Drupal\Tests\my_module\Unit\Entity\PostTest::it_throws_an_exception_if_the_node_is_not_an_article > Failed asserting that exception of type "InvalidArgumentException" is thrown.
This commit is contained in:
parent
655c854a80
commit
4be8e02246
|
@ -21,4 +21,15 @@ class PostTest extends UnitTestCase {
|
|||
$this->assertSame('Test post', $post->getTitle());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_throws_an_exception_if_the_node_is_not_an_article() {
|
||||
$node = $this->createMock(NodeInterface::class);
|
||||
|
||||
$node->method('bundle')->willReturn('page');
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
new Post($node);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue