From 76172f4667ec243ee07847b39cf4446238c63968 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 19 Mar 2020 21:55:28 +0000 Subject: [PATCH] 5b: Add a test for which nodes are wrappable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we attempt to wrap a node which is not an article, we expect an Exception to be thrown. As one currently isn’t, the test will fail. --- .../tests/src/Unit/Wrapper/ArticleWrapperTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/modules/custom/my_module/tests/src/Unit/Wrapper/ArticleWrapperTest.php b/web/modules/custom/my_module/tests/src/Unit/Wrapper/ArticleWrapperTest.php index 4812f99..d1a8be8 100644 --- a/web/modules/custom/my_module/tests/src/Unit/Wrapper/ArticleWrapperTest.php +++ b/web/modules/custom/my_module/tests/src/Unit/Wrapper/ArticleWrapperTest.php @@ -21,5 +21,15 @@ class ArticleWrapperTest extends UnitTestCase { $this->assertSame('article', $articleWrapper->getOriginal()->bundle()); } + /** @test */ + public function it_throws_an_exception_if_the_node_is_not_an_article() { + $this->expectException(\InvalidArgumentException::class); + + $page = $this->createMock(NodeInterface::class); + $page->method('bundle')->willReturn('page'); + + new ArticleWrapper($page); + } + }