GetParamByOrderHeaderTest.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace Tests\Services\OrderService\GetParamByOrderHeaderTest;
  3. use App\Commodity;
  4. use App\Logistic;
  5. use App\OracleBasCode;
  6. use App\OracleDOCOrderHeader;
  7. use App\Order;
  8. use App\Owner;
  9. use App\Services\LogisticService;
  10. use App\Services\OracleDOCOrderHeaderService;
  11. use App\Services\OrderIssueService;
  12. use App\Services\OrderService;
  13. use App\Services\OwnerService;
  14. use App\Services\ShopService;
  15. use App\Services\WarehouseService;
  16. use App\Shop;
  17. use App\Warehouse;
  18. use Illuminate\Foundation\Testing\RefreshDatabase;
  19. use Illuminate\Foundation\Testing\WithFaker;
  20. use Tests\TestCase;
  21. class GetParamByOrderHeaderTest extends TestCase
  22. {
  23. use RefreshDatabase;
  24. /** @var OrderService $service */
  25. private $service;
  26. private $data = [];
  27. public function setUp(): void
  28. {
  29. parent::setUp();
  30. $this->service = app(OrderService::class);
  31. $wmsOrderHeader = factory(OracleDOCOrderHeader::class)->make([
  32. 'customerid'=>'TEST_OW','sostatus'=>99,'userdefine1'=>'TEST_CA','warehouseid'=>'WH_TEST'
  33. ]);
  34. $orderType = factory(OracleBasCode::class)->make(['code'=>'sysy', 'codeid'=>'SO_TYP', 'codename_c'=>'测试状态']);
  35. $wmsOrderHeader->setRelation('orderType',$orderType);
  36. $code_BasCode = factory(OracleBasCode::class)->make(['codeid'=>'OW','code'=>'99','descr_c'=>'订单完成']);
  37. $wmsOrderHeader->setRelation('oracleBASCode',$code_BasCode);
  38. $this->data['orderHeader'] = $wmsOrderHeader;
  39. $this->data['warehouse'] = factory(Warehouse::class)->create(['code'=>'WH_TEST']);
  40. $this->data['logistic'] = factory(Logistic::class)->create(['code'=>'TEST_CA','name'=>'测试承运商']);
  41. $this->data['owner'] = factory(Owner::class)->create(['code'=>'TEST_OW','name'=>'测试货主']);
  42. $this->data['shop'] = factory(Shop::class)->create(['owner_id'=>$this->data['owner']['id']]);
  43. $this->mock(OracleDOCOrderHeaderService::class,function($mock)use($wmsOrderHeader){
  44. $mock->shouldReceive('first')->andReturn($wmsOrderHeader);
  45. });
  46. }
  47. /**
  48. * @test
  49. */
  50. public function testGetParamByOrderHeader()
  51. {
  52. $orderHeader = $this->data['orderHeader'] ;
  53. $orderHeaders = collect([$orderHeader]);
  54. app(ShopService::class)->getByWmsOrders($orderHeaders);
  55. app(OwnerService::class)->getByWmsOrders($orderHeaders);
  56. app(LogisticService::class)->getByWmsOrders($orderHeaders);
  57. app(WarehouseService::class)->getByWmsOrders($orderHeaders);
  58. $param = $this->service->getParamByOrderHeader($orderHeader);
  59. $this->assertNotNull($param);
  60. $this->assertNotEmpty($param['code']);
  61. $this->assertNotEmpty($param['owner_id']);
  62. $this->assertNotNull($param['logistic_id']);
  63. $this->assertNotEmpty($param['consignee_name']);
  64. $this->assertNotEmpty($param['consignee_phone']);
  65. $this->assertNotEmpty($param['province']);
  66. $this->assertNotEmpty($param['city']);
  67. $this->assertNotEmpty($param['district']);
  68. $this->assertNotEmpty($param['address']);
  69. $this->assertNotEmpty($param['client_code']);
  70. $this->assertNotEmpty($param['wms_edittime']);
  71. $this->assertNotEmpty($param['wms_status']);
  72. $this->assertNotEmpty($param['updated_at']);
  73. $this->assertNotEmpty($param['created_at']);
  74. $this->assertNotEmpty($param['warehouse_id']);
  75. }
  76. public function tearDown(): void
  77. {
  78. cache()->forget("getLogisticByCode_{$this->data['logistic']['code']}");
  79. cache()->forget("getOwnerByCode_{$this->data['owner']['code']}");
  80. cache()->forget("getShopByCodeMap_{$this->data['shop']['code']}");
  81. cache()->forget("WareHouse_{$this->data['warehouse']['code']}");
  82. // $order = Order::query()->where('code',$this->data['orderHeader']['orderno'])->first();
  83. // $order->delete();
  84. $this->data['logistic']->delete();
  85. $this->data['owner']->delete();
  86. $this->data['shop']->delete();
  87. $this->data['warehouse']->delete();
  88. parent::tearDown(); // TODO: Change the autogenerated stub
  89. }
  90. }