From 6e8a34112aac70afaafdf37ab0d248ef032096f1 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Mon, 19 Jun 2023 15:32:31 +0300 Subject: [PATCH] Add tests for the Item.isBelong method. --- tests/Feature/ItemTest.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/Feature/ItemTest.php b/tests/Feature/ItemTest.php index 074cfbf..f973d15 100644 --- a/tests/Feature/ItemTest.php +++ b/tests/Feature/ItemTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use App\Models\Company; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; @@ -10,6 +11,34 @@ use App\Models\Item; class ItemTest extends TestCase { + /* Item methods */ + + public function test_item_belong_right_company(): void + { + $right_company_name = 'testCompany'; + $company = Company::where('name', $right_company_name)->first(); + + $item_name = 'Pizza Polo'; + $item = Item::where('name', $item_name)->first(); + + $is_belong = $item->isBelong($company); + + $this->assertTrue($is_belong); + } + + public function test_item_belong_wrong_company(): void + { + $wrong_company_name = 'testCompany2'; + $company = Company::where('name', $wrong_company_name)->first(); + + $item_name = 'Pizza Polo'; + $item = Item::where('name', $item_name)->first(); + + $is_belong = $item->isBelong($company); + + $this->assertFalse($is_belong); + } + /* Item validation */ public function test_item_with_empty_name(): void