CreateBarcodeByWmsTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Tests\Services\CommodityBarcodeService;
  3. use App\OracleBasSKU;
  4. use App\Services\CommodityBarcodeService;
  5. use App\ValueStore;
  6. use Tests\TestCase;
  7. class CreateBarcodeByWmsTest extends TestCase
  8. {
  9. /**
  10. * @var CommodityBarcodeService $service
  11. */
  12. public $service;
  13. public $bas_skus;
  14. public $created_at;
  15. public $commodityBarcodes;
  16. public function setUp(): void
  17. {
  18. parent::setUp(); // TODO: Change the autogenerated stub
  19. $this->created_at = config('sync.commodity_sync.created_at');
  20. $last_time = ValueStore::query()->where('name', $this->created_at)->value('value');
  21. $startDate = \Illuminate\Support\Carbon::now()->subSeconds(65);
  22. $this->service = app(CommodityBarcodeService::class);
  23. $this->bas_skus = OracleBasSKU::query()
  24. ->select('customerid', 'sku', 'descr_c', 'alternate_sku1', 'alternate_sku2', 'alternate_sku3', 'skulength', 'skuwidth', 'skuhigh', 'cube', 'packid', 'addtime', 'edittime')
  25. ->where('addTime', '>=', $last_time ?? $startDate)
  26. ->orderByDesc('addtime')
  27. ->get();
  28. }
  29. public function testCreateBarcodeByWms()
  30. {
  31. if ($this->bas_skus->isEmpty()) {
  32. $this->assertEmpty($this->bas_skus);
  33. return;
  34. }
  35. $this->service->createBarcodeByWms($this->bas_skus);
  36. $this->commodityBarcodes=$this->service->getByWms($this->bas_skus);
  37. if ($this->commodityBarcodes) $this->assertNotNull($this->commodityBarcodes);
  38. }
  39. public function tearDown(): void
  40. {
  41. parent::tearDown(); // TODO: Change the autogenerated stub
  42. }
  43. }