]> BookStack Code Mirror - bookstack/blob - tests/TestCase.php
Started Social Auth Testing
[bookstack] / tests / TestCase.php
1 <?php
2
3 use Illuminate\Foundation\Testing\DatabaseTransactions;
4
5 class TestCase extends Illuminate\Foundation\Testing\TestCase
6 {
7
8     use DatabaseTransactions;
9
10     /**
11      * The base URL to use while testing the application.
12      *
13      * @var string
14      */
15     protected $baseUrl = 'http://localhost';
16     private $admin;
17
18     /**
19      * Creates the application.
20      *
21      * @return \Illuminate\Foundation\Application
22      */
23     public function createApplication()
24     {
25         $app = require __DIR__.'/../bootstrap/app.php';
26
27         $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
28
29         return $app;
30     }
31
32     public function asAdmin()
33     {
34         if($this->admin === null) {
35             $this->admin = \BookStack\User::find(1);
36         }
37         return $this->actingAs($this->admin);
38     }
39
40     /**
41      * Quickly sets an array of settings.
42      * @param $settingsArray
43      */
44     protected function setSettings($settingsArray)
45     {
46         $settings = app('BookStack\Services\SettingService');
47         foreach ($settingsArray as $key => $value) {
48             $settings->put($key, $value);
49         }
50     }
51 }