-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
$resp->assertSee('Move Page');
$movePageResp = $this->put($page->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$page = Page::find($page->id);
$newChapter = $newBook->chapters()->first();
$movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
- 'entity_selection' => 'chapter:' . $newChapter->id
+ 'entity_selection' => 'chapter:' . $newChapter->id,
]);
$page = Page::find($page->id);
$newBook = Book::where('id', '!=', $oldChapter->book_id)->first();
$movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$page->refresh();
$this->setEntityRestrictions($newBook, ['view', 'update', 'delete'], $editor->roles->all());
$movePageResp = $this->actingAs($editor)->put($page->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$this->assertPermissionError($movePageResp);
$this->setEntityRestrictions($newBook, ['view', 'update', 'delete', 'create'], $editor->roles->all());
$movePageResp = $this->put($page->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$page = Page::find($page->id);
$this->setEntityRestrictions($page, ['view', 'update', 'create'], $editor->roles->all());
$movePageResp = $this->actingAs($editor)->put($page->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$this->assertPermissionError($movePageResp);
$pageView = $this->get($page->getUrl());
$this->setEntityRestrictions($page, ['view', 'update', 'create', 'delete'], $editor->roles->all());
$movePageResp = $this->put($page->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$page = Page::find($page->id);
$chapterMoveResp->assertSee('Move Chapter');
$moveChapterResp = $this->put($chapter->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$chapter = Chapter::find($chapter->id);
$this->setEntityRestrictions($chapter, ['view', 'update', 'create'], $editor->roles->all());
$moveChapterResp = $this->actingAs($editor)->put($chapter->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$this->assertPermissionError($moveChapterResp);
$pageView = $this->get($chapter->getUrl());
$this->setEntityRestrictions($chapter, ['view', 'update', 'create', 'delete'], $editor->roles->all());
$moveChapterResp = $this->put($chapter->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$chapter = Chapter::find($chapter->id);
$pageToCheck->delete();
$this->asEditor()->put($chapter->getUrl('/move'), [
- 'entity_selection' => 'book:' . $newBook->id
+ 'entity_selection' => 'book:' . $newBook->id,
]);
$pageToCheck->refresh();
// Create request data
$reqData = [
[
- 'id' => $chapterToMove->id,
- 'sort' => 0,
+ 'id' => $chapterToMove->id,
+ 'sort' => 0,
'parentChapter' => false,
- 'type' => 'chapter',
- 'book' => $newBook->id
- ]
+ 'type' => 'chapter',
+ 'book' => $newBook->id,
+ ],
];
foreach ($pagesToMove as $index => $page) {
$reqData[] = [
- 'id' => $page->id,
- 'sort' => $index,
+ 'id' => $page->id,
+ 'sort' => $index,
'parentChapter' => $index === count($pagesToMove) - 1 ? $chapterToMove->id : false,
- 'type' => 'page',
- 'book' => $newBook->id
+ 'type' => 'page',
+ 'book' => $newBook->id,
];
}
$sortResp->assertRedirect($newBook->getUrl());
$sortResp->assertStatus(302);
$this->assertDatabaseHas('chapters', [
- 'id' => $chapterToMove->id,
- 'book_id' => $newBook->id,
- 'priority' => 0
+ 'id' => $chapterToMove->id,
+ 'book_id' => $newBook->id,
+ 'priority' => 0,
]);
$this->assertTrue($newBook->chapters()->count() === 1);
$this->assertTrue($newBook->chapters()->first()->pages()->count() === 1);
$checkResp = $this->get(Page::find($checkPage->id)->getUrl());
$checkResp->assertSee($newBook->name);
}
-
-}
\ No newline at end of file
+}