]> BookStack Code Mirror - bookstack/blob - tests/Settings/FooterLinksTest.php
Cleaned up dark mode styles inc. setting browser color scheme
[bookstack] / tests / Settings / FooterLinksTest.php
1 <?php
2
3 namespace Tests\Settings;
4
5 use Tests\TestCase;
6
7 class FooterLinksTest extends TestCase
8 {
9     public function test_saving_setting()
10     {
11         $resp = $this->asAdmin()->post('/settings/customization', [
12             'setting-app-footer-links' => [
13                 ['label' => 'My custom link 1', 'url' => 'https://example.com/1'],
14                 ['label' => 'My custom link 2', 'url' => 'https://example.com/2'],
15             ],
16         ]);
17         $resp->assertRedirect('/settings/customization');
18
19         $result = setting('app-footer-links');
20         $this->assertIsArray($result);
21         $this->assertCount(2, $result);
22         $this->assertEquals('My custom link 2', $result[1]['label']);
23         $this->assertEquals('https://example.com/1', $result[0]['url']);
24     }
25
26     public function test_set_options_visible_on_settings_page()
27     {
28         $this->setSettings(['app-footer-links' => [
29             ['label' => 'My custom link', 'url' => 'https://example.com/link-a'],
30             ['label' => 'Another Link', 'url' => 'https://example.com/link-b'],
31         ]]);
32
33         $resp = $this->asAdmin()->get('/settings/customization');
34         $resp->assertSee('value="My custom link"', false);
35         $resp->assertSee('value="Another Link"', false);
36         $resp->assertSee('value="https://example.com/link-a"', false);
37         $resp->assertSee('value="https://example.com/link-b"', false);
38     }
39
40     public function test_footer_links_show_on_pages()
41     {
42         $this->setSettings(['app-footer-links' => [
43             ['label' => 'My custom link', 'url' => 'https://example.com/link-a'],
44             ['label' => 'Another Link', 'url' => 'https://example.com/link-b'],
45         ]]);
46
47         $resp = $this->get('/login');
48         $this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/link-a"]', 'My custom link');
49
50         $resp = $this->asEditor()->get('/');
51         $this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/link-b"]', 'Another link');
52     }
53
54     public function test_using_translation_system_for_labels()
55     {
56         $this->setSettings(['app-footer-links' => [
57             ['label' => 'trans::common.privacy_policy', 'url' => 'https://example.com/privacy'],
58             ['label' => 'trans::common.terms_of_service', 'url' => 'https://example.com/terms'],
59         ]]);
60
61         $resp = $this->get('/login');
62         $this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/privacy"]', 'Privacy Policy');
63         $this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/terms"]', 'Terms of Service');
64     }
65 }