diff --git a/tests/Casts/BinaryUuidTest.php b/tests/Casts/BinaryUuidTest.php index 2183c12fa..0d76c6927 100644 --- a/tests/Casts/BinaryUuidTest.php +++ b/tests/Casts/BinaryUuidTest.php @@ -8,6 +8,7 @@ use MongoDB\BSON\Binary; use MongoDB\Laravel\Tests\Models\Casting; use MongoDB\Laravel\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use function hex2bin; @@ -20,7 +21,7 @@ protected function setUp(): void Casting::truncate(); } - /** @dataProvider provideBinaryUuidCast */ + #[DataProvider('provideBinaryUuidCast')] public function testBinaryUuidCastModel(string $expectedUuid, string|Binary $saveUuid, Binary $queryUuid): void { Casting::create(['uuid' => $saveUuid]); diff --git a/tests/Casts/ObjectIdTest.php b/tests/Casts/ObjectIdTest.php index 8d3e9daf4..57201b4eb 100644 --- a/tests/Casts/ObjectIdTest.php +++ b/tests/Casts/ObjectIdTest.php @@ -8,6 +8,7 @@ use MongoDB\BSON\ObjectId; use MongoDB\Laravel\Tests\Models\CastObjectId; use MongoDB\Laravel\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ObjectIdTest extends TestCase { @@ -18,7 +19,7 @@ protected function setUp(): void CastObjectId::truncate(); } - /** @dataProvider provideObjectIdCast */ + #[DataProvider('provideObjectIdCast')] public function testStoreObjectId(string|ObjectId $saveObjectId, ObjectId $queryObjectId): void { $stringObjectId = (string) $saveObjectId; diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 83097973b..586452109 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -14,6 +14,7 @@ use MongoDB\Laravel\Connection; use MongoDB\Laravel\Query\Builder; use MongoDB\Laravel\Schema\Builder as SchemaBuilder; +use PHPUnit\Framework\Attributes\DataProvider; use function env; use function spl_object_hash; @@ -186,7 +187,7 @@ public static function dataConnectionConfig(): Generator ]; } - /** @dataProvider dataConnectionConfig */ + #[DataProvider('dataConnectionConfig')] public function testConnectionConfig(string $expectedUri, string $expectedDatabaseName, array $config): void { $connection = new Connection($config); diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 9d2b58b6e..3c4cbd8df 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -28,6 +28,7 @@ use MongoDB\Laravel\Tests\Models\Soft; use MongoDB\Laravel\Tests\Models\SqlUser; use MongoDB\Laravel\Tests\Models\User; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\TestWith; use function abs; @@ -370,7 +371,7 @@ public function testSoftDelete(): void $this->assertEquals(2, Soft::count()); } - /** @dataProvider provideId */ + #[DataProvider('provideId')] public function testPrimaryKey(string $model, $id, $expected, bool $expectedFound): void { $model::truncate(); @@ -755,7 +756,7 @@ public static function provideDate(): Generator yield 'DateTime date, time and ms before unix epoch' => [new DateTime('1965-08-08 04.08.37.324')]; } - /** @dataProvider provideDate */ + #[DataProvider('provideDate')] public function testDateInputs($date): void { // Test with create and standard property diff --git a/tests/Query/BuilderTest.php b/tests/Query/BuilderTest.php index 4076b3028..3ec933499 100644 --- a/tests/Query/BuilderTest.php +++ b/tests/Query/BuilderTest.php @@ -19,6 +19,7 @@ use MongoDB\Laravel\Query\Builder; use MongoDB\Laravel\Query\Grammar; use MongoDB\Laravel\Query\Processor; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -29,7 +30,7 @@ class BuilderTest extends TestCase { - /** @dataProvider provideQueryBuilderToMql */ + #[DataProvider('provideQueryBuilderToMql')] public function testMql(array $expected, Closure $build): void { $builder = $build(self::getBuilder()); @@ -1298,7 +1299,7 @@ function (Builder $elemMatchQuery): void { } } - /** @dataProvider provideExceptions */ + #[DataProvider('provideExceptions')] public function testException($class, $message, Closure $build): void { $builder = self::getBuilder(); @@ -1396,7 +1397,7 @@ public static function provideExceptions(): iterable ]; } - /** @dataProvider getEloquentMethodsNotSupported */ + #[DataProvider('getEloquentMethodsNotSupported')] public function testEloquentMethodsNotSupported(Closure $callback) { $builder = self::getBuilder(); diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 60645c985..2fd66bf70 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -12,6 +12,7 @@ use MongoDB\Laravel\Tests\Models\Birthday; use MongoDB\Laravel\Tests\Models\Scoped; use MongoDB\Laravel\Tests\Models\User; +use PHPUnit\Framework\Attributes\TestWith; use function str; @@ -662,10 +663,8 @@ public function testDelete(): void $this->assertEquals(0, User::count()); } - /** - * @testWith [0] - * [2] - */ + #[TestWith([0])] + #[TestWith([2])] public function testDeleteException(int $limit): void { $this->expectException(LogicException::class); diff --git a/tests/Seeder/DatabaseSeeder.php b/tests/Seeder/DatabaseSeeder.php index ef512b869..eade44a96 100644 --- a/tests/Seeder/DatabaseSeeder.php +++ b/tests/Seeder/DatabaseSeeder.php @@ -8,12 +8,7 @@ class DatabaseSeeder extends Seeder { - /** - * Run the database seeds. - * - * @return void - */ - public function run() + public function run(): void { $this->call(UserTableSeeder::class); } diff --git a/tests/TestCase.php b/tests/TestCase.php index e2be67a04..5f37ea170 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -21,10 +21,8 @@ class TestCase extends OrchestraTestCase * Get application providers. * * @param Application $app - * - * @return array */ - protected function getApplicationProviders($app) + protected function getApplicationProviders($app): array { $providers = parent::getApplicationProviders($app); @@ -37,10 +35,8 @@ protected function getApplicationProviders($app) * Get package providers. * * @param Application $app - * - * @return array */ - protected function getPackageProviders($app) + protected function getPackageProviders($app): array { return [ MongoDBServiceProvider::class, @@ -54,10 +50,8 @@ protected function getPackageProviders($app) * Define environment setup. * * @param Application $app - * - * @return void */ - protected function getEnvironmentSetUp($app) + protected function getEnvironmentSetUp($app): void { // reset base path to point to our package's src directory //$app['path.base'] = __DIR__ . '/../src';