@@ -161,6 +161,19 @@ public function testNestedDefaultComponentParsing()
161
161
'@endComponentClass##END-COMPONENT-CLASS##</div> ' , trim ($ result ));
162
162
}
163
163
164
+ public function testCustomNamespaceNestedDefaultComponentParsing ()
165
+ {
166
+ $ this ->mockViewFactory ();
167
+ $ result = $ this ->compiler (namespaces: ['nightshade ' => 'Nightshade \\View \\Components ' ])->compileTags ('<div><x-nightshade::accordion /></div> ' );
168
+
169
+ $ this ->assertSame ("<div>##BEGIN-COMPONENT-CLASS##@component('Nightshade\View\Components\Accordion\Accordion', 'nightshade::accordion', [])
170
+ <?php if (isset( \$attributes) && \$attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
171
+ <?php \$attributes = \$attributes->except(\Nightshade\View\Components\Accordion\Accordion::ignoredParameterNames()); ?>
172
+ <?php endif; ?>
173
+ <?php \$component->withAttributes([]); ?> \n" .
174
+ '@endComponentClass##END-COMPONENT-CLASS##</div> ' , trim ($ result ));
175
+ }
176
+
164
177
public function testBasicComponentWithEmptyAttributesParsing ()
165
178
{
166
179
$ this ->mockViewFactory ();
@@ -375,6 +388,18 @@ public function testSelfClosingComponentsCanBeCompiled()
375
388
'@endComponentClass##END-COMPONENT-CLASS##</div> ' , trim ($ result ));
376
389
}
377
390
391
+ public function testClassesCanBeFoundByComponents ()
392
+ {
393
+ $ this ->mockViewFactory ();
394
+ $ compiler = $ this ->compiler (namespaces: ['nightshade ' => 'Nightshade \\View \\Components ' ]);
395
+
396
+ $ result = $ compiler ->findClassByComponent ('nightshade::calendar ' );
397
+ $ this ->assertSame ('Nightshade \\View \\Components \\Calendar ' , trim ($ result ));
398
+
399
+ $ result = $ compiler ->findClassByComponent ('nightshade::accordion ' );
400
+ $ this ->assertSame ('Nightshade \\View \\Components \\Accordion \\Accordion ' , trim ($ result ));
401
+ }
402
+
378
403
public function testClassNamesCanBeGuessed ()
379
404
{
380
405
$ container = new Container ;
@@ -1004,3 +1029,27 @@ public function render()
1004
1029
return 'card ' ;
1005
1030
}
1006
1031
}
1032
+
1033
+ namespace Nightshade \View \Components ;
1034
+
1035
+ use Illuminate \View \Component ;
1036
+
1037
+ class Calendar extends Component
1038
+ {
1039
+ public function render ()
1040
+ {
1041
+ return 'calendar ' ;
1042
+ }
1043
+ }
1044
+
1045
+ namespace Nightshade \View \Components \Accordion ;
1046
+
1047
+ use Illuminate \View \Component ;
1048
+
1049
+ class Accordion extends Component
1050
+ {
1051
+ public function render ()
1052
+ {
1053
+ return 'accordion ' ;
1054
+ }
1055
+ }
0 commit comments