@@ -51,64 +51,67 @@ protected function setUp(): void
51
51
$ this ->locator = new FileLocator ($ autoloader );
52
52
}
53
53
54
- public function testLocateFileWorksWithLegacyStructure ()
54
+ public function testLocateFileNotNamespacedFindsInAppDirectory ()
55
55
{
56
- $ file = 'Controllers/Home ' ;
56
+ $ file = 'Controllers/Home ' ; // not namespaced
57
57
58
58
$ expected = APPPATH . 'Controllers/Home.php ' ;
59
59
60
60
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file ));
61
61
}
62
62
63
- public function testLocateFileWithLegacyStructureNotFound ()
63
+ public function testLocateFileNotNamespacedNotFound ()
64
64
{
65
- $ file = 'Unknown ' ;
65
+ $ file = 'Unknown ' ; // not namespaced
66
66
67
67
$ this ->assertFalse ($ this ->locator ->locateFile ($ file ));
68
68
}
69
69
70
- public function testLocateFileWorksInApplicationDirectory ()
70
+ public function testLocateFileNotNamespacedFindsWithFolderInAppDirectory ()
71
71
{
72
- $ file = 'welcome_message ' ;
72
+ $ file = 'welcome_message ' ; // not namespaced
73
73
74
74
$ expected = APPPATH . 'Views/welcome_message.php ' ;
75
75
76
76
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file , 'Views ' ));
77
77
}
78
78
79
- public function testLocateFileWorksInApplicationDirectoryWithoutFolder ()
79
+ public function testLocateFileNotNamespacedFindesWithoutFolderInAppDirectory ()
80
80
{
81
- $ file = 'Common ' ;
81
+ $ file = 'Common ' ; // not namespaced
82
82
83
83
$ expected = APPPATH . 'Common.php ' ;
84
84
85
85
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file ));
86
86
}
87
87
88
- public function testLocateFileWorksInNestedApplicationDirectory ()
88
+ public function testLocateFileNotNamespacedWorksInNestedAppDirectory ()
89
89
{
90
- $ file = 'Controllers/Home ' ;
90
+ $ file = 'Controllers/Home ' ; // not namespaced
91
91
92
92
$ expected = APPPATH . 'Controllers/Home.php ' ;
93
93
94
+ // This works because $file contains `Controllers`.
94
95
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file , 'Controllers ' ));
95
96
}
96
97
97
- public function testLocateFileReplacesFolderName ()
98
+ public function testLocateFileWithFolderNameInFile ()
98
99
{
99
100
$ file = '\App\Views/errors/html/error_404.php ' ;
100
101
101
102
$ expected = APPPATH . 'Views/errors/html/error_404.php ' ;
102
103
104
+ // This works because $file contains `Views`.
103
105
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file , 'Views ' ));
104
106
}
105
107
106
- public function testLocateFileReplacesFolderNameLegacy ()
108
+ public function testLocateFileNotNamespacedWithFolderNameInFile ()
107
109
{
108
- $ file = 'Views/welcome_message.php ' ;
110
+ $ file = 'Views/welcome_message.php ' ; // not namespaced
109
111
110
112
$ expected = APPPATH . 'Views/welcome_message.php ' ;
111
113
114
+ // This works because $file contains `Views`.
112
115
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file , 'Views ' ));
113
116
}
114
117
@@ -118,6 +121,7 @@ public function testLocateFileCanFindNamespacedView()
118
121
119
122
$ expected = APPPATH . 'Views/errors/html/error_404.php ' ;
120
123
124
+ // The namespace `Errors` (APPPATH . 'Views/errors') + the folder (`html`) + `error_404`
121
125
$ this ->assertSame ($ expected , $ this ->locator ->locateFile ($ file , 'html ' ));
122
126
}
123
127
0 commit comments