Server IP : 103.11.96.170 / Your IP : 3.135.194.164 Web Server : Microsoft-IIS/10.0 System : Windows NT WIN-F6SLGVICLOP 10.0 build 17763 (Windows Server 2016) AMD64 User : elibrary.unsap.ac.id ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF Directory (0777) : D:/localhost/grosir/tests/Feature/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php namespace Tests\Feature; use App\Product; use App\Unit; use Illuminate\Foundation\Testing\DatabaseMigrations; use Tests\BrowserKitTestCase; class ManageUnitsTest extends BrowserKitTestCase { use DatabaseMigrations; /** @test */ public function user_can_see_unit_list() { $unit1 = factory(Unit::class)->create(['name' => 'Testing 123']); $unit2 = factory(Unit::class)->create(['name' => 'Testing 456']); $this->loginAsUser(); $this->visit(route('units.index')); $this->see($unit1->name); $this->see($unit2->name); } /** @test */ public function user_can_create_a_unit() { $this->loginAsUser(); $this->visit(route('units.index')); $this->click(trans('unit.create')); $this->seePageIs(route('units.index', ['action' => 'create'])); $this->type('Unit 1', 'name'); $this->press(trans('unit.create')); $this->seePageIs(route('units.index')); // $this->see(trans('unit.created')); $this->seeInDatabase('product_units', [ 'name' => 'Unit 1', ]); } /** @test */ public function user_can_edit_a_unit() { $this->loginAsUser(); $unit = factory(Unit::class)->create(); $this->visit(route('units.index')); $this->click('edit-unit-'.$unit->id); $this->seePageIs(route('units.index', ['action' => 'edit', 'id' => $unit->id])); $this->type('Unit 1', 'name'); $this->press(trans('unit.update')); // $this->see(trans('unit.updated')); $this->seePageIs(route('units.index')); $this->seeInDatabase('product_units', [ 'name' => 'Unit 1', ]); } /** @test */ public function user_can_delete_a_unit() { $this->loginAsUser(); $unit = factory(Unit::class)->create(); $this->visit(route('units.index')); $this->click('del-unit-'.$unit->id); $this->seePageIs(route('units.index', ['action' => 'delete', 'id' => $unit->id])); $this->seeInDatabase('product_units', [ 'id' => $unit->id, ]); $this->press(trans('app.delete_confirm_button')); $this->dontSeeInDatabase('product_units', [ 'id' => $unit->id, ]); } /** @test */ public function user_can_not_delete_a_unit_that_has_product() { $this->loginAsUser(); $product = factory(Product::class)->create(); $unitId = $product->unit_id; $this->visit(route('units.index')); $this->click('del-unit-'.$unitId); $this->seePageIs(route('units.index', ['action' => 'delete', 'id' => $unitId])); $this->press(trans('app.delete_confirm_button')); $this->see(trans('unit.undeleteable')); $this->seePageIs(route('units.index', ['action' => 'delete', 'id' => $unitId])); $this->seeInDatabase('product_units', [ 'id' => $unitId, ]); } }