-
Notifications
You must be signed in to change notification settings - Fork 2
/
http.php
50 lines (38 loc) · 1.45 KB
/
http.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Bank;
use App\User;
use URL;
class BankTest extends TestCase
{
use DatabaseTransactions;
/**
* A basic test example.
*
* @return void
*/
protected function setUp() {
parent::setUp();
// kode untuk menset base url nya jadi localhost
// karena kalau gak localhost jadi tidak bisa jalan testing http nya
// selalu responnya 404
URL::forceRootUrl('http://localhost');
}
//CRUD TESTING
public function testBankCrud() {
//TAMBAH BANK
$bank = Bank::create(["nama_bank" => "BRI","atas_nama" => "Rindang Ramadhan","no_rek"=>"1234567890"]);
$this->assertDatabaseHas('banks', ["nama_bank" => "BRI","atas_nama" => "Rindang Ramadhan","no_rek"=>"1234567890"]);
//UPDATE BANK
Bank::find($bank->id)->update(["nama_bank" => "BCA", "atas_nama"=>"Afrizal Ansyah", "no_rek"=>"9876543210"]);
$this->assertDatabaseHas('banks', ["nama_bank" => "BCA", "atas_nama" => "Afrizal Ansyah", "no_rek" => "9876543210"]);
//DELETE BANK
$hapus_bank = Bank::destroy($bank->id);
$bank = Bank::find($bank->id);
$this->assertDatabaseMissing('banks', ["nama_bank" => "BCA", "atas_nama" => "Afrizal Ansyah", "no_rek" => "9876543210"]);
}
}