| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?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
- {
- /** @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 = 'renewal_list->test';
- $this->hasKey = 'renewal_has->test';
- $this->prefixKey = 'renewal->test';
- }
- /**
- * @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
- {
- foreach ($this->data['OrderHeader'] as $datum) {
- Cache::forget($this->prefixKey.$datum->orderno);
- }
- Cache::forget($this->renewal_list);
- Cache::forget($this->hasKey);
- parent::tearDown(); // TODO: Change the autogenerated stub
- }
- }
|