$query->select('id')->from('pages')
->whereColumn('pages.id', '=', $fullPageIdColumn)
->where('pages.draft', '=', false);
+ })->orWhereExists(function (QueryBuilder $query) use ($fullPageIdColumn) {
+ $query->select('id')->from('pages')
+ ->whereColumn('pages.id', '=', $fullPageIdColumn)
+ ->where('pages.draft', '=', true)
+ ->where('pages.created_by', '=', $this->currentUser()->id);
});
});
}
return $pageRepo->publishDraft($draftPage, $input);
}
+ /**
+ * Create and return a new test draft page.
+ */
+ public function newDraftPage(array $input = ['name' => 'test page', 'html' => 'My new test page']): Page
+ {
+ $book = $this->book();
+ $pageRepo = app(PageRepo::class);
+ $draftPage = $pageRepo->getNewDraftPage($book);
+ $pageRepo->updatePageDraft($draftPage, $input);
+ $this->addToCache($draftPage);
+ return $draftPage;
+ }
+
/**
* @param Entity|Entity[] $entities
*/
$this->withHtml($searchFailRequest)->assertElementNotExists('div');
}
+ public function test_image_gallery_lists_for_draft_page()
+ {
+ $this->actingAs($this->users->editor());
+ $draft = $this->entities->newDraftPage();
+ $this->files->uploadGalleryImageToPage($this, $draft);
+ $image = Image::query()->where('uploaded_to', '=', $draft->id)->firstOrFail();
+
+ $resp = $this->get("/images/gallery?page=1&uploaded_to={$draft->id}");
+ $resp->assertSee($image->getThumb(150, 150));
+ }
+
public function test_image_usage()
{
$page = $this->entities->page();