From 6534191d59521e1e5a88638b1c6a1c77f74dd12a Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Thu, 31 Oct 2019 20:02:34 +0100 Subject: Migrate news to model class --- tests/Unit/Models/News/NewsTest.php | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/Unit/Models/News/NewsTest.php (limited to 'tests/Unit/Models/News/NewsTest.php') diff --git a/tests/Unit/Models/News/NewsTest.php b/tests/Unit/Models/News/NewsTest.php new file mode 100644 index 00000000..7309c0b0 --- /dev/null +++ b/tests/Unit/Models/News/NewsTest.php @@ -0,0 +1,80 @@ +initDatabase(); + + $this->user = User::make([ + 'name' => 'lorem', + 'password' => '', + 'email' => 'foo@bar.batz', + 'api_key' => '', + ]); + $this->user->save(); + + $this->newsData = [ + 'title' => 'test title', + 'text' => 'test text', + 'user_id' => $this->user->id + ]; + } + + /** + * Tests that creating a News item with default values works. + * + * @return void + */ + public function testCreateDefault(): void + { + $news = News::create($this->newsData); + + $this->assertSame(1, $news->id); + $this->assertSame($this->newsData['title'], $news->title); + $this->assertSame($this->newsData['text'], $news->text); + $this->assertFalse($news->is_meeting); + } + + /** + * Tests that creating a News item with all fill values works. + * + * @return void + */ + public function testCreate(): void + { + $news = News::create( + $this->newsData + ['is_meeting' => true,] + ); + + $this->assertSame(1, $news->id); + $this->assertSame($this->newsData['title'], $news->title); + $this->assertSame($this->newsData['text'], $news->text); + $this->assertTrue($news->is_meeting); + } +} -- cgit v1.3.1