InsertStoreTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Tests\Services\StoreService;
  3. use App\Services\StoreService;
  4. use Illuminate\Support\Facades\DB;
  5. use Tests\TestCase;
  6. class InsertStoreTest extends TestCase
  7. {
  8. /** @var StoreService $service */
  9. public $service;
  10. public $params=[];
  11. public function setUp(): void
  12. {
  13. parent::setUp(); // TODO: Change the autogenerated stub
  14. $this->service=app(StoreService::class);
  15. $data1=[
  16. 'asn_code' => 'ASN2010210111',
  17. 'warehouse_id' =>2,
  18. 'owner_id' => 2,
  19. 'stored_method' =>'退货入库',
  20. 'status' =>'完全收货',
  21. 'remark' => 'test',
  22. 'created_at'=>'2020-11-06 14:32:00',
  23. 'updated_at'=>'2020-11-06 14:32:00',
  24. ];
  25. array_push($this->params,$data1);
  26. $data2=[
  27. 'asn_code' => 'ASN2010210222',
  28. 'warehouse_id' =>2,
  29. 'owner_id' => 2,
  30. 'stored_method' =>'退货入库',
  31. 'status' =>'完全收货',
  32. 'remark' => 'test',
  33. 'created_at'=>'2020-11-06 14:32:00',
  34. 'updated_at'=>'2020-11-06 14:32:00',
  35. ];
  36. array_push($this->params,$data2);
  37. }
  38. public function testInsertStore(){
  39. $stores=$this->service->insertStore($this->params);
  40. $this->assertNotEmpty($stores);
  41. $this->assertDatabaseHas('stores',$this->params[0]);
  42. }
  43. public function tearDown(): void
  44. {
  45. DB::table('stores')->whereIn('asn_code',data_get($this->params,'*.asn_code'))->delete();
  46. parent::tearDown(); // TODO: Change the autogenerated stub
  47. }
  48. }