]> BookStack Code Mirror - bookstack/blob - tests/Settings/SettingsTest.php
Added 404 response for non-existing setting categories
[bookstack] / tests / Settings / SettingsTest.php
1 <?php
2
3 namespace Tests\Settings;
4
5 use Tests\TestCase;
6
7 class SettingsTest extends TestCase
8 {
9     public function test_settings_endpoint_redirects_to_settings_view()
10     {
11         $resp = $this->asAdmin()->get('/settings');
12
13         $resp->assertRedirect('/settings/features');
14     }
15
16     public function test_settings_category_links_work_as_expected()
17     {
18         $this->asAdmin();
19         $categories = [
20             'features' => 'Features & Security',
21             'customization' => 'Customization',
22             'registration' => 'Registration',
23         ];
24
25         foreach ($categories as $category => $title) {
26             $resp = $this->get("/settings/{$category}");
27             $resp->assertElementContains('h1', $title);
28             $resp->assertElementExists("form[action$=\"/settings/{$category}\"]");
29         }
30     }
31
32     public function test_not_found_setting_category_throws_404()
33     {
34         $resp = $this->asAdmin()->get('/settings/biscuits');
35
36         $resp->assertStatus(404);
37         $resp->assertSee('Page Not Found');
38     }
39 }