Skip to content

Instantly share code, notes, and snippets.

@aungwinthant
Last active September 16, 2019 05:36
Show Gist options
  • Save aungwinthant/61ecf265d05ffb5f6d97916de2c48397 to your computer and use it in GitHub Desktop.
Save aungwinthant/61ecf265d05ffb5f6d97916de2c48397 to your computer and use it in GitHub Desktop.
Unit Testing Save Method
<?php
namespace Tests\Feature;
use App\Models\Category;
use App\Repositories\CategoryRepository;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class CategoryRepositoryTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function test_save_method_in_repository()
{
$data = [
"name" => "Test Category",
];
$categoryRepo = new CategoryRepository(new Category);
$category = $categoryRepo->save($data);
$this->assertInstanceOf(Category::class,$category);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment