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