]> BookStack Code Mirror - bookstack/blob - tests/TestCase.php
LDAP: Added TLS support
[bookstack] / tests / TestCase.php
1 <?php namespace Tests;
2
3 use BookStack\Entities\Entity;
4 use Illuminate\Foundation\Testing\DatabaseTransactions;
5 use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
6
7 abstract class TestCase extends BaseTestCase
8 {
9     use CreatesApplication;
10     use DatabaseTransactions;
11     use SharedTestHelpers;
12
13     /**
14      * The base URL to use while testing the application.
15      * @var string
16      */
17     protected $baseUrl = 'http://localhost';
18
19     /**
20      * Assert the session contains a specific entry.
21      * @param string $key
22      * @return $this
23      */
24     protected function assertSessionHas(string $key)
25     {
26         $this->assertTrue(session()->has($key), "Session does not contain a [{$key}] entry");
27         return $this;
28     }
29
30     /**
31      * Override of the get method so we can get visibility of custom TestResponse methods.
32      * @param  string  $uri
33      * @param  array  $headers
34      * @return TestResponse
35      */
36     public function get($uri, array $headers = [])
37     {
38         return parent::get($uri, $headers);
39     }
40
41     /**
42      * Create the test response instance from the given response.
43      *
44      * @param  \Illuminate\Http\Response $response
45      * @return TestResponse
46      */
47     protected function createTestResponse($response)
48     {
49         return TestResponse::fromBaseResponse($response);
50     }
51
52     /**
53      * Assert that an activity entry exists of the given key.
54      * Checks the activity belongs to the given entity if provided.
55      */
56     protected function assertActivityExists(string $key, Entity $entity = null)
57     {
58         $detailsToCheck = ['key' => $key];
59
60         if ($entity) {
61             $detailsToCheck['entity_type'] = $entity->getMorphClass();
62             $detailsToCheck['entity_id'] = $entity->id;
63         }
64
65         $this->assertDatabaseHas('activities', $detailsToCheck);
66     }
67 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.