| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace Tests\Services\OrderService\GetParamByOrderHeaderTest;
- use App\Commodity;
- use App\Logistic;
- use App\OracleBasCode;
- use App\OracleDOCOrderHeader;
- use App\Order;
- use App\Owner;
- use App\Services\LogisticService;
- use App\Services\OracleDOCOrderHeaderService;
- use App\Services\OrderIssueService;
- use App\Services\OrderService;
- use App\Services\OwnerService;
- use App\Services\ShopService;
- use App\Services\WarehouseService;
- use App\Shop;
- use App\Warehouse;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Illuminate\Support\Facades\DB;
- use Tests\TestCase;
- class GetParamByOrderHeaderTest extends TestCase
- {
- /** @var OrderService $service */
- private $service;
- private $data = [];
- public function setUp(): void
- {
- parent::setUp();
- $this->service = app(OrderService::class);
- // $this->data['owner'] = factory(Owner::class)->create(['name'=>'测试货主']);
- $wmsOrderHeader = factory(OracleDOCOrderHeader::class)->make([
- 'customerid'=>'TEST_OW','sostatus'=>99,'userdefine1'=>'TEST_CA','warehouseid'=>'WH_TEST'
- ]);
- $orderType = factory(OracleBasCode::class)->make(['code'=>'sysy', 'codeid'=>'SO_TYP', 'codename_c'=>'测试状态']);
- $wmsOrderHeader->setRelation('orderType',$orderType);
- $code_BasCode = factory(OracleBasCode::class)->make(['codeid'=>'OW','code'=>'99','descr_c'=>'订单完成']);
- $wmsOrderHeader->setRelation('oracleBASCode',$code_BasCode);
- $this->data['orderHeader'] = $wmsOrderHeader;
- DB::insert('insert ignore into warehouses (code) values(?)',['WH_TEST']);
- $this->data['warehouse'] = Warehouse::query()->where('code','WH_TEST')->first();
- DB::insert('insert ignore into logistics (code,name) values(?,?)',['TEST_CA','测试承运商']);
- $this->data['logistic'] = Logistic::query()->where('code','TEST_CA')->where('name','测试承运商')->first();
- // $this->data['owner'] = factory(Owner::class)->create(['code'=>'TEST_OW','name'=>'测试货主']);
- DB::insert('insert ignore into owners (code,name) values(?,?)',['TEST_OW','测试货主']);
- $this->data['owner'] = Owner::query()->where('code','TEST_OW')->where('name','测试货主')->first();
- $this->data['shop'] = factory(Shop::class)->create(['owner_id'=>$this->data['owner']['id']]);
- $this->mock(OracleDOCOrderHeaderService::class,function($mock)use($wmsOrderHeader){
- $mock->shouldReceive('first')->andReturn($wmsOrderHeader);
- });
- }
- /**
- * @test
- */
- public function testGetParamByOrderHeader()
- {
- $orderHeader = $this->data['orderHeader'] ;
- $orderHeaders = collect([$orderHeader]);
- app(ShopService::class)->getByWmsOrders($orderHeaders);
- app(OwnerService::class)->getByWmsOrders($orderHeaders);
- app(LogisticService::class)->getByWmsOrders($orderHeaders);
- app(WarehouseService::class)->getByWmsOrders($orderHeaders);
- $param = $this->service->getParamByOrderHeader($orderHeader);
- $this->assertNotNull($param);
- $this->assertNotEmpty($param['code']);
- $this->assertNotEmpty($param['owner_id']);
- $this->assertNotNull($param['logistic_id']);
- // $this->assertNotEmpty($param['consignee_name']);
- // $this->assertNotEmpty($param['consignee_phone']);
- // $this->assertNotEmpty($param['province']);
- // $this->assertNotEmpty($param['city']);
- // $this->assertNotEmpty($param['district']);
- // $this->assertNotEmpty($param['address']);
- // $this->assertNotEmpty($param['client_code']);
- $this->assertNotEmpty($param['wms_edittime']);
- $this->assertNotEmpty($param['wms_status']);
- $this->assertNotEmpty($param['updated_at']);
- $this->assertNotEmpty($param['created_at']);
- $this->assertNotEmpty($param['warehouse_id']);
- }
- public function tearDown(): void
- {
- cache()->forget("getLogisticByCode_{$this->data['logistic']['code']}");
- cache()->forget("getOwnerByCode_{$this->data['owner']['code']}");
- cache()->forget("getShopByCodeMap_{$this->data['shop']['code']}");
- cache()->forget("WareHouse_{$this->data['warehouse']['code']}");
- // $order = Order::query()->where('code',$this->data['orderHeader']['orderno'])->first();
- // $order->delete();
- Shop::query()->where('owner_id',$this->data['owner']['id'])->delete();
- Logistic::query()->where('code','TEST_CA')->where('name','测试承运商')->forceDelete();
- Owner::query()->where('name','测试货主')->delete();
- Warehouse::query()->where('code','WH_TEST')->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|