GetShopByCodeMapTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /** @var OwnerService $service */
  14. private $service;
  15. private $data;
  16. public function setUp(): void
  17. {
  18. parent::setUp(); // TODO: Change the autogenerated stub
  19. $this->service = app('ShopService');
  20. $this->data = [];
  21. $orderHeader = OracleDOCOrderHeader::query()
  22. ->whereNotNull('issuepartyname')
  23. ->where('sostatus','99')
  24. ->orderByDesc('AddTime')
  25. ->first();
  26. $this->data['orderHeader'] = $orderHeader;
  27. $this->data['map'][] = [
  28. 'owner_code' => $orderHeader['customerid'],
  29. 'issuepartyname' => $orderHeader['issuepartyname']
  30. ];
  31. }
  32. /**
  33. * @test
  34. */
  35. public function getShopByCodeMap()
  36. {
  37. $shop = $this->service->getShopByCodeMap($this->data['map']);
  38. $this->assertNotNull($shop);
  39. $orderHeader = $this->data['orderHeader'];
  40. $owner = Owner::find($shop->first()->owner_id);
  41. $this->assertEquals($owner->code,$orderHeader['customerid']);
  42. $this->assertEquals($shop->first()->name,$orderHeader['issuepartyname']);
  43. }
  44. public function tearDown(): void
  45. {
  46. parent::tearDown(); // TODO: Change the autogenerated stub
  47. }
  48. }