17
17
class PresenterTest extends IntegrationTest
18
18
{
19
19
/** @test */
20
- public function you_can_get_the_original_model ()
20
+ public function can_get_the_original_model ()
21
21
{
22
22
$ user = factory (User::class)->create ();
23
23
$ presenter = new class ($ user ) extends Presenter {
@@ -40,7 +40,7 @@ public function middleName()
40
40
}
41
41
42
42
/** @test */
43
- public function it_delegates_undefined_method_calls_to_the_underlying_model_instance ()
43
+ public function delegates_undefined_method_calls_to_the_underlying_model_instance ()
44
44
{
45
45
$ user = factory (User::class)->create ();
46
46
$ presenter = new class ($ user ) extends Presenter {
@@ -49,7 +49,7 @@ public function it_delegates_undefined_method_calls_to_the_underlying_model_inst
49
49
}
50
50
51
51
/** @test */
52
- public function it_delegates_magic_properties_to_the_presenter ()
52
+ public function delegates_magic_properties_to_the_presenter ()
53
53
{
54
54
$ user = factory (User::class)->create ();
55
55
$ presenter = new class ($ user ) extends Presenter {
@@ -63,7 +63,7 @@ public function getSayHelloAttribute()
63
63
}
64
64
65
65
/** @test */
66
- public function a_model_can_be_converted_to_an_array ()
66
+ public function can_be_converted_to_an_array ()
67
67
{
68
68
Carbon::setTestNow (Carbon::parse ('Oct 14 2019 ' ));
69
69
@@ -96,7 +96,7 @@ public function getUpdatedAtAttribute($model)
96
96
}
97
97
98
98
/** @test */
99
- public function a_model_can_be_converted_to_json ()
99
+ public function can_be_converted_to_json ()
100
100
{
101
101
Carbon::setTestNow (Carbon::parse ('Oct 14 2019 ' ));
102
102
@@ -129,7 +129,7 @@ public function getUpdatedAtAttribute($model)
129
129
}
130
130
131
131
/** @test */
132
- public function a_model_can_be_converted_to_a_string ()
132
+ public function can_be_converted_to_a_string ()
133
133
{
134
134
Carbon::setTestNow (Carbon::parse ('Oct 14 2019 ' ));
135
135
@@ -162,35 +162,35 @@ public function getUpdatedAtAttribute($model)
162
162
}
163
163
164
164
/** @test */
165
- public function you_can_call_present_on_an_eloquent_model_using_the_trait ()
165
+ public function can_call_present_on_an_eloquent_model_using_the_trait ()
166
166
{
167
167
$ user = factory (User::class)->create ()->present (UserProfilePresenter::class);
168
168
$ this ->assertInstanceOf (UserProfilePresenter::class, $ user );
169
169
}
170
170
171
171
/** @test */
172
- public function you_can_call_present_on_an_eloquent_model_using_the_trait_and_use_default_presenter ()
172
+ public function can_call_present_on_an_eloquent_model_using_the_trait_and_use_default_presenter ()
173
173
{
174
174
$ user = factory (UserWithDefaultPresenter::class)->create ()->present ();
175
175
$ this ->assertInstanceOf (UserProfilePresenter::class, $ user );
176
176
}
177
177
178
178
/** @test */
179
- public function it_throws_if_theres_no_default_presenter_and_none_is_passed_in ()
179
+ public function throws_if_theres_no_default_presenter_and_none_is_passed_in ()
180
180
{
181
181
$ this ->expectException (BadMethodCallException::class);
182
182
factory (User::class)->create ()->present (null );
183
183
}
184
184
185
185
/** @test */
186
- public function you_can_use_a_helper_function_to_decorate_a_model ()
186
+ public function can_use_a_helper_function_to_decorate_a_model ()
187
187
{
188
188
$ user = present (factory (User::class)->create (), UserProfilePresenter::class);
189
189
$ this ->assertInstanceOf (UserProfilePresenter::class, $ user );
190
190
}
191
191
192
192
/** @test */
193
- public function you_can_present_a_model_using_a_closure ()
193
+ public function can_present_a_model_using_a_closure ()
194
194
{
195
195
$ presenter = factory (User::class)->create (['name ' => 'David ' ])->present (function ($ user ) {
196
196
return ['name ' => strtolower ($ user ->name )];
@@ -200,7 +200,7 @@ public function you_can_present_a_model_using_a_closure()
200
200
}
201
201
202
202
/** @test */
203
- public function you_can_present_an_object_that_is_not_a_model ()
203
+ public function can_present_an_object_that_is_not_a_model ()
204
204
{
205
205
$ notAModel = new class {
206
206
public $ name = 'david ' ;
@@ -219,7 +219,7 @@ public function fullName()
219
219
}
220
220
221
221
/** @test */
222
- public function you_can_present_a_collection_of_eloquent_models ()
222
+ public function can_present_a_collection_of_eloquent_models ()
223
223
{
224
224
$ user = factory (User::class)->create ();
225
225
$ users = collect ([$ user ])->present (UserProfilePresenter::class);
@@ -230,7 +230,7 @@ public function you_can_present_a_collection_of_eloquent_models()
230
230
}
231
231
232
232
/** @test */
233
- public function you_can_present_a_collection_of_models_using_a_closure ()
233
+ public function can_present_a_collection_of_models_using_a_closure ()
234
234
{
235
235
$ user = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
236
236
$ users = collect ([$ user ])->present (function ($ user ) {
@@ -243,7 +243,7 @@ public function you_can_present_a_collection_of_models_using_a_closure()
243
243
}
244
244
245
245
/** @test */
246
- public function you_can_create_presenters_using_the_make_method ()
246
+ public function can_create_presenters_using_the_make_method ()
247
247
{
248
248
$ user = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
249
249
$ presenter = Presenter::make ($ user , UserProfilePresenter::class);
@@ -252,7 +252,7 @@ public function you_can_create_presenters_using_the_make_method()
252
252
}
253
253
254
254
/** @test */
255
- public function you_can_call_make_on_the_presenter_itself ()
255
+ public function can_call_make_on_the_presenter_itself ()
256
256
{
257
257
$ user = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
258
258
$ presenter = UserProfilePresenter::make ($ user );
@@ -261,7 +261,7 @@ public function you_can_call_make_on_the_presenter_itself()
261
261
}
262
262
263
263
/** @test */
264
- public function you_can_present_a_collection_of_models_using_collection_method ()
264
+ public function can_present_a_collection_of_models_using_collection_method ()
265
265
{
266
266
$ user1 = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
267
267
$ user2 = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
@@ -272,7 +272,7 @@ public function you_can_present_a_collection_of_models_using_collection_method()
272
272
}
273
273
274
274
/** @test */
275
- public function you_can_present_a_collection_of_models_using_collection_method_on_the_presenter_itself ()
275
+ public function can_present_a_collection_of_models_using_collection_method_on_the_presenter_itself ()
276
276
{
277
277
$ user1 = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
278
278
$ user2 = factory (User::class)->create (['name ' => 'David Hemphill ' ]);
@@ -283,7 +283,7 @@ public function you_can_present_a_collection_of_models_using_collection_method_o
283
283
}
284
284
285
285
/** @test */
286
- public function it_can_camel_case_the_attributes_instead_of_snake_casing_them ()
286
+ public function can_camel_case_the_attributes_instead_of_snake_casing_them ()
287
287
{
288
288
Carbon::setTestNow (Carbon::parse ('Oct 14 2019 ' ));
289
289
@@ -303,7 +303,7 @@ public function it_can_camel_case_the_attributes_instead_of_snake_casing_them()
303
303
}
304
304
305
305
/** @test */
306
- public function you_can_set_the_casing_strategy_at_runtime ()
306
+ public function can_set_the_casing_strategy_at_runtime ()
307
307
{
308
308
$ presenter = factory (User::class)
309
309
->
create ([
'name ' =>
'David Hemphill ' ,
'email ' =>
'[email protected] ' ])
@@ -345,7 +345,7 @@ public function a_collection_of_presented_eloquent_models_will_still_return_json
345
345
}
346
346
347
347
/** @test */
348
- public function you_can_paginate_a_presented_collection ()
348
+ public function can_paginate_a_presented_collection ()
349
349
{
350
350
factory (User::class)->create (['name ' => 'David Hemphill ' ]);
351
351
factory (User::class)->create (['name ' => 'Taylor Otwell ' ]);
@@ -360,7 +360,7 @@ public function you_can_paginate_a_presented_collection()
360
360
}
361
361
362
362
/** @test */
363
- public function a_presenter_removes_hidden_model_attributes_from_output ()
363
+ public function presenter_removes_hidden_model_attributes_from_output ()
364
364
{
365
365
$ presenter = factory (User::class)
366
366
->
create ([
'name ' =>
'David Hemphill ' ,
'email ' =>
'[email protected] ' ])
@@ -373,7 +373,7 @@ public function a_presenter_removes_hidden_model_attributes_from_output()
373
373
}
374
374
375
375
/** @test */
376
- public function a_presenter_removes_hidden_attributes_and_leaves_visible_model_attributes_from_output ()
376
+ public function presenter_removes_hidden_attributes_and_leaves_visible_model_attributes_in_output ()
377
377
{
378
378
$ presenter = factory (User::class)
379
379
->
create ([
'name ' =>
'David Hemphill ' ,
'email ' =>
'[email protected] ' ])
@@ -385,7 +385,7 @@ public function a_presenter_removes_hidden_attributes_and_leaves_visible_model_a
385
385
}
386
386
387
387
/** @test */
388
- public function it_supports_offset_exists_via_array_access ()
388
+ public function supports_offset_exists_via_array_access ()
389
389
{
390
390
$ presenter = factory (User::class)
391
391
->
create ([
'name ' =>
'David Hemphill ' ,
'email ' =>
'[email protected] ' ])
@@ -395,23 +395,20 @@ public function it_supports_offset_exists_via_array_access()
395
395
}
396
396
397
397
/** @test */
398
- public function a_presenter_leaves_visible_model_attributes_from_output ()
398
+ public function presenter_leaves_visible_model_attributes_in_output ()
399
399
{
400
400
$ presenter = factory (User::class)
401
401
->
create ([
'name ' =>
'David Hemphill ' ,
'email ' =>
'[email protected] ' ])
402
402
->present (VisibleAttributesPresenter::class);
403
403
404
- $ result = $ presenter ->toArray ();
405
-
406
- $ this ->assertTrue (isset ($ result ['id ' ]));
407
- $ this ->assertTrue (isset ($ result ['email ' ]));
408
- $ this ->assertFalse (isset ($ result ['name ' ]));
409
-
410
- $ this ->
assertEquals (
$ result[
'email ' ],
'[email protected] ' );
404
+ $ this ->assertEquals ([
405
+ 'id ' => 1 ,
406
+
407
+ ], $ presenter ->toArray ());
411
408
}
412
409
413
410
/** @test */
414
- public function it_can_be_array_accessed ()
411
+ public function can_be_array_accessed ()
415
412
{
416
413
$ presenter = factory (User::class)
417
414
->
create ([
'name ' =>
'David Hemphill ' ,
'email ' =>
'[email protected] ' ])
@@ -421,7 +418,7 @@ public function it_can_be_array_accessed()
421
418
}
422
419
423
420
/** @test */
424
- public function it_cannot_be_written_to_via_array_access ()
421
+ public function cannot_be_written_to_via_array_access ()
425
422
{
426
423
$ this ->expectException (BadMethodCallException::class);
427
424
0 commit comments