2021-09-06 17:19:06 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Settings;
|
2021-01-30 19:23:15 -05:00
|
|
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class FooterLinksTest extends TestCase
|
|
|
|
{
|
|
|
|
public function test_saving_setting()
|
|
|
|
{
|
2022-03-28 06:09:55 -04:00
|
|
|
$resp = $this->asAdmin()->post('/settings/customization', [
|
2021-01-30 19:23:15 -05:00
|
|
|
'setting-app-footer-links' => [
|
|
|
|
['label' => 'My custom link 1', 'url' => 'https://example.com/1'],
|
|
|
|
['label' => 'My custom link 2', 'url' => 'https://example.com/2'],
|
|
|
|
],
|
|
|
|
]);
|
2022-03-28 06:09:55 -04:00
|
|
|
$resp->assertRedirect('/settings/customization');
|
2021-01-30 19:23:15 -05:00
|
|
|
|
|
|
|
$result = setting('app-footer-links');
|
|
|
|
$this->assertIsArray($result);
|
|
|
|
$this->assertCount(2, $result);
|
|
|
|
$this->assertEquals('My custom link 2', $result[1]['label']);
|
|
|
|
$this->assertEquals('https://example.com/1', $result[0]['url']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_set_options_visible_on_settings_page()
|
|
|
|
{
|
|
|
|
$this->setSettings(['app-footer-links' => [
|
|
|
|
['label' => 'My custom link', 'url' => 'https://example.com/link-a'],
|
|
|
|
['label' => 'Another Link', 'url' => 'https://example.com/link-b'],
|
|
|
|
]]);
|
|
|
|
|
2022-03-28 06:09:55 -04:00
|
|
|
$resp = $this->asAdmin()->get('/settings/customization');
|
2021-10-26 17:04:18 -04:00
|
|
|
$resp->assertSee('value="My custom link"', false);
|
|
|
|
$resp->assertSee('value="Another Link"', false);
|
|
|
|
$resp->assertSee('value="https://example.com/link-a"', false);
|
|
|
|
$resp->assertSee('value="https://example.com/link-b"', false);
|
2021-01-30 19:23:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function test_footer_links_show_on_pages()
|
|
|
|
{
|
|
|
|
$this->setSettings(['app-footer-links' => [
|
|
|
|
['label' => 'My custom link', 'url' => 'https://example.com/link-a'],
|
|
|
|
['label' => 'Another Link', 'url' => 'https://example.com/link-b'],
|
|
|
|
]]);
|
|
|
|
|
2022-07-23 10:10:18 -04:00
|
|
|
$resp = $this->get('/login');
|
|
|
|
$this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/link-a"]', 'My custom link');
|
|
|
|
|
|
|
|
$resp = $this->asEditor()->get('/');
|
|
|
|
$this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/link-b"]', 'Another link');
|
2021-01-30 19:23:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function test_using_translation_system_for_labels()
|
|
|
|
{
|
|
|
|
$this->setSettings(['app-footer-links' => [
|
|
|
|
['label' => 'trans::common.privacy_policy', 'url' => 'https://example.com/privacy'],
|
|
|
|
['label' => 'trans::common.terms_of_service', 'url' => 'https://example.com/terms'],
|
|
|
|
]]);
|
|
|
|
|
|
|
|
$resp = $this->get('/login');
|
2022-07-23 10:10:18 -04:00
|
|
|
$this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/privacy"]', 'Privacy Policy');
|
|
|
|
$this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/terms"]', 'Terms of Service');
|
2021-01-30 19:23:15 -05:00
|
|
|
}
|
2021-06-26 11:23:15 -04:00
|
|
|
}
|