Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shivishbrahma committed Jun 10, 2023
1 parent a177fe2 commit 4606f68
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
6 changes: 1 addition & 5 deletions tests/Unit/ApprovalUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ class ApprovalUnitTest extends TestCase
use RefreshDatabase;
private $user, $approval;

/**
* A basic unit test example.
*
* @return void
*/

protected function setUp(): void
{
parent::setUp();
Expand Down
21 changes: 10 additions & 11 deletions tests/Unit/CartUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Cart;
use App\Models\Product;
use App\Models\Seller;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
Expand All @@ -12,20 +13,18 @@ class CartUnitTest extends TestCase
{
use RefreshDatabase;

private $cart, $user, $product;
private $cart, $user, $sellerUser, $seller, $product;


/**
* A basic unit test example.
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();

$this->user = User::factory()->seller()->make();
$this->product = Product::factory()->make();
$this->cart = Cart::factory()->make(['user_id' => $this->user->id, 'product_id' => $this->product->id]);
$this->user = User::factory()->create();
$this->sellerUser = User::factory()->seller()->create();
$this->seller = Seller::factory()->create(['user_id' => $this->sellerUser->id]);
$this->product = Product::factory()->create(['seller_id' => $this->seller->id]);
$this->cart = Cart::factory()->create(['user_id' => $this->user->id, 'product_id' => $this->product->id]);
}

public function testFillableAttributes()
Expand All @@ -37,12 +36,12 @@ public function testFillableAttributes()

public function testCartBelongstoUser()
{
$this->assertEquals($this->cart->user_id, $this->user->id);
$this->assertEquals($this->cart->user->id, $this->user->id);
}

public function testProductBelongstoUser()
{
$this->assertEquals($this->cart->product_id, $this->product->id);
$this->assertEquals($this->cart->product->id, $this->product->id);
}

public function testGetTotalPrice()
Expand Down
7 changes: 1 addition & 6 deletions tests/Unit/ContactUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@

use App\Models\Contact;
use Tests\TestCase;

class ContactUnitTest extends TestCase
{
private $contact;

/**
* A basic unit test example.
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->contact = Contact::factory()->make();

}

public function testFillableAttributes()
Expand Down
18 changes: 8 additions & 10 deletions tests/Unit/FileImageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@

namespace Tests\Unit;

use PHPUnit\Framework\TestCase;
use App\FileImage;
use App\Models\FileImage;
use Tests\TestCase;

class FileImageUnitTest extends TestCase
{
/**
* A basic unit test example.
*
* @return void
*/
private $fileimage;


protected function setUp(): void
{
parent::setUp();

$this->fileimage = new FileImage();
$this->fileimage = FileImage::factory()->make();
}

public function testFillableAttributes()
{
$fillable = ['name', 'type', 'ref_id'];

$this->assertEquals($this->fileimage->getFillable(), $fillable);
}

}

0 comments on commit 4606f68

Please sign in to comment.