5 use BookStack\Entities\Models\Entity;
6 use Illuminate\Foundation\Testing\DatabaseTransactions;
7 use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
9 abstract class TestCase extends BaseTestCase
11 use CreatesApplication;
12 use DatabaseTransactions;
13 use SharedTestHelpers;
16 * The base URL to use while testing the application.
20 protected $baseUrl = 'http://localhost';
23 * Assert the session contains a specific entry.
29 protected function assertSessionHas(string $key)
31 $this->assertTrue(session()->has($key), "Session does not contain a [{$key}] entry");
37 * Override of the get method so we can get visibility of custom TestResponse methods.
40 * @param array $headers
42 * @return TestResponse
44 public function get($uri, array $headers = [])
46 return parent::get($uri, $headers);
50 * Create the test response instance from the given response.
52 * @param \Illuminate\Http\Response $response
54 * @return TestResponse
56 protected function createTestResponse($response)
58 return TestResponse::fromBaseResponse($response);
62 * Assert that an activity entry exists of the given key.
63 * Checks the activity belongs to the given entity if provided.
65 protected function assertActivityExists(string $type, ?Entity $entity = null, string $detail = '')
67 $detailsToCheck = ['type' => $type];
70 $detailsToCheck['entity_type'] = $entity->getMorphClass();
71 $detailsToCheck['entity_id'] = $entity->id;
75 $detailsToCheck['detail'] = $detail;
78 $this->assertDatabaseHas('activities', $detailsToCheck);