3 namespace Tests\Settings;
6 use Tests\Uploads\UsesImages;
8 class SettingsTest extends TestCase
12 public function test_settings_endpoint_redirects_to_settings_view()
14 $resp = $this->asAdmin()->get('/settings');
16 $resp->assertStatus(302);
18 // Manually check path to ensure it's generated as the full path
19 $location = $resp->headers->get('location');
20 $this->assertEquals(url('/settings/features'), $location);
23 public function test_settings_category_links_work_as_expected()
27 'features' => 'Features & Security',
28 'customization' => 'Customization',
29 'registration' => 'Registration',
32 foreach ($categories as $category => $title) {
33 $resp = $this->get("/settings/{$category}");
34 $this->withHtml($resp)->assertElementContains('h1', $title);
35 $this->withHtml($resp)->assertElementExists("form[action$=\"/settings/{$category}\"]");
39 public function test_not_found_setting_category_throws_404()
41 $resp = $this->asAdmin()->get('/settings/biscuits');
43 $resp->assertStatus(404);
44 $resp->assertSee('Page Not Found');
47 public function test_updating_and_removing_app_icon()
50 $galleryFile = $this->getTestImage('my-app-icon.png');
51 $expectedPath = public_path('uploads/images/system/' . date('Y-m') . '/my-app-icon.png');
53 $this->assertFalse(setting()->get('app-icon'));
54 $this->assertFalse(setting()->get('app-icon-180'));
55 $this->assertFalse(setting()->get('app-icon-128'));
56 $this->assertFalse(setting()->get('app-icon-64'));
57 $this->assertFalse(setting()->get('app-icon-32'));
59 $prevFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
61 $upload = $this->call('POST', '/settings/customization', [], [], ['app_icon' => $galleryFile], []);
62 $upload->assertRedirect('/settings/customization');
64 $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);
65 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon'));
66 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-180'));
67 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-128'));
68 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-64'));
69 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-32'));
71 $newFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
72 $this->assertEquals(5, $newFileCount - $prevFileCount);
74 $resp = $this->get('/');
75 $this->withHtml($resp)->assertElementCount('link[sizes][href*="my-app-icon"]', 6);
77 $reset = $this->post('/settings/customization', ['app_icon_reset' => 'true']);
78 $reset->assertRedirect('/settings/customization');
80 $resetFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
81 $this->assertEquals($prevFileCount, $resetFileCount);
82 $this->assertFalse(setting()->get('app-icon'));
83 $this->assertFalse(setting()->get('app-icon-180'));
84 $this->assertFalse(setting()->get('app-icon-128'));
85 $this->assertFalse(setting()->get('app-icon-64'));
86 $this->assertFalse(setting()->get('app-icon-32'));