Skip to content

Commit

Permalink
delete and insert
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed May 11, 2022
1 parent 56f9dff commit 457f78f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/admin/traits/SortableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ public function testSorting()
// ensures the sort index title = 3 is the last item, which is now since jane has swap to first position James
$q = UserStub::find()->asArray()->all();
$this->assertSame('James', $q[2]['firstname']);

// delete the model
$modelLast->delete();

// add new item
$newModel = new UserStub();
$newModel->title = 20;
$newModel->firstname = 'Han';
$newModel->lastname = 'Solo';
$newModel->email = 'hansolo@luya.io';
$newModel->password = 'doesnotexis434!@Aasdfts';
$newModel->is_deleted = false;
$this->assertTrue($newModel->save());

$newModel->refresh();

// the index has changed by the sortable plugin, even we have entered 20 as value
// since we have deleted an item, the index has now 3 entries and not 4
$this->assertSame('3', $newModel->title);
}
}

Expand Down

0 comments on commit 457f78f

Please sign in to comment.