|
@@ 82-97 (lines=16) @@
|
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/** @test */ |
| 82 |
|
public function it_can_set_a_new_order_with_trashed_models() |
| 83 |
|
{ |
| 84 |
|
$this->setUpSoftDeletes(); |
| 85 |
|
|
| 86 |
|
$dummies = DummyWithSoftDeletes::all(); |
| 87 |
|
|
| 88 |
|
$dummies->random()->delete(); |
| 89 |
|
|
| 90 |
|
$newOrder = Collection::make($dummies->pluck('id'))->shuffle(); |
| 91 |
|
|
| 92 |
|
DummyWithSoftDeletes::setNewOrder($newOrder); |
| 93 |
|
|
| 94 |
|
foreach (DummyWithSoftDeletes::withTrashed()->orderBy('order_column')->get() as $i => $dummy) { |
| 95 |
|
$this->assertEquals($newOrder[$i], $dummy->id); |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
/** @test */ |
| 100 |
|
public function it_can_set_a_new_order_by_custom_column_with_trashed_models() |
|
@@ 100-115 (lines=16) @@
|
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
/** @test */ |
| 100 |
|
public function it_can_set_a_new_order_by_custom_column_with_trashed_models() |
| 101 |
|
{ |
| 102 |
|
$this->setUpSoftDeletes(); |
| 103 |
|
|
| 104 |
|
$dummies = DummyWithSoftDeletes::all(); |
| 105 |
|
|
| 106 |
|
$dummies->random()->delete(); |
| 107 |
|
|
| 108 |
|
$newOrder = Collection::make($dummies->pluck('custom_column_sort'))->shuffle(); |
| 109 |
|
|
| 110 |
|
DummyWithSoftDeletes::setNewOrderByCustomColumn('custom_column_sort', $newOrder); |
| 111 |
|
|
| 112 |
|
foreach (DummyWithSoftDeletes::withTrashed()->orderBy('order_column')->get() as $i => $dummy) { |
| 113 |
|
$this->assertEquals($newOrder[$i], $dummy->custom_column_sort); |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
/** @test */ |
| 118 |
|
public function it_can_set_a_new_order_without_trashed_models() |