RecordReportTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace Tests\Services\OwnerLogisticFeeReportService;
  3. use App\OwnerLogisticFeeDetail;
  4. use App\Services\OwnerLogisticFeeReportService;
  5. use Tests\TestCase;
  6. use App\OwnerLogisticFeeReport;
  7. use App\Traits\TestMockSubServices;
  8. class RecordReportTest extends TestCase
  9. {
  10. use TestMockSubServices;
  11. /** @var OwnerLogisticFeeReportService $service */
  12. public $service;
  13. private $data;
  14. private $amount = 2;
  15. function setUp(): void
  16. {
  17. parent::setUp();
  18. $this->service = app('OwnerLogisticFeeReportService');
  19. // $this->data['OwnerLogisticFeeDetail']
  20. // = factory(\App\OwnerLogisticFeeDetail::class, $this->amount)
  21. // ->create([
  22. // 'created_at' => now()->subMonth()->startOfMonth()->addDays(1),
  23. // 'province' => '北京',
  24. // 'initial_weight_price' => '20',
  25. // 'additional_price' => '20',
  26. // 'logistic_id' => '20',
  27. // ]);
  28. }
  29. public function testReturned()
  30. {
  31. $this->assertTrue(true);
  32. }
  33. function tearDown(): void
  34. {
  35. // OwnerLogisticFeeDetail::query()
  36. // ->whereIn('id', data_get($this->data['OwnerLogisticFeeDetail'], '*.id') ?? [])
  37. // ->delete();
  38. parent::tearDown();
  39. }
  40. /**
  41. * @test
  42. */
  43. public function get_test()
  44. {
  45. OwnerLogisticFeeDetail::query()->truncate();
  46. OwnerLogisticFeeReport::query()->truncate();
  47. factory(OwnerLogisticFeeDetail::class)->create([
  48. 'created_at' => now()->subMonth(),
  49. 'updated_at' => now()->subMonth(),
  50. 'province' => '北京',
  51. 'initial_weight' => '10',
  52. 'initial_weight_price' => '10',
  53. 'additional_price' => '10',
  54. 'additional_weight' => '10',
  55. 'logistic_id' => '1',
  56. 'owner_id' => '1',
  57. 'additional_weigh_weight' => '1',
  58. ]);
  59. factory(OwnerLogisticFeeDetail::class)->create([
  60. 'created_at' => now()->subMonth(),
  61. 'updated_at' => now()->subMonth(),
  62. 'province' => '北京',
  63. 'initial_weight' => '10',
  64. 'initial_weight_price' => '10',
  65. 'additional_price' => '10',
  66. 'additional_weight' => '10',
  67. 'logistic_id' => '1',
  68. 'owner_id' => '1',
  69. 'additional_weigh_weight' => '1',
  70. ]);
  71. $this->service->recordReport();
  72. $this->assertDatabaseHas('owner_logistic_fee_reports', [
  73. 'logistic_id' => '1',
  74. 'province' => '北京',
  75. 'counted_date' => now()->subMonth()->startOfMonth()->toDateString(),
  76. 'initial_weight' => '10',
  77. 'initial_weight_price' => '10',
  78. 'initial_amount' => '2',
  79. 'additional_weight' => '10',
  80. 'additional_price' => '10',
  81. 'additional_amount' => '2',
  82. 'fee' => '40',
  83. 'owner_id' => '1',
  84. ]);
  85. }
  86. }