<?php namespace Tests;
+use BookStack\Entities\Entity;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
*/
protected $baseUrl = 'http://localhost';
- /**
- * Assert a permission error has occurred.
- * @param TestResponse $response
- * @return TestCase
- */
- protected function assertPermissionError(TestResponse $response)
- {
- $response->assertRedirect('/');
- $this->assertSessionHas('error');
- session()->remove('error');
- return $this;
- }
-
/**
* Assert the session contains a specific entry.
* @param string $key
{
return TestResponse::fromBaseResponse($response);
}
+
+ /**
+ * 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);
+ }
}
\ No newline at end of file