3 use BookStack\Entities\Entity;
4 use Illuminate\Foundation\Testing\DatabaseTransactions;
5 use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
7 abstract class TestCase extends BaseTestCase
9 use CreatesApplication;
10 use DatabaseTransactions;
11 use SharedTestHelpers;
14 * The base URL to use while testing the application.
17 protected $baseUrl = 'http://localhost';
20 * Assert the session contains a specific entry.
24 protected function assertSessionHas(string $key)
26 $this->assertTrue(session()->has($key), "Session does not contain a [{$key}] entry");
31 * Override of the get method so we can get visibility of custom TestResponse methods.
33 * @param array $headers
34 * @return TestResponse
36 public function get($uri, array $headers = [])
38 return parent::get($uri, $headers);
42 * Create the test response instance from the given response.
44 * @param \Illuminate\Http\Response $response
45 * @return TestResponse
47 protected function createTestResponse($response)
49 return TestResponse::fromBaseResponse($response);
53 * Assert that an activity entry exists of the given key.
54 * Checks the activity belongs to the given entity if provided.
56 protected function assertActivityExists(string $key, Entity $entity = null)
58 $detailsToCheck = ['key' => $key];
61 $detailsToCheck['entity_type'] = $entity->getMorphClass();
62 $detailsToCheck['entity_id'] = $entity->id;
65 $this->assertDatabaseHas('activities', $detailsToCheck);