+
+ /**
+ * Assert that an activity entry exists of the given key.
+ * Checks the activity belongs to the given entity if provided.
+ */
+ protected function assertActivityExists(string $key, Entity $entity = null)
+ {
+ $detailsToCheck = ['key' => $key];
+
+ if ($entity) {
+ $detailsToCheck['entity_type'] = $entity->getMorphClass();
+ $detailsToCheck['entity_id'] = $entity->id;
+ }
+
+ $this->assertDatabaseHas('activities', $detailsToCheck);
+ }