X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a65701294eaad4aad5ba5d9e249cbfb774ee6ca6..c54101c603a3e8e06c372de673a811d41a1f1f9d:/tests/Sorting/BookSortTest.php diff --git a/tests/Sorting/BookSortTest.php b/tests/Sorting/BookSortTest.php index a726da148..4737ec231 100644 --- a/tests/Sorting/BookSortTest.php +++ b/tests/Sorting/BookSortTest.php @@ -1,11 +1,11 @@ entities->bookHasChaptersAndPages(); + $chapter = $book->chapters()->first(); + \DB::table('chapters')->where('id', '=', $chapter->id)->update([ + 'priority' => 10001, + 'updated_at' => \Carbon\Carbon::now()->subYear(5), + ]); + + $chapter->refresh(); + $oldUpdatedAt = $chapter->updated_at->unix(); + + $sortData = [ + 'id' => $chapter->id, + 'sort' => 0, + 'parentChapter' => false, + 'type' => 'chapter', + 'book' => $book->id, + ]; + $this->asEditor()->put($book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect(); + + $chapter->refresh(); + $this->assertNotEquals(10001, $chapter->priority); + $this->assertEquals($oldUpdatedAt, $chapter->updated_at->unix()); + } + public function test_book_sort_item_returns_book_content() { $bookToSort = $this->entities->book(); @@ -223,13 +249,13 @@ class BookSortTest extends TestCase public function test_book_sort_item_shows_auto_sort_status() { - $sort = SortSet::factory()->create(['name' => 'My sort']); + $sort = SortRule::factory()->create(['name' => 'My sort']); $book = $this->entities->book(); $resp = $this->asAdmin()->get($book->getUrl('/sort-item')); $this->withHtml($resp)->assertElementNotExists("span[title='Auto Sort Active: My sort']"); - $book->sort_set_id = $sort->id; + $book->sort_rule_id = $sort->id; $book->save(); $resp = $this->asAdmin()->get($book->getUrl('/sort-item')); @@ -238,7 +264,7 @@ class BookSortTest extends TestCase public function test_auto_sort_options_shown_on_sort_page() { - $sort = SortSet::factory()->create(); + $sort = SortRule::factory()->create(); $book = $this->entities->book(); $resp = $this->asAdmin()->get($book->getUrl('/sort')); @@ -247,7 +273,7 @@ class BookSortTest extends TestCase public function test_auto_sort_option_submit_saves_to_book() { - $sort = SortSet::factory()->create(); + $sort = SortRule::factory()->create(); $book = $this->entities->book(); $bookPage = $book->pages()->first(); $bookPage->priority = 10000; @@ -261,7 +287,7 @@ class BookSortTest extends TestCase $book->refresh(); $bookPage->refresh(); - $this->assertEquals($sort->id, $book->sort_set_id); + $this->assertEquals($sort->id, $book->sort_rule_id); $this->assertNotEquals(10000, $bookPage->priority); $resp = $this->get($book->getUrl('/sort'));