From 37db8803e20ad05ec95eb97bfb3b34adfcc62b70 Mon Sep 17 00:00:00 2001 From: PovilasKorop Date: Tue, 16 Nov 2021 07:25:20 +0200 Subject: [PATCH] Improved first test --- README.md | 4 ++-- app/Models/{News.php => Morningnews.php} | 3 +-- tests/Feature/EloquentTest.php | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename app/Models/{News.php => Morningnews.php} (70%) diff --git a/README.md b/README.md index 60a03fb..abc1ee4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Good luck! ## Task 1. Model with Different Table Name. -In `app/Models/News.php` file, specify that the model would work with "morning_news" table, as it is created in the migrations. +In `app/Models/Morningnews.php` file, change it so that the model would work with "morning_news" table, as it is created in the migrations. -Test method `test_create_model_different_table()`. +Test method `test_create_model_incorrect_table()`. diff --git a/app/Models/News.php b/app/Models/Morningnews.php similarity index 70% rename from app/Models/News.php rename to app/Models/Morningnews.php index 8329710..2335e17 100644 --- a/app/Models/News.php +++ b/app/Models/Morningnews.php @@ -5,8 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -// TASK: Define the model's related table as "morning_news" -class News extends Model +class Morningnews extends Model { use HasFactory; diff --git a/tests/Feature/EloquentTest.php b/tests/Feature/EloquentTest.php index 23796cf..3cf2f52 100644 --- a/tests/Feature/EloquentTest.php +++ b/tests/Feature/EloquentTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use App\Models\Morningnews; use App\Models\News; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -10,13 +11,13 @@ class EloquentTest extends TestCase { use RefreshDatabase; - public function test_create_model_different_table() + // TASK: Make the model Morningnews work with DB table "morning_news" + public function test_create_model_incorrect_table() { $article = ['title' => 'Something', 'news_text' => 'Something']; - News::create($article); + Morningnews::create($article); $this->assertDatabaseHas('morning_news', $article); } - }