FindByParamsTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Tests\CacheService\LogisticTimingService\FindByParamsTest;
  3. use App\City;
  4. use App\Logistic;
  5. use App\Province;
  6. use App\Services\LogisticTimingService;
  7. use Illuminate\Foundation\Testing\RefreshDatabase;
  8. use Tests\TestCase;
  9. class FindByParamsTest extends TestCase
  10. {
  11. /**
  12. * @var LogisticTimingService $logisticTimingService
  13. */
  14. public $logisticTimingService;
  15. public function setUp(): void
  16. {
  17. parent::setUp();
  18. $this->logisticTimingService = app(LogisticTimingService::class);
  19. factory(Logistic::class)->create(['name'=>'新杰物流','code'=>'XJWL']);
  20. $province = null;
  21. if(!Province::query()->where('name','like','江苏')->exists())
  22. $province = factory(Province::class)->create(['name'=>'江苏']);
  23. else
  24. $province = Province::query()->where('name','like','江苏')->first();
  25. if(!city::query()->where('name','like','南京'))
  26. factory(City::class)->create(['name'=>'南京', 'province_id'=>$province->id]);
  27. }
  28. /**
  29. * @test
  30. */
  31. public function findByParams()
  32. {
  33. $cityName = '江苏省';
  34. $provinceName = '南京市';
  35. $logistic = Logistic::query()->where('name','like','新杰物流'.'%')->first();
  36. $result = $this->logisticTimingService->findByParams($cityName,$provinceName,$logistic->id);
  37. $this->assertNull($result);
  38. }
  39. }