File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,4 +234,39 @@ public function testMakeMethod()
234234 $ this ->assertEquals (array ('foo ' ), $ collection ->all ());
235235 }
236236
237+
238+ public function testGetListValueWithAccessors ()
239+ {
240+ $ model = new TestAccessorEloquentTestStub (array ('some ' => 'foo ' ));
241+ $ modelTwo = new TestAccessorEloquentTestStub (array ('some ' => 'bar ' ));
242+ $ data = new Collection (array ($ model , $ modelTwo ));
243+
244+ $ this ->assertEquals (array ('foo ' , 'bar ' ), $ data ->lists ('some ' ));
245+ }
246+
237247}
248+
249+ class TestAccessorEloquentTestStub
250+ {
251+ protected $ attributes = array ();
252+
253+ public function __construct ($ attributes )
254+ {
255+ $ this ->attributes = $ attributes ;
256+ }
257+
258+ public function __get ($ attribute )
259+ {
260+ $ accessor = 'get ' .lcfirst ($ attribute ). 'Attribute ' ;
261+ if (method_exists ($ this , $ accessor )) {
262+ return $ this ->$ accessor ();
263+ }
264+
265+ return $ this ->$ attribute ;
266+ }
267+
268+ public function getSomeAttribute ()
269+ {
270+ return $ this ->attributes ['some ' ];
271+ }
272+ }
You can’t perform that action at this time.
0 commit comments