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