From f13d9769b0dd79acf6d0dffe3e021a8ceb4b1f9d Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 18 Nov 2018 17:31:25 +0800 Subject: [PATCH] Add product belongs to unit relation test --- tests/Unit/Integration/ProductTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Unit/Integration/ProductTest.php b/tests/Unit/Integration/ProductTest.php index 6e0c06f..1fdee77 100644 --- a/tests/Unit/Integration/ProductTest.php +++ b/tests/Unit/Integration/ProductTest.php @@ -2,11 +2,15 @@ namespace Tests\Unit\Integration; +use App\Unit; use App\Product; use Tests\TestCase; +use Illuminate\Foundation\Testing\RefreshDatabase; class ProductTest extends TestCase { + use RefreshDatabase; + /** @test */ public function it_has_get_price_method() { @@ -41,4 +45,13 @@ class ProductTest extends TestCase $product = new Product(['cash_price' => 2000, 'credit_price' => null]); $this->assertEquals(2000, $product->getPrice('credit')); } + + /** @test */ + public function a_product_has_belongs_to_unit_relation() + { + $product = factory(Product::class)->make(); + + $this->assertInstanceOf(Unit::class, $product->unit); + $this->assertEquals($product->unit_id, $product->unit->id); + } }