File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use Coderflex \LaravelPresenter \Concerns \CanPresent ;
6
6
use Coderflex \LaravelPresenter \Concerns \UsesPresenters ;
7
- use Coderflex \LaravelPresenter \Tests \Presenters \UserPresenter ;
7
+ use Coderflex \LaravelPresenter \Tests \Presenters \{ UserPresenter , UserSettingPresenter } ;
8
8
use Illuminate \Database \Eloquent \Model ;
9
9
10
10
class User extends Model implements CanPresent
@@ -15,5 +15,6 @@ class User extends Model implements CanPresent
15
15
16
16
protected $ presenters = [
17
17
'default ' => UserPresenter::class,
18
+ 'setting ' => UserSettingPresenter::class,
18
19
];
19
20
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Coderflex \LaravelPresenter \Tests \Presenters ;
4
+
5
+ use Coderflex \LaravelPresenter \Presenter ;
6
+
7
+ class UserSettingPresenter extends Presenter
8
+ {
9
+ public function lang ()
10
+ {
11
+ return 'en ' ;
12
+ }
13
+ }
Original file line number Diff line number Diff line change 28
28
->toEqual ('John Doe ' );
29
29
})->group ('Presenter Implementation ' );
30
30
31
+ it ('presents user lang from another presenter type ' , function () {
32
+ $ user = new User ([
33
+ 'first_name ' => 'John ' ,
34
+ 'last_name ' => 'Doe ' ,
35
+ 'email ' => 'john@example.com ' ,
36
+ 'password ' => '123 ' ,
37
+ ]);
38
+
39
+ expect ($ user ->present ('setting ' )->lang )
40
+ ->toEqual ('en ' );
41
+ })->group ('Presenter Implementation ' );
42
+
31
43
it ('should implements CanPresent Interface ' , function () {
32
44
$ post = new Post ([
33
45
'title ' => 'a title for a post ' ,
You can’t perform that action at this time.
0 commit comments