File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ public function __invoke()
1010 {
1111 session ()->reflash ();
1212
13- $ url = config ('statamic.cp.route ' ).'/ ' .urlencode ( Preference::get ('start_page ' , config ('statamic.cp.start_page ' ) ));
13+ $ url = config ('statamic.cp.route ' ).'/ ' .Preference::get ('start_page ' , config ('statamic.cp.start_page ' ));
1414
1515 return redirect ($ url );
1616 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CP ;
4+
5+ use PHPUnit \Framework \Attributes \Test ;
6+ use Statamic \Facades \File ;
7+ use Statamic \Facades \Preference ;
8+ use Statamic \Facades \User ;
9+ use Tests \PreventSavingStacheItemsToDisk ;
10+ use Tests \TestCase ;
11+
12+ class StartPageTest extends TestCase
13+ {
14+ use PreventSavingStacheItemsToDisk;
15+
16+ protected function setUp (): void
17+ {
18+ parent ::setUp ();
19+
20+ File::delete (resource_path ('preferences.yaml ' ));
21+ }
22+
23+ #[Test]
24+ public function it_uses_start_page_preference ()
25+ {
26+ config ('statamic.cp.start_page ' , 'dashboard ' );
27+
28+ Preference::default ()->setPreference ('start_page ' , 'collections/pages ' )->save ();
29+
30+ $ this
31+ ->actingAs (User::make ()->makeSuper ()->save ())
32+ ->get ('/cp ' )
33+ ->assertRedirect ('/cp/collections/pages ' );
34+ }
35+
36+ #[Test]
37+ public function it_falls_back_to_start_page_config_option_when_preference_is_missing ()
38+ {
39+ config ('statamic.cp.start_page ' , 'dashboard ' );
40+
41+ $ this
42+ ->actingAs (User::make ()->makeSuper ()->save ())
43+ ->get ('/cp ' )
44+ ->assertRedirect ('/cp/dashboard ' );
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments