File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -598,7 +598,7 @@ function helper($filenames): void
598598 if (str_contains ($ filename , '\\' )) {
599599 $ path = $ loader ->locateFile ($ filename , 'Helpers ' );
600600
601- if ($ path !== '' ) {
601+ if ($ path === false ) {
602602 throw FileNotFoundException::forFileNotFound ($ filename );
603603 }
604604
Original file line number Diff line number Diff line change 1313
1414namespace CodeIgniter ;
1515
16+ use CodeIgniter \Autoloader \Autoloader ;
1617use CodeIgniter \Autoloader \FileLocator ;
18+ use CodeIgniter \Files \Exceptions \FileNotFoundException ;
1719use CodeIgniter \Test \CIUnitTestCase ;
1820use Config \Services ;
1921use PHPUnit \Framework \Attributes \CoversFunction ;
@@ -148,4 +150,25 @@ function foo_bar_baz(): string
148150
149151 $ this ->assertSame ($ this ->dummyHelpers [0 ], foo_bar_baz ());
150152 }
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+ helper ('Tests\Support\Helpers\baguette ' );
173+ }
151174}
You can’t perform that action at this time.
0 commit comments