From d27bcabc8bc0ab41dbd2219519718b11f8f9ce94 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Thu, 2 Jan 2020 15:08:08 +0100 Subject: tests: code coverage cleanup --- tests/Unit/Models/User/UserTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/Unit/Models/User') diff --git a/tests/Unit/Models/User/UserTest.php b/tests/Unit/Models/User/UserTest.php index fd8e2396..7f56d0c4 100644 --- a/tests/Unit/Models/User/UserTest.php +++ b/tests/Unit/Models/User/UserTest.php @@ -5,6 +5,7 @@ namespace Engelsystem\Test\Unit\Models; use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Models\BaseModel; use Engelsystem\Models\News; +use Engelsystem\Models\NewsComment; use Engelsystem\Models\Question; use Engelsystem\Models\User\Contact; use Engelsystem\Models\User\HasUserModel; @@ -148,6 +149,22 @@ class UserTest extends TestCase ]; } + /** + * Tests that accessing the NewsComments of an User works. + * + * @covers \Engelsystem\Models\User\User::newsComments + */ + public function testNewsComments(): void + { + ($user = new User($this->data))->save(); + $newsComment = NewsComment::create(['news_id' => 0, 'text' => 'test comment', 'user_id' => $user->id]); + $comments = $user->newsComments; + + $this->assertCount(1, $comments); + $comment = $comments->first(); + $this->assertSame($newsComment->id, $comment->id); + } + /** * @covers \Engelsystem\Models\User\User::questionsAsked */ -- cgit v1.2.3-70-g09d2