+
+ protected function assertNotificationContains(\Illuminate\Testing\TestResponse $resp, string $text)
+ {
+ return $this->withHtml($resp)->assertElementContains('[notification]', $text);
+ }
+
+ /**
+ * Set a test handler as the logging interface for the application.
+ * Allows capture of logs for checking against during tests.
+ */
+ protected function withTestLogger(): TestHandler
+ {
+ $monolog = new Logger('testing');
+ $testHandler = new TestHandler();
+ $monolog->pushHandler($testHandler);
+
+ Log::extend('testing', function () use ($monolog) {
+ return $monolog;
+ });
+ Log::setDefaultDriver('testing');
+
+ return $testHandler;
+ }
+
+ /**
+ * Assert that an activity entry exists of the given key.
+ * Checks the activity belongs to the given entity if provided.
+ */
+ protected function assertActivityExists(string $type, ?Entity $entity = null, string $detail = '')
+ {
+ $detailsToCheck = ['type' => $type];
+
+ if ($entity) {
+ $detailsToCheck['entity_type'] = $entity->getMorphClass();
+ $detailsToCheck['entity_id'] = $entity->id;
+ }
+
+ if ($detail) {
+ $detailsToCheck['detail'] = $detail;
+ }
+
+ $this->assertDatabaseHas('activities', $detailsToCheck);
+ }
+
+ /**
+ * @return array{page: Page, chapter: Chapter, book: Book, bookshelf: Bookshelf}
+ */
+ protected function getEachEntityType(): array
+ {
+ return [
+ 'page' => Page::query()->first(),
+ 'chapter' => Chapter::query()->first(),
+ 'book' => Book::query()->first(),
+ 'bookshelf' => Bookshelf::query()->first(),
+ ];
+ }