GetParamByOrderHeaderTest.php 4.0 KB

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