File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -598,7 +598,7 @@ function helper($filenames): void
598
598
if (str_contains ($ filename , '\\' )) {
599
599
$ path = $ loader ->locateFile ($ filename , 'Helpers ' );
600
600
601
- if ($ path !== '' ) {
601
+ if ($ path === false ) {
602
602
throw FileNotFoundException::forFileNotFound ($ filename );
603
603
}
604
604
Original file line number Diff line number Diff line change 13
13
14
14
namespace CodeIgniter ;
15
15
16
+ use CodeIgniter \Autoloader \Autoloader ;
16
17
use CodeIgniter \Autoloader \FileLocator ;
18
+ use CodeIgniter \Files \Exceptions \FileNotFoundException ;
17
19
use CodeIgniter \Test \CIUnitTestCase ;
18
20
use Config \Services ;
19
21
use PHPUnit \Framework \Attributes \CoversFunction ;
@@ -148,4 +150,33 @@ function foo_bar_baz(): string
148
150
149
151
$ this ->assertSame ($ this ->dummyHelpers [0 ], foo_bar_baz ());
150
152
}
153
+
154
+ public function testNamespacedHelperNotFound (): void
155
+ {
156
+ $ this ->expectException (FileNotFoundException::class);
157
+
158
+ $ locator = $ this ->getMockLocator ();
159
+ Services::injectMock ('locator ' , $ locator );
160
+
161
+ helper ('foo\barbaz ' );
162
+ }
163
+
164
+ public function testNamespacedHelperFound (): void
165
+ {
166
+ $ autoloader = new Autoloader ();
167
+ $ autoloader ->addNamespace ('Tests\Support\Helpers ' , TESTPATH . '_support/Helpers ' );
168
+ $ locator = new FileLocator ($ autoloader );
169
+
170
+ Services::injectMock ('locator ' , $ locator );
171
+
172
+ $ found = true ;
173
+
174
+ try {
175
+ helper ('Tests\Support\Helpers\baguette ' );
176
+ } catch (FileNotFoundException ) {
177
+ $ found = false ;
178
+ }
179
+
180
+ $ this ->assertTrue ($ found );
181
+ }
151
182
}
You can’t perform that action at this time.
0 commit comments