InventoryAccountController_MissionTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Tests\Inventory\Http\InventoryController;
  3. use App\Authority;
  4. use App\Owner;
  5. use App\Role;
  6. use App\User;
  7. use Illuminate\Support\Facades\DB;
  8. use Tests\TestCase;
  9. class InventoryControllerMissionTest extends TestCase
  10. {
  11. public $response=null;
  12. public $role;
  13. public $user;
  14. function setUp(): void
  15. {
  16. parent::setUp(); // TODO: Change the autogenerated stub
  17. if(!$this->user){
  18. $this->user = factory(User::class)->create();
  19. $this->role= Role::firstOrCreate([
  20. 'name'=>'testRole',
  21. ]);
  22. $this->assertNotEmpty($this->role->id);
  23. $authority= Authority::where('name','库存管理-盘点')->first();
  24. DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$this->role->id]);
  25. DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
  26. }
  27. $url = 'http://bswas/inventory/stockInventory/mission';
  28. $this->response=$this->actingAs($this->user)->get($url);
  29. }
  30. function testMissionNotHavingException(){
  31. $this->response->assertDontSee('Exception');
  32. }
  33. function testMissionViewIsRight(){
  34. $this->response->assertViewIs('inventory.stockInventory.mission');
  35. }
  36. function testMissionHasOwners(){
  37. $owners=Owner::select('id','name')->get();
  38. $this->response->assertViewHas('owners',$owners);
  39. }
  40. function testMissionHasInventories(){
  41. $this->response->assertViewHas('inventoryAccounts');
  42. }
  43. function tearDown(): void
  44. {
  45. DB::table('user_role')->where('id_role',$this->role['id'])->delete();
  46. DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
  47. User::where('id',$this->user['id'])->delete();
  48. Role::where('id',$this->role['id'])->delete();
  49. parent::tearDown(); // TODO: Change the autogenerated stub
  50. }
  51. }