GetShopByCodeMapTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Tests\Services\ShopService;
  3. use App\OracleDOCOrderHeader;
  4. use App\Owner;
  5. use App\Services\OwnerService;
  6. use App\Services\ShopService;
  7. use Carbon\Carbon;
  8. use Illuminate\Foundation\Testing\RefreshDatabase;
  9. use Illuminate\Foundation\Testing\WithFaker;
  10. use Tests\TestCase;
  11. class GetShopByCodeMapTest extends TestCase
  12. {
  13. use RefreshDatabase;
  14. /** @var OwnerService $service */
  15. private $service;
  16. private $data;
  17. public function setUp(): void
  18. {
  19. parent::setUp(); // TODO: Change the autogenerated stub
  20. $this->service = app('ShopService');
  21. $this->data = [];
  22. $orderHeader = OracleDOCOrderHeader::query()
  23. ->whereNotNull('issuepartyname')
  24. ->where('sostatus','99')
  25. ->orderByDesc('AddTime')
  26. ->first();
  27. $this->data['orderHeader'] = $orderHeader;
  28. $this->data['map'][] = [
  29. 'owner_code' => $orderHeader['customerid'],
  30. 'issuepartyname' => $orderHeader['issuepartyname']
  31. ];
  32. }
  33. /**
  34. * @test
  35. */
  36. public function getShopByCodeMap()
  37. {
  38. $shop = $this->service->getShopByCodeMap($this->data['map']);
  39. $this->assertNotNull($shop);
  40. $orderHeader = $this->data['orderHeader'];
  41. $owner = Owner::find($shop->first()->owner_id);
  42. $this->assertEquals($owner->code,$orderHeader['customerid']);
  43. $this->assertEquals($shop->first()->name,$orderHeader['issuepartyname']);
  44. }
  45. public function tearDown(): void
  46. {
  47. cache()->flush();
  48. parent::tearDown(); // TODO: Change the autogenerated stub
  49. }
  50. }