Skip to content

Commit f116b9b

Browse files
authored
Fix tests code style and update workflows (#102)
1 parent 6c02982 commit f116b9b

10 files changed

Lines changed: 51 additions & 96 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ jobs:
4646

4747
steps:
4848
- name: Checkout code
49-
uses: actions/checkout@v2
49+
uses: actions/checkout@v4
5050

5151
- name: Cache dependencies
52-
uses: actions/cache@v2
52+
uses: actions/cache@v4
5353
with:
5454
path: ~/.composer/cache/files
5555
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

tests/AbstractTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
abstract class AbstractTestCase extends Orchestra
2323
{
24+
public static $latestResponse;
25+
2426
/**
2527
* Actions to be performed on PHPUnit start.
2628
*

tests/Unit/Events/ModelWasBannedTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
final class ModelWasBannedTest extends AbstractTestCase
2222
{
23-
/** @test */
24-
public function it_can_fire_event_on_helper_call(): void
23+
public function test_it_can_fire_event_on_helper_call(): void
2524
{
2625
Event::fake(ModelWasBanned::class);
2726
$entity = User::factory()->create();
@@ -31,8 +30,7 @@ public function it_can_fire_event_on_helper_call(): void
3130
Event::assertDispatched(ModelWasBanned::class);
3231
}
3332

34-
/** @test */
35-
public function it_can_fire_event_on_relation_create(): void
33+
public function test_it_can_fire_event_on_relation_create(): void
3634
{
3735
Event::fake(ModelWasBanned::class);
3836
$entity = User::factory()->create();

tests/Unit/Events/ModelWasUnbannedTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
final class ModelWasUnbannedTest extends AbstractTestCase
2222
{
23-
/** @test */
24-
public function it_can_fire_event_on_helper_call(): void
23+
public function test_it_can_fire_event_on_helper_call(): void
2524
{
2625
Event::fake(ModelWasUnbanned::class);
2726
$ban = Ban::factory()->create();
@@ -31,8 +30,7 @@ public function it_can_fire_event_on_helper_call(): void
3130
Event::assertDispatched(ModelWasUnbanned::class);
3231
}
3332

34-
/** @test */
35-
public function it_can_fire_event_on_relation_delete(): void
33+
public function test_it_can_fire_event_on_relation_delete(): void
3634
{
3735
Event::fake(ModelWasUnbanned::class);
3836
$ban = Ban::factory()->create();

tests/Unit/Models/BanTest.php

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
final class BanTest extends AbstractTestCase
2222
{
23-
/** @test */
24-
public function it_can_fill_comment(): void
23+
public function test_it_can_fill_comment(): void
2524
{
2625
$ban = new Ban([
2726
'comment' => 'Enjoy your ban!',
@@ -30,8 +29,7 @@ public function it_can_fill_comment(): void
3029
$this->assertSame('Enjoy your ban!', $ban->comment);
3130
}
3231

33-
/** @test */
34-
public function it_can_fill_expired_at(): void
32+
public function test_it_can_fill_expired_at(): void
3533
{
3634
$expiredAt = Carbon::now()->toDateTimeString();
3735

@@ -42,8 +40,7 @@ public function it_can_fill_expired_at(): void
4240
$this->assertEquals($expiredAt, $ban->getAttribute('expired_at'));
4341
}
4442

45-
/** @test */
46-
public function it_can_fill_created_by_type(): void
43+
public function test_it_can_fill_created_by_type(): void
4744
{
4845
$ban = new Ban([
4946
'created_by_type' => 'TestType',
@@ -52,8 +49,7 @@ public function it_can_fill_created_by_type(): void
5249
$this->assertSame('TestType', $ban->getAttribute('created_by_type'));
5350
}
5451

55-
/** @test */
56-
public function it_can_fill_created_by_id(): void
52+
public function test_it_can_fill_created_by_id(): void
5753
{
5854
$ban = new Ban([
5955
'created_by_id' => '4',
@@ -62,8 +58,7 @@ public function it_can_fill_created_by_id(): void
6258
$this->assertSame('4', $ban->getAttribute('created_by_id'));
6359
}
6460

65-
/** @test */
66-
public function it_casts_expired_at(): void
61+
public function test_it_casts_expired_at(): void
6762
{
6863
$ban = new Ban([
6964
'expired_at' => '2018-03-28 00:00:00',
@@ -72,8 +67,7 @@ public function it_casts_expired_at(): void
7267
$this->assertInstanceOf(Carbon::class, $ban->getAttribute('expired_at'));
7368
}
7469

75-
/** @test */
76-
public function it_casts_deleted_at(): void
70+
public function test_it_casts_deleted_at(): void
7771
{
7872
$ban = Ban::factory()->create([
7973
'deleted_at' => '2018-03-28 00:00:00',
@@ -82,8 +76,7 @@ public function it_casts_deleted_at(): void
8276
$this->assertInstanceOf(Carbon::class, $ban->deleted_at);
8377
}
8478

85-
/** @test */
86-
public function it_not_modify_null_expired_at(): void
79+
public function test_it_not_modify_null_expired_at(): void
8780
{
8881
$ban = new Ban([
8982
'expired_at' => null,
@@ -92,8 +85,7 @@ public function it_not_modify_null_expired_at(): void
9285
$this->assertNull($ban->getAttribute('expired_at'));
9386
}
9487

95-
/** @test */
96-
public function it_can_has_ban_creator(): void
88+
public function test_it_can_has_ban_creator(): void
9789
{
9890
$bannedBy = User::factory()->create();
9991

@@ -105,8 +97,7 @@ public function it_can_has_ban_creator(): void
10597
$this->assertInstanceOf(User::class, $ban->createdBy);
10698
}
10799

108-
/** @test */
109-
public function it_can_set_custom_ban_creator(): void
100+
public function test_it_can_set_custom_ban_creator(): void
110101
{
111102
$bannable = User::factory()->create();
112103
$bannedBy = User::factory()->create();
@@ -119,8 +110,7 @@ public function it_can_set_custom_ban_creator(): void
119110
$this->assertTrue($ban->createdBy->is($bannedBy));
120111
}
121112

122-
/** @test */
123-
public function it_not_overwrite_ban_creator_with_auth_user_if_custom_value_is_provided(): void
113+
public function test_it_not_overwrite_ban_creator_with_auth_user_if_custom_value_is_provided(): void
124114
{
125115
$bannable = User::factory()->create();
126116
$bannedBy = User::factory()->create();
@@ -136,8 +126,7 @@ public function it_not_overwrite_ban_creator_with_auth_user_if_custom_value_is_p
136126
$this->assertTrue($ban->createdBy->is($bannedBy));
137127
}
138128

139-
/** @test */
140-
public function it_can_make_model_with_expire_carbon_date(): void
129+
public function test_it_can_make_model_with_expire_carbon_date(): void
141130
{
142131
$expiredAt = Carbon::now();
143132

@@ -148,8 +137,7 @@ public function it_can_make_model_with_expire_carbon_date(): void
148137
$this->assertEquals($expiredAt, $ban->getAttribute('expired_at'));
149138
}
150139

151-
/** @test */
152-
public function it_can_make_model_with_expire_string_date(): void
140+
public function test_it_can_make_model_with_expire_string_date(): void
153141
{
154142
$ban = new Ban([
155143
'expired_at' => '2086-03-28 00:00:00',
@@ -158,8 +146,7 @@ public function it_can_make_model_with_expire_string_date(): void
158146
$this->assertEquals('2086-03-28 00:00:00', $ban->getAttribute('expired_at'));
159147
}
160148

161-
/** @test */
162-
public function it_can_make_model_with_expire_relative_date(): void
149+
public function test_it_can_make_model_with_expire_relative_date(): void
163150
{
164151
$ban = new Ban([
165152
'expired_at' => '+1 year',
@@ -172,8 +159,7 @@ public function it_can_make_model_with_expire_relative_date(): void
172159
);
173160
}
174161

175-
/** @test */
176-
public function it_can_has_bannable_model(): void
162+
public function test_it_can_has_bannable_model(): void
177163
{
178164
$user = User::factory()->create();
179165

@@ -185,8 +171,7 @@ public function it_can_has_bannable_model(): void
185171
$this->assertInstanceOf(User::class, $ban->bannable);
186172
}
187173

188-
/** @test */
189-
public function it_can_scope_bannable_models(): void
174+
public function test_it_can_scope_bannable_models(): void
190175
{
191176
$user1 = User::factory()->create();
192177
Ban::factory()->count(4)->create([
@@ -204,8 +189,7 @@ public function it_can_scope_bannable_models(): void
204189
$this->assertCount(4, $bannableModels);
205190
}
206191

207-
/** @test */
208-
public function it_can_check_if_ban_is_permanent(): void
192+
public function test_it_can_check_if_ban_is_permanent(): void
209193
{
210194
$permanentBan = new Ban();
211195
$temporaryBan = new Ban([
@@ -216,8 +200,7 @@ public function it_can_check_if_ban_is_permanent(): void
216200
$this->assertFalse($temporaryBan->isPermanent());
217201
}
218202

219-
/** @test */
220-
public function it_can_check_if_ban_is_temporary(): void
203+
public function test_it_can_check_if_ban_is_temporary(): void
221204
{
222205
$permanentBan = new Ban();
223206
$temporaryBan = new Ban([
@@ -228,8 +211,7 @@ public function it_can_check_if_ban_is_temporary(): void
228211
$this->assertTrue($temporaryBan->isTemporary());
229212
}
230213

231-
/** @test */
232-
public function it_can_check_if_ban_with_null_expired_at_is_permanent(): void
214+
public function test_it_can_check_if_ban_with_null_expired_at_is_permanent(): void
233215
{
234216
$permanentBan = new Ban([
235217
'expired_at' => null,

tests/Unit/Observers/BanObserverTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
final class BanObserverTest extends AbstractTestCase
2020
{
21-
/** @test */
22-
public function it_can_set_banned_flag_to_owner_model_on_create(): void
21+
public function test_it_can_set_banned_flag_to_owner_model_on_create(): void
2322
{
2423
$user = User::factory()->create([
2524
'banned_at' => null,

tests/Unit/Scopes/BannedAtScopeTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
final class BannedAtScopeTest extends AbstractTestCase
2222
{
23-
/** @test */
24-
public function it_can_get_all_models_by_default(): void
23+
public function test_it_can_get_all_models_by_default(): void
2524
{
2625
User::factory()->count(2)->create([
2726
'banned_at' => Carbon::now()->subDay(),
@@ -35,8 +34,7 @@ public function it_can_get_all_models_by_default(): void
3534
$this->assertCount(5, $entities);
3635
}
3736

38-
/** @test */
39-
public function it_can_get_models_without_banned(): void
37+
public function test_it_can_get_models_without_banned(): void
4038
{
4139
User::factory()->count(2)->create([
4240
'banned_at' => Carbon::now()->subDay(),
@@ -50,8 +48,7 @@ public function it_can_get_models_without_banned(): void
5048
$this->assertCount(3, $entities);
5149
}
5250

53-
/** @test */
54-
public function it_can_get_models_with_banned(): void
51+
public function test_it_can_get_models_with_banned(): void
5552
{
5653
User::factory()->count(2)->create([
5754
'banned_at' => Carbon::now()->subDay(),
@@ -65,8 +62,7 @@ public function it_can_get_models_with_banned(): void
6562
$this->assertCount(5, $entities);
6663
}
6764

68-
/** @test */
69-
public function it_can_get_only_banned_models(): void
65+
public function test_it_can_get_only_banned_models(): void
7066
{
7167
User::factory()->count(2)->create([
7268
'banned_at' => Carbon::now()->subDay(),
@@ -80,8 +76,7 @@ public function it_can_get_only_banned_models(): void
8076
$this->assertCount(2, $entities);
8177
}
8278

83-
/** @test */
84-
public function it_can_auto_apply_banned_at_default_scope(): void
79+
public function test_it_can_auto_apply_banned_at_default_scope(): void
8580
{
8681
User::factory()->count(3)->create([
8782
'banned_at' => Carbon::now()->subDay(),

tests/Unit/Services/BanServiceTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
final class BanServiceTest extends AbstractTestCase
2222
{
23-
/** @test */
24-
public function it_can_delete_all_expired_bans(): void
23+
public function test_it_can_delete_all_expired_bans(): void
2524
{
2625
Ban::factory()->count(3)->create([
2726
'expired_at' => Carbon::now()->subMonth(),

0 commit comments

Comments
 (0)