File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,7 @@ protected function ignoredMethods()
324
324
return array_merge ([
325
325
'data ' ,
326
326
'render ' ,
327
+ 'resolve ' ,
327
328
'resolveView ' ,
328
329
'shouldRender ' ,
329
330
'view ' ,
Original file line number Diff line number Diff line change 5
5
use Illuminate \View \Component ;
6
6
use Illuminate \View \ComponentAttributeBag ;
7
7
use PHPUnit \Framework \TestCase ;
8
+ use ReflectionMethod ;
8
9
9
10
class ViewComponentTest extends TestCase
10
11
{
@@ -19,6 +20,44 @@ public function testDataExposure()
19
20
$ this ->assertSame ('taylor ' , $ variables ['hello ' ]('taylor ' ));
20
21
}
21
22
23
+ public function testIgnoredMethodsAreNotExposedToViewData ()
24
+ {
25
+ $ component = new class extends Component
26
+ {
27
+ protected $ except = ['goodbye ' ];
28
+
29
+ public function render ()
30
+ {
31
+ return 'test ' ;
32
+ }
33
+
34
+ public function hello ()
35
+ {
36
+ return 'hello world ' ;
37
+ }
38
+
39
+ public function goodbye ()
40
+ {
41
+ return 'goodbye ' ;
42
+ }
43
+ };
44
+
45
+ $ data = $ component ->data ();
46
+
47
+ $ this ->assertArrayHasKey ('hello ' , $ data );
48
+ $ this ->assertArrayNotHasKey ('goodbye ' , $ data );
49
+
50
+ $ reflectionMethod = new ReflectionMethod ($ component , 'ignoredMethods ' );
51
+
52
+ $ reflectionMethod ->setAccessible (true );
53
+
54
+ $ ignoredMethods = $ reflectionMethod ->invoke ($ component );
55
+
56
+ foreach ($ ignoredMethods as $ method ) {
57
+ $ this ->assertArrayNotHasKey ($ method , $ data );
58
+ }
59
+ }
60
+
22
61
public function testAttributeParentInheritance ()
23
62
{
24
63
$ component = new TestViewComponent ;
You can’t perform that action at this time.
0 commit comments