Skip to content

Commit

Permalink
[10.x] Test Improvements (#48797)
Browse files Browse the repository at this point in the history
* [10.x] Test Improvements

Remove deprecated `@test` usage and always prefix test method name with `test`.

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Apply suggestions from code review

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Oct 24, 2023
1 parent 61ea0bc commit 6350194
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 29 deletions.
9 changes: 3 additions & 6 deletions tests/Database/DatabaseEloquentIrregularPluralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,14 @@ protected function schema()
return $connection->getSchemaBuilder();
}

/** @test */
public function itPluralizesTheTableName()
public function testItPluralizesTheTableName()
{
$model = new IrregularPluralHuman;

$this->assertSame('irregular_plural_humans', $model->getTable());
}

/** @test */
public function itTouchesTheParentWithAnIrregularPlural()
public function testItTouchesTheParentWithAnIrregularPlural()
{
Carbon::setTestNow('2018-05-01 12:13:14');

Expand All @@ -104,8 +102,7 @@ public function itTouchesTheParentWithAnIrregularPlural()
$this->assertSame('2018-05-01 15:16:17', (string) $human->updated_at);
}

/** @test */
public function itPluralizesMorphToManyRelationships()
public function testItPluralizesMorphToManyRelationships()
{
$human = IrregularPluralHuman::create(['email' => '[email protected]']);

Expand Down
2 changes: 0 additions & 2 deletions tests/Foundation/FoundationApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ public function testEnvPathsAreAbsoluteInWindows()
);
}

/** @test */
public function testMacroable(): void
{
$app = new Application;
Expand All @@ -517,7 +516,6 @@ public function testMacroable(): void
$this->assertFalse($app->foo());
}

/** @test */
public function testUseConfigPath(): void
{
$app = new Application;
Expand Down
9 changes: 3 additions & 6 deletions tests/Integration/Auth/ForgotPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ protected function defineRoutes($router)
})->name('custom.password.reset');
}

/** @test */
public function it_can_send_forgot_password_email()
public function testItCanSendForgotPasswordEmail()
{
Notification::fake();

Expand All @@ -67,8 +66,7 @@ function (ResetPassword $notification, $channels) use ($user) {
);
}

/** @test */
public function it_can_send_forgot_password_email_via_create_url_using()
public function testItCanSendForgotPasswordEmailViaCreateUrlUsing()
{
Notification::fake();

Expand All @@ -95,8 +93,7 @@ function (ResetPassword $notification, $channels) use ($user) {
);
}

/** @test */
public function it_can_send_forgot_password_email_via_to_mail_using()
public function testItCanSendForgotPasswordEmailViaToMailUsing()
{
Notification::fake();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ protected function defineRoutes($router)
})->name('custom.password.reset');
}

/** @test */
public function it_cannot_send_forgot_password_email()
public function testItCannotSendForgotPasswordEmail()
{
$this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');
$this->expectExceptionMessage('Route [password.reset] not defined.');
Expand All @@ -66,8 +65,7 @@ function (ResetPassword $notification, $channels) use ($user) {
);
}

/** @test */
public function it_can_send_forgot_password_email_via_create_url_using()
public function testItCanSendForgotPasswordEmailViaCreateUrlUsing()
{
Notification::fake();

Expand All @@ -94,8 +92,7 @@ function (ResetPassword $notification, $channels) use ($user) {
);
}

/** @test */
public function it_can_send_forgot_password_email_via_to_mail_using()
public function testItCanSendForgotPasswordEmailViaToMailUsing()
{
Notification::fake();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ protected function getPackageProviders($app)
return [HeadServiceProvider::class];
}

/** @test */
public function it_can_boot_service_provider_registered_from_another_service_provider()
public function testItCanBootServiceProviderRegisteredFromAnotherServiceProvider()
{
$this->assertTrue($this->app['tail.registered']);
$this->assertTrue($this->app['tail.booted']);
Expand Down
1 change: 0 additions & 1 deletion tests/Integration/Generators/FactoryMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class FactoryMakeCommandTest extends TestCase
'database/factories/FooFactory.php',
];

/** @test */
public function testItCanGenerateFactoryFile()
{
$this->artisan('make:factory', ['name' => 'FooFactory'])
Expand Down
6 changes: 2 additions & 4 deletions tests/Integration/Generators/ResourceMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class ResourceMakeCommandTest extends TestCase
'app/Http/Resources/FooResourceCollection.php',
];

/** @test */
public function it_can_generate_resource_file()
public function testItCanGenerateResourceFile()
{
$this->artisan('make:resource', ['name' => 'FooResource'])
->assertExitCode(0);
Expand All @@ -22,8 +21,7 @@ public function it_can_generate_resource_file()
], 'app/Http/Resources/FooResource.php');
}

/** @test */
public function it_can_generate_resource_collection_file()
public function testItCanGenerateResourceCollectionFile()
{
$this->artisan('make:resource', ['name' => 'FooResourceCollection', '--collection' => true])
->assertExitCode(0);
Expand Down
3 changes: 1 addition & 2 deletions tests/Support/SupportStrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ public function testRandom()
$this->assertIsString(Str::random());
}

/** @test */
public function TestWhetherTheNumberOfGeneratedCharactersIsEquallyDistributed()
public function testWhetherTheNumberOfGeneratedCharactersIsEquallyDistributed()
{
$results = [];
// take 6.200.000 samples, because there are 62 different characters
Expand Down

0 comments on commit 6350194

Please sign in to comment.