| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace Tests\Services\StoreService;
- use App\OracleDOCASNHeader;
- use App\Services\StoreService;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\DB;
- use Tests\TestCase;
- class UpdateStoreTest extends TestCase
- {
- /** @var StoreService $service */
- public $service;
- public $asnHeaders;
- public $stores;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $startDate = \Illuminate\Support\Carbon::now()->subSeconds(300);
- $this->service=app(StoreService::class);
- $this->asnHeaders=OracleDOCASNHeader::query()
- ->with(['asnType', 'asnStatus', 'asnDetails' => function ($query) {
- $query->with(['lineStatus', 'qualityStatus','basSku']);
- }])
- ->where('EditTime', '>=', $startDate)
- ->whereColumn('EditTime', '<>', 'addTime')
- ->get();
- }
- public function testUpdateStore(){
- if (!$this->asnHeaders) {
- $this->assertNull($this->asnHeaders);
- }else{
- $this->service->updateStore($this->asnHeaders);
- $this->stores=$this->service->getByWms($this->asnHeaders);
- $this->assertNotEmpty($this->stores);
- }
- }
- public function tearDown(): void
- {
- $storeIds=[];
- foreach ($this->stores as $store){
- array_push($storeIds,$store->id);
- }
- DB::table('stores')->whereIn('asn_code',data_get($this->asnHeaders,'*.asnno'))->delete();
- DB::table('store_items')->whereIn('store_id',$storeIds)->delete();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|