Skip to content

Commit 5e24cb2

Browse files
Reformat Tests (#54)
* wip * Apply fixes from StyleCI (#53)
1 parent 2b43679 commit 5e24cb2

File tree

1 file changed

+31
-34
lines changed

1 file changed

+31
-34
lines changed

tests/PresenterTest.php

+31-34
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class PresenterTest extends IntegrationTest
1818
{
1919
/** @test */
20-
public function you_can_get_the_original_model()
20+
public function can_get_the_original_model()
2121
{
2222
$user = factory(User::class)->create();
2323
$presenter = new class($user) extends Presenter {
@@ -40,7 +40,7 @@ public function middleName()
4040
}
4141

4242
/** @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()
4444
{
4545
$user = factory(User::class)->create();
4646
$presenter = new class($user) extends Presenter {
@@ -49,7 +49,7 @@ public function it_delegates_undefined_method_calls_to_the_underlying_model_inst
4949
}
5050

5151
/** @test */
52-
public function it_delegates_magic_properties_to_the_presenter()
52+
public function delegates_magic_properties_to_the_presenter()
5353
{
5454
$user = factory(User::class)->create();
5555
$presenter = new class($user) extends Presenter {
@@ -63,7 +63,7 @@ public function getSayHelloAttribute()
6363
}
6464

6565
/** @test */
66-
public function a_model_can_be_converted_to_an_array()
66+
public function can_be_converted_to_an_array()
6767
{
6868
Carbon::setTestNow(Carbon::parse('Oct 14 2019'));
6969

@@ -96,7 +96,7 @@ public function getUpdatedAtAttribute($model)
9696
}
9797

9898
/** @test */
99-
public function a_model_can_be_converted_to_json()
99+
public function can_be_converted_to_json()
100100
{
101101
Carbon::setTestNow(Carbon::parse('Oct 14 2019'));
102102

@@ -129,7 +129,7 @@ public function getUpdatedAtAttribute($model)
129129
}
130130

131131
/** @test */
132-
public function a_model_can_be_converted_to_a_string()
132+
public function can_be_converted_to_a_string()
133133
{
134134
Carbon::setTestNow(Carbon::parse('Oct 14 2019'));
135135

@@ -162,35 +162,35 @@ public function getUpdatedAtAttribute($model)
162162
}
163163

164164
/** @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()
166166
{
167167
$user = factory(User::class)->create()->present(UserProfilePresenter::class);
168168
$this->assertInstanceOf(UserProfilePresenter::class, $user);
169169
}
170170

171171
/** @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()
173173
{
174174
$user = factory(UserWithDefaultPresenter::class)->create()->present();
175175
$this->assertInstanceOf(UserProfilePresenter::class, $user);
176176
}
177177

178178
/** @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()
180180
{
181181
$this->expectException(BadMethodCallException::class);
182182
factory(User::class)->create()->present(null);
183183
}
184184

185185
/** @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()
187187
{
188188
$user = present(factory(User::class)->create(), UserProfilePresenter::class);
189189
$this->assertInstanceOf(UserProfilePresenter::class, $user);
190190
}
191191

192192
/** @test */
193-
public function you_can_present_a_model_using_a_closure()
193+
public function can_present_a_model_using_a_closure()
194194
{
195195
$presenter = factory(User::class)->create(['name' => 'David'])->present(function ($user) {
196196
return ['name' => strtolower($user->name)];
@@ -200,7 +200,7 @@ public function you_can_present_a_model_using_a_closure()
200200
}
201201

202202
/** @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()
204204
{
205205
$notAModel = new class {
206206
public $name = 'david';
@@ -219,7 +219,7 @@ public function fullName()
219219
}
220220

221221
/** @test */
222-
public function you_can_present_a_collection_of_eloquent_models()
222+
public function can_present_a_collection_of_eloquent_models()
223223
{
224224
$user = factory(User::class)->create();
225225
$users = collect([$user])->present(UserProfilePresenter::class);
@@ -230,7 +230,7 @@ public function you_can_present_a_collection_of_eloquent_models()
230230
}
231231

232232
/** @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()
234234
{
235235
$user = factory(User::class)->create(['name' => 'David Hemphill']);
236236
$users = collect([$user])->present(function ($user) {
@@ -243,7 +243,7 @@ public function you_can_present_a_collection_of_models_using_a_closure()
243243
}
244244

245245
/** @test */
246-
public function you_can_create_presenters_using_the_make_method()
246+
public function can_create_presenters_using_the_make_method()
247247
{
248248
$user = factory(User::class)->create(['name' => 'David Hemphill']);
249249
$presenter = Presenter::make($user, UserProfilePresenter::class);
@@ -252,7 +252,7 @@ public function you_can_create_presenters_using_the_make_method()
252252
}
253253

254254
/** @test */
255-
public function you_can_call_make_on_the_presenter_itself()
255+
public function can_call_make_on_the_presenter_itself()
256256
{
257257
$user = factory(User::class)->create(['name' => 'David Hemphill']);
258258
$presenter = UserProfilePresenter::make($user);
@@ -261,7 +261,7 @@ public function you_can_call_make_on_the_presenter_itself()
261261
}
262262

263263
/** @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()
265265
{
266266
$user1 = factory(User::class)->create(['name' => 'David Hemphill']);
267267
$user2 = factory(User::class)->create(['name' => 'David Hemphill']);
@@ -272,7 +272,7 @@ public function you_can_present_a_collection_of_models_using_collection_method()
272272
}
273273

274274
/** @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()
276276
{
277277
$user1 = factory(User::class)->create(['name' => 'David Hemphill']);
278278
$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
283283
}
284284

285285
/** @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()
287287
{
288288
Carbon::setTestNow(Carbon::parse('Oct 14 2019'));
289289

@@ -303,7 +303,7 @@ public function it_can_camel_case_the_attributes_instead_of_snake_casing_them()
303303
}
304304

305305
/** @test */
306-
public function you_can_set_the_casing_strategy_at_runtime()
306+
public function can_set_the_casing_strategy_at_runtime()
307307
{
308308
$presenter = factory(User::class)
309309
->create(['name' => 'David Hemphill', 'email' => '[email protected]'])
@@ -345,7 +345,7 @@ public function a_collection_of_presented_eloquent_models_will_still_return_json
345345
}
346346

347347
/** @test */
348-
public function you_can_paginate_a_presented_collection()
348+
public function can_paginate_a_presented_collection()
349349
{
350350
factory(User::class)->create(['name' => 'David Hemphill']);
351351
factory(User::class)->create(['name' => 'Taylor Otwell']);
@@ -360,7 +360,7 @@ public function you_can_paginate_a_presented_collection()
360360
}
361361

362362
/** @test */
363-
public function a_presenter_removes_hidden_model_attributes_from_output()
363+
public function presenter_removes_hidden_model_attributes_from_output()
364364
{
365365
$presenter = factory(User::class)
366366
->create(['name' => 'David Hemphill', 'email' => '[email protected]'])
@@ -373,7 +373,7 @@ public function a_presenter_removes_hidden_model_attributes_from_output()
373373
}
374374

375375
/** @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()
377377
{
378378
$presenter = factory(User::class)
379379
->create(['name' => 'David Hemphill', 'email' => '[email protected]'])
@@ -385,7 +385,7 @@ public function a_presenter_removes_hidden_attributes_and_leaves_visible_model_a
385385
}
386386

387387
/** @test */
388-
public function it_supports_offset_exists_via_array_access()
388+
public function supports_offset_exists_via_array_access()
389389
{
390390
$presenter = factory(User::class)
391391
->create(['name' => 'David Hemphill', 'email' => '[email protected]'])
@@ -395,23 +395,20 @@ public function it_supports_offset_exists_via_array_access()
395395
}
396396

397397
/** @test */
398-
public function a_presenter_leaves_visible_model_attributes_from_output()
398+
public function presenter_leaves_visible_model_attributes_in_output()
399399
{
400400
$presenter = factory(User::class)
401401
->create(['name' => 'David Hemphill', 'email' => '[email protected]'])
402402
->present(VisibleAttributesPresenter::class);
403403

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+
'email' => '[email protected]',
407+
], $presenter->toArray());
411408
}
412409

413410
/** @test */
414-
public function it_can_be_array_accessed()
411+
public function can_be_array_accessed()
415412
{
416413
$presenter = factory(User::class)
417414
->create(['name' => 'David Hemphill', 'email' => '[email protected]'])
@@ -421,7 +418,7 @@ public function it_can_be_array_accessed()
421418
}
422419

423420
/** @test */
424-
public function it_cannot_be_written_to_via_array_access()
421+
public function cannot_be_written_to_via_array_access()
425422
{
426423
$this->expectException(BadMethodCallException::class);
427424

0 commit comments

Comments
 (0)