3 namespace Tests\Settings;
7 class SettingsTest extends TestCase
9 public function test_settings_endpoint_redirects_to_settings_view()
11 $resp = $this->asAdmin()->get('/settings');
13 $resp->assertStatus(302);
15 // Manually check path to ensure it's generated as the full path
16 $location = $resp->headers->get('location');
17 $this->assertEquals(url('/settings/features'), $location);
20 public function test_settings_category_links_work_as_expected()
24 'features' => 'Features & Security',
25 'customization' => 'Customization',
26 'registration' => 'Registration',
29 foreach ($categories as $category => $title) {
30 $resp = $this->get("/settings/{$category}");
31 $this->withHtml($resp)->assertElementContains('h1', $title);
32 $this->withHtml($resp)->assertElementExists("form[action$=\"/settings/{$category}\"]");
36 public function test_not_found_setting_category_throws_404()
38 $resp = $this->asAdmin()->get('/settings/biscuits');
40 $resp->assertStatus(404);
41 $resp->assertSee('Page Not Found');
44 public function test_updating_and_removing_app_icon()
47 $galleryFile = $this->files->uploadedImage('my-app-icon.png');
48 $expectedPath = public_path('uploads/images/system/' . date('Y-m') . '/my-app-icon.png');
50 $this->assertFalse(setting()->get('app-icon'));
51 $this->assertFalse(setting()->get('app-icon-180'));
52 $this->assertFalse(setting()->get('app-icon-128'));
53 $this->assertFalse(setting()->get('app-icon-64'));
54 $this->assertFalse(setting()->get('app-icon-32'));
56 file_get_contents(public_path('icon.ico')),
57 file_get_contents(public_path('favicon.ico')),
60 $prevFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
62 $upload = $this->call('POST', '/settings/customization', [], [], ['app_icon' => $galleryFile], []);
63 $upload->assertRedirect('/settings/customization');
65 $this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);
66 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon'));
67 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-180'));
68 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-128'));
69 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-64'));
70 $this->assertStringContainsString('my-app-icon', setting()->get('app-icon-32'));
72 $newFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
73 $this->assertEquals(5, $newFileCount - $prevFileCount);
75 $resp = $this->get('/');
76 $this->withHtml($resp)->assertElementCount('link[sizes][href*="my-app-icon"]', 6);
78 $this->assertNotEquals(
79 file_get_contents(public_path('icon.ico')),
80 file_get_contents(public_path('favicon.ico')),
83 $reset = $this->post('/settings/customization', ['app_icon_reset' => 'true']);
84 $reset->assertRedirect('/settings/customization');
86 $resetFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
87 $this->assertEquals($prevFileCount, $resetFileCount);
88 $this->assertFalse(setting()->get('app-icon'));
89 $this->assertFalse(setting()->get('app-icon-180'));
90 $this->assertFalse(setting()->get('app-icon-128'));
91 $this->assertFalse(setting()->get('app-icon-64'));
92 $this->assertFalse(setting()->get('app-icon-32'));
95 file_get_contents(public_path('icon.ico')),
96 file_get_contents(public_path('favicon.ico')),