InsertStoreTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. $this->service->insertStore($this->params);
  40. $this->assertDatabaseHas('stores',$this->params[0]);
  41. }
  42. public function tearDown(): void
  43. {
  44. DB::table('stores')->whereIn('asn_code',data_get($this->params,'*.asn_code'))->delete();
  45. parent::tearDown(); // TODO: Change the autogenerated stub
  46. }
  47. }