UpdateStoreTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Tests\Services\StoreService;
  3. use App\OracleDOCASNHeader;
  4. use App\Services\StoreService;
  5. use Carbon\Carbon;
  6. use Illuminate\Support\Facades\DB;
  7. use Tests\TestCase;
  8. class UpdateStoreTest extends TestCase
  9. {
  10. /** @var StoreService $service */
  11. public $service;
  12. public $asnHeaders;
  13. public $stores;
  14. public function setUp(): void
  15. {
  16. parent::setUp(); // TODO: Change the autogenerated stub
  17. $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
  18. $this->service=app(StoreService::class);
  19. $this->asnHeaders=OracleDOCASNHeader::query()
  20. ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
  21. $query->with(['lineStatus', 'qualityStatus','basSku']);
  22. }])
  23. ->where('EditTime', '>=', $startDate)
  24. ->whereColumn('EditTime', '<>', 'addTime')
  25. ->get();
  26. }
  27. public function testUpdateStore(){
  28. if (!$this->asnHeaders) {
  29. $this->assertNull($this->asnHeaders);
  30. }else{
  31. $this->service->updateStore($this->asnHeaders);
  32. $this->stores=$this->service->getByWms($this->asnHeaders);
  33. $this->assertNotNull($this->stores);
  34. }
  35. }
  36. public function tearDown(): void
  37. {
  38. $storeIds=[];
  39. foreach ($this->stores as $store){
  40. array_push($storeIds,$store->id);
  41. }
  42. DB::table('stores')->whereIn('asn_code',data_get($this->asnHeaders,'*.asnno'))->delete();
  43. DB::table('store_items')->whereIn('store_id',$storeIds)->delete();
  44. cache()->flush();
  45. parent::tearDown(); // TODO: Change the autogenerated stub
  46. }
  47. }