@@ -46,6 +46,31 @@ public function testPublicMethodsWithNoArgsAreEagerlyInvokedAndNotCached()
46
46
$ this ->assertEquals (3 , $ component ->counter );
47
47
}
48
48
49
+ public function testItIgnoresExceptedMethodsAndProperties ()
50
+ {
51
+ $ component = new TestExceptedViewComponent ();
52
+ $ variables = $ component ->data ();
53
+
54
+ // Ignored methods (with no args) are not invoked behind the scenes.
55
+ $ this ->assertEquals ('Otwell ' , $ component ->taylor );
56
+
57
+ $ this ->assertArrayNotHasKey ('hello ' , $ variables );
58
+ $ this ->assertArrayNotHasKey ('hello2 ' , $ variables );
59
+ $ this ->assertArrayNotHasKey ('taylor ' , $ variables );
60
+ }
61
+
62
+ public function testMethodsOverridePropertyValues ()
63
+ {
64
+ $ component = new TestHelloPropertyHelloMethodComponent ();
65
+ $ variables = $ component ->data ();
66
+ $ this ->assertArrayHasKey ('hello ' , $ variables );
67
+ $ this ->assertEquals ('world ' , $ variables ['hello ' ]());
68
+
69
+ // protected methods do not override public properties.
70
+ $ this ->assertArrayHasKey ('world ' , $ variables );
71
+ $ this ->assertEquals ('world property ' , $ variables ['world ' ]);
72
+ }
73
+
49
74
public function testAttributesAreMergedNotOverwritten ()
50
75
{
51
76
$ component = new TestDefaultAttributesComponent ;
@@ -111,6 +136,50 @@ private function privateHello()
111
136
}
112
137
}
113
138
139
+ class TestExceptedViewComponent extends Component
140
+ {
141
+ protected $ except = ['hello ' , 'hello2 ' , 'taylor ' ];
142
+
143
+ public $ taylor = 'Otwell ' ;
144
+
145
+ public function hello ($ string = 'world ' )
146
+ {
147
+ return $ string ;
148
+ }
149
+
150
+ public function hello2 ()
151
+ {
152
+ return $ this ->taylor = '' ;
153
+ }
154
+
155
+ public function render ()
156
+ {
157
+ return 'test ' ;
158
+ }
159
+ }
160
+
161
+ class TestHelloPropertyHelloMethodComponent extends Component
162
+ {
163
+ public function render ()
164
+ {
165
+ return 'test ' ;
166
+ }
167
+
168
+ public $ hello = 'hello property ' ;
169
+
170
+ public $ world = 'world property ' ;
171
+
172
+ public function hello ($ string = 'world ' )
173
+ {
174
+ return $ string ;
175
+ }
176
+
177
+ protected function world ($ string = 'world ' )
178
+ {
179
+ return $ string ;
180
+ }
181
+ }
182
+
114
183
class TestDefaultAttributesComponent extends Component
115
184
{
116
185
public function __construct ()
0 commit comments