| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace Tests\Services\StoreService;
- use App\OracleDOCASNHeader;
- use App\Services\StoreService;
- use Carbon\Carbon;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Support\Facades\DB;
- use Tests\TestCase;
- class CreateStoreTest extends TestCase
- {
- // use RefreshDatabase;
- /** @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('addTime', '>=', $startDate)
- ->get();
- }
- public function testCreateStore(){
- if (!$this->asnHeaders) return null;
- $this->service->createStore($this->asnHeaders);
- $this->stores=$this->service->getByWms($this->asnHeaders);
- $this->assertNotnull($this->stores);
- $this->assertNotNull($this->asnHeaders);
- }
- 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();
- cache()->flush();
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|