+ $error = session()->get('error');
+ PHPUnit::assertTrue($error === $message, "Failed asserting the session contains an error. \nFound: {$error}\nExpecting: {$message}");
+ }
+
+ /**
+ * Assert the session contains a specific entry.
+ */
+ protected function assertSessionHas(string $key): self
+ {
+ $this->assertTrue(session()->has($key), "Session does not contain a [{$key}] entry");
+
+ return $this;
+ }
+
+ protected function assertNotificationContains(\Illuminate\Testing\TestResponse $resp, string $text)
+ {
+ return $this->withHtml($resp)->assertElementContains('.notification[role="alert"]', $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['loggable_type'] = $entity->getMorphClass();
+ $detailsToCheck['loggable_id'] = $entity->id;