|
|
@@ -14,10 +14,13 @@ use Tests\TestCase;
|
|
|
|
|
|
class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
{
|
|
|
- use RefreshDatabase;
|
|
|
-
|
|
|
protected $newOrderCountingRecordService;
|
|
|
|
|
|
+ protected $orders;
|
|
|
+ protected $orderCountingRecords;
|
|
|
+ protected $owners;
|
|
|
+
|
|
|
+
|
|
|
protected function setUp(): void
|
|
|
{
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub
|
|
|
@@ -30,9 +33,17 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
protected function tearDown(): void
|
|
|
{
|
|
|
cache()->flush();
|
|
|
- OrderCountingRecord::truncate();
|
|
|
- Order::truncate();
|
|
|
- Owner::truncate();
|
|
|
+ foreach ($this->orders as $order) {
|
|
|
+ $order->delete();
|
|
|
+ }
|
|
|
+ foreach ($this->orderCountingRecords as $orderCountingRecord) {
|
|
|
+ $orderCountingRecord->delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($this->owners as $owner) {
|
|
|
+ $owner->delete();
|
|
|
+ }
|
|
|
+
|
|
|
parent::tearDown(); // TODO: Change the autogenerated stub
|
|
|
}
|
|
|
|
|
|
@@ -41,7 +52,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
*/
|
|
|
public function transfersToConditions()
|
|
|
{
|
|
|
- factory(Owner::class)->times(2)->create();
|
|
|
+ $this->owners = factory(Owner::class)->times(2)->create();
|
|
|
$start = Carbon::now()->subDays(2)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
$unit = '日';
|
|
|
@@ -59,7 +70,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
*/
|
|
|
public function dateUtils_week()
|
|
|
{
|
|
|
- factory(Owner::class)->times(2)->create();
|
|
|
+ $this->owners = factory(Owner::class)->times(2)->create();
|
|
|
$start = Carbon::now()->subWeeks(2)->toDateString();
|
|
|
$end = Carbon::now()->toDateString();
|
|
|
$unit = '周';
|
|
|
@@ -288,7 +299,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
$owner1 = factory(Owner::class)->create();
|
|
|
$owner2 = factory(Owner::class)->create();
|
|
|
|
|
|
- $unQueryCondition = $this->newOrderCountingRecordService->transfersToCondition($start, $end, $unit,$this->newOrderCountingRecordService->getCountingOwnerIds());
|
|
|
+ $unQueryCondition = $this->newOrderCountingRecordService->transfersToCondition($start, $end, $unit, $this->newOrderCountingRecordService->getCountingOwnerIds());
|
|
|
|
|
|
factory(Order::class)->times(1)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now(), 'owner_id' => $owner1->id]);
|
|
|
factory(Order::class)->times(2)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now(), 'owner_id' => $owner2->id]);
|
|
|
@@ -324,7 +335,7 @@ class NewOrderCountingRecordServiceTest extends TestCase
|
|
|
|
|
|
factory(Order::class)->times(3)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner1->id]);
|
|
|
factory(Order::class)->times(4)->create(['wms_status' => '订单完成', 'created_at' => Carbon::now()->subDays(1), 'owner_id' => $owner2->id]);
|
|
|
- $unQueryCondition = $this->newOrderCountingRecordService->transfersToCondition($start, $end, $unit,$this->newOrderCountingRecordService->getCountingOwnerIds());
|
|
|
+ $unQueryCondition = $this->newOrderCountingRecordService->transfersToCondition($start, $end, $unit, $this->newOrderCountingRecordService->getCountingOwnerIds());
|
|
|
|
|
|
$result = $this->newOrderCountingRecordService->getOrderCountingRecords($unQueryCondition, $unit);
|
|
|
$this->assertEquals(3, $result->where('date_target', Carbon::now()->toDateString())->reduce(function ($carry, $item) {
|