SetAsnSyncAtTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Tests\Services\StoreService;
  3. use App\Services\OrderService;
  4. use App\Services\StoreService;
  5. use App\ValueStore;
  6. use Carbon\Carbon;
  7. use Illuminate\Foundation\Testing\RefreshDatabase;
  8. use Illuminate\Foundation\Testing\WithFaker;
  9. use Illuminate\Support\Str;
  10. use Tests\TestCase;
  11. class SetAsnSyncAtTest extends TestCase
  12. {
  13. /** @var StoreService $service */
  14. private $service;
  15. private $created_at;
  16. private $original_value;
  17. public function setUp(): void
  18. {
  19. parent::setUp(); // TODO: Change the autogenerated stub
  20. $this->service = app(StoreService::class);
  21. $this->created_at = config('sync.asn_sync.created_at');
  22. }
  23. /**
  24. * @test
  25. */
  26. public function testSetAsnSyncAt()
  27. {
  28. /** @var Carbon $time */
  29. $data = Carbon::now();
  30. $this->original_value=ValueStore::query()->where('name',$this->created_at)->value('value');
  31. $this->service->setAsnLastSyncAt($this->created_at,$data);
  32. $value=ValueStore::query()->where('name',$this->created_at)->value('value');
  33. $this->assertEquals((string)$data,(string)$value);
  34. }
  35. public function tearDown(): void
  36. {
  37. ValueStore::query()->updateOrCreate([
  38. 'name' => $this->created_at,
  39. ], [
  40. 'name' => $this->created_at,
  41. 'value' => $this->original_value,
  42. ]);
  43. parent::tearDown(); // TODO: Change the autogenerated stub
  44. }
  45. }