Skip to content

Commit

Permalink
test it can set order without touching timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
mokhosh committed Jan 20, 2024
1 parent 70e6b24 commit 11c7b49
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/SortableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ public function it_can_touch_timestamps_when_setting_a_new_order()
}
}

/** @test */
public function it_can_set_a_new_order_without_touching_timestamps()
{
$this->setUpTimestamps();
DummyWithTimestamps::query()->update(['updated_at' => now()]);
$originalTimestamps = DummyWithTimestamps::all()->pluck('updated_at');

$this->travelTo(now()->addMinute());

config()->set('eloquent-sortable.ignore_timestamps', true);
$newOrder = Collection::make(DummyWithTimestamps::all()->pluck('id'))->shuffle()->toArray();
DummyWithTimestamps::setNewOrder($newOrder);

foreach (DummyWithTimestamps::orderBy('order_column')->get() as $i => $dummy) {
$this->assertEquals($originalTimestamps[$i], $dummy->updated_at);
}
}

/** @test */
public function it_can_set_a_new_order_by_custom_column()
{
Expand Down

0 comments on commit 11c7b49

Please sign in to comment.