| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Tests\Services\OrderService;
- use App\OracleDOCOrderHeader;
- use App\Services\OrderService;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Str;
- use Tests\TestCase;
- class PushOrderUpdateCacheTest extends TestCase
- {
- use RefreshDatabase;
- /** @var OrderService $service */
- public $service;
- public $data;
- private $renewal_list;
- private $hasKey;
- private $prefixKey;
- public function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->service = app('OrderService');
- $arr = [Str::uuid(),Str::uuid(),Str::uuid(),Str::uuid(),Str::uuid()];
- $list = [];
- foreach ($arr as $item) {
- $orderHeader= new OracleDOCOrderHeader();
- $orderHeader->orderno = (string)$item;
- $list[] = $orderHeader;
- }
- $this->data['OrderHeader'] = $list;
- $this->renewal_list = config('sync.order_sync.cache_prefix.renewal_list');
- $this->hasKey = config('sync.order_sync.cache_prefix.renewal_has');
- $this->prefixKey = config('sync.order_sync.cache_prefix.renewal');
- }
- /**
- * @test
- */
- public function pushOrderUpdateCache()
- {
- $this->service->pushOrderCache($this->data['OrderHeader'],$this->prefixKey,$this->hasKey,$this->renewal_list);
- try {
- Cache::get($this->hasKey);
- $this->assertNotNull(Cache::get($this->hasKey));
- foreach ($this->data['OrderHeader'] as $datum) {
- $this->assertNotEmpty(Cache::get($this->prefixKey.$datum->orderno));
- }
- $this->assertNotNull($this->data['OrderHeader']);
- } catch (\Exception $e) {
- $this->assertNotNull($e);
- }
- }
- public function tearDown(): void
- {
- try {
- Cache::forget($this->renewal_list);
- Cache::forget($this->hasKey);
- foreach ($this->data['OrderHeader'] as $item) {
- Cache::forget($this->prefixKey . $item->orderno);
- }
- } catch (\Exception $e) {
- }
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|