From f7535414145e3a524b5d8e7ea94c2ce173b10caa Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 23 Oct 2023 17:48:33 +0800 Subject: [PATCH 01/13] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 4 ++-- tests/Database/DatabaseEloquentIrregularPluralTest.php | 7 ++++--- tests/Filesystem/FilesystemTest.php | 10 ++++------ tests/Foundation/FoundationApplicationTest.php | 2 -- tests/Integration/Auth/ForgotPasswordTest.php | 7 ++++--- .../Auth/ForgotPasswordWithoutDefaultRoutesTest.php | 7 ++++--- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index b4547d815abd..c4810f62af9f 100644 --- a/composer.json +++ b/composer.json @@ -104,10 +104,10 @@ "league/flysystem-read-only": "^3.3", "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "^9.0", + "orchestra/testbench-core": "dev-phpunit11", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", - "phpunit/phpunit": "^10.1", + "phpunit/phpunit": "^11.0", "predis/predis": "^2.0.2", "symfony/cache": "^7.0", "symfony/http-client": "^7.0" diff --git a/tests/Database/DatabaseEloquentIrregularPluralTest.php b/tests/Database/DatabaseEloquentIrregularPluralTest.php index 7d2ce9490b43..95a305c3d529 100644 --- a/tests/Database/DatabaseEloquentIrregularPluralTest.php +++ b/tests/Database/DatabaseEloquentIrregularPluralTest.php @@ -5,6 +5,7 @@ use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Carbon; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class DatabaseEloquentIrregularPluralTest extends TestCase @@ -71,7 +72,7 @@ protected function schema() return $connection->getSchemaBuilder(); } - /** @test */ + #[Test] public function itPluralizesTheTableName() { $model = new IrregularPluralHuman; @@ -79,7 +80,7 @@ public function itPluralizesTheTableName() $this->assertSame('irregular_plural_humans', $model->getTable()); } - /** @test */ + #[Test] public function itTouchesTheParentWithAnIrregularPlural() { Carbon::setTestNow('2018-05-01 12:13:14'); @@ -104,7 +105,7 @@ public function itTouchesTheParentWithAnIrregularPlural() $this->assertSame('2018-05-01 15:16:17', (string) $human->updated_at); } - /** @test */ + #[Test] public function itPluralizesMorphToManyRelationships() { $human = IrregularPluralHuman::create(['email' => 'bobby@example.com']); diff --git a/tests/Filesystem/FilesystemTest.php b/tests/Filesystem/FilesystemTest.php index f9cd9cd239a6..3bad6c52a015 100755 --- a/tests/Filesystem/FilesystemTest.php +++ b/tests/Filesystem/FilesystemTest.php @@ -7,6 +7,8 @@ use Illuminate\Support\LazyCollection; use Illuminate\Testing\Assert; use Mockery as m; +use PHPUnit\Framework\Attributes\AfterClass; +use PHPUnit\Framework\Attributes\BeforeClass; use PHPUnit\Framework\TestCase; use SplFileInfo; @@ -14,18 +16,14 @@ class FilesystemTest extends TestCase { private static $tempDir; - /** - * @beforeClass - */ + #[BeforeClass] public static function setUpTempDir() { self::$tempDir = sys_get_temp_dir().'/tmp'; mkdir(self::$tempDir); } - /** - * @afterClass - */ + #[AfterClass] public static function tearDownTempDir() { $files = new Filesystem; diff --git a/tests/Foundation/FoundationApplicationTest.php b/tests/Foundation/FoundationApplicationTest.php index 8f1ce849d6a8..f23dc801f33d 100755 --- a/tests/Foundation/FoundationApplicationTest.php +++ b/tests/Foundation/FoundationApplicationTest.php @@ -500,7 +500,6 @@ public function testEnvPathsAreAbsoluteInWindows() ); } - /** @test */ public function testMacroable(): void { $app = new Application; @@ -517,7 +516,6 @@ public function testMacroable(): void $this->assertFalse($app->foo()); } - /** @test */ public function testUseConfigPath(): void { $app = new Application; diff --git a/tests/Integration/Auth/ForgotPasswordTest.php b/tests/Integration/Auth/ForgotPasswordTest.php index 94766105ae78..576271619897 100644 --- a/tests/Integration/Auth/ForgotPasswordTest.php +++ b/tests/Integration/Auth/ForgotPasswordTest.php @@ -10,6 +10,7 @@ use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser; use Orchestra\Testbench\Factories\UserFactory; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class ForgotPasswordTest extends TestCase { @@ -43,7 +44,7 @@ protected function defineRoutes($router) })->name('custom.password.reset'); } - /** @test */ + #[Test] public function it_can_send_forgot_password_email() { Notification::fake(); @@ -67,7 +68,7 @@ function (ResetPassword $notification, $channels) use ($user) { ); } - /** @test */ + #[Test] public function it_can_send_forgot_password_email_via_create_url_using() { Notification::fake(); @@ -95,7 +96,7 @@ function (ResetPassword $notification, $channels) use ($user) { ); } - /** @test */ + #[Test] public function it_can_send_forgot_password_email_via_to_mail_using() { Notification::fake(); diff --git a/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php b/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php index 221601ac76f6..af2969915d9c 100644 --- a/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php +++ b/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php @@ -10,6 +10,7 @@ use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser; use Orchestra\Testbench\Factories\UserFactory; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class ForgotPasswordWithoutDefaultRoutesTest extends TestCase { @@ -39,7 +40,7 @@ protected function defineRoutes($router) })->name('custom.password.reset'); } - /** @test */ + #[Test] public function it_cannot_send_forgot_password_email() { $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException'); @@ -66,7 +67,7 @@ function (ResetPassword $notification, $channels) use ($user) { ); } - /** @test */ + #[Test] public function it_can_send_forgot_password_email_via_create_url_using() { Notification::fake(); @@ -94,7 +95,7 @@ function (ResetPassword $notification, $channels) use ($user) { ); } - /** @test */ + #[Test] public function it_can_send_forgot_password_email_via_to_mail_using() { Notification::fake(); From d47662abcc50a96cc2316948e8ec82b216fb2da1 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 23 Oct 2023 20:17:53 +0800 Subject: [PATCH 02/13] wip Signed-off-by: Mior Muhammad Zaki --- tests/Auth/AuthAccessGateTest.php | 8 +- tests/Broadcasting/BroadcasterTest.php | 5 +- .../UsePusherChannelsNamesTest.php | 9 +- tests/Bus/BusBatchTest.php | 7 +- tests/Cache/CacheMemcachedConnectorTest.php | 9 +- tests/Cache/CacheMemcachedStoreTest.php | 5 +- tests/Cache/CacheRepositoryTest.php | 4 +- tests/Cache/RedisCacheIntegrationTest.php | 10 +- tests/Console/Scheduling/EventTest.php | 17 +- tests/Database/DatabaseConnectorTest.php | 13 +- .../Database/DatabaseMySqlSchemaStateTest.php | 5 +- tests/Encryption/EncrypterTest.php | 5 +- tests/Filesystem/FilesystemAdapterTest.php | 5 +- tests/Filesystem/FilesystemManagerTest.php | 5 +- tests/Filesystem/FilesystemTest.php | 16 +- tests/Hashing/HasherTest.php | 13 +- tests/Http/HttpJsonResponseTest.php | 13 +- tests/Http/HttpRequestTest.php | 13 +- tests/Http/HttpTestingFileFactoryTest.php | 7 +- .../ApiAuthenticationWithEloquentTest.php | 5 +- .../Cache/MemcachedCacheLockTestCase.php | 5 +- .../Cache/MemcachedTaggedCacheTestCase.php | 5 +- .../Cache/PhpRedisCacheLockTest.php | 17 +- tests/Integration/Cache/Psr6RedisTest.php | 5 +- .../Integration/Console/CommandEventsTest.php | 5 +- .../Console/CommandSchedulingTest.php | 5 +- .../Scheduling/SubMinuteSchedulingTest.php | 3 +- .../EloquentModelCustomCastingTest.php | 23 +- .../Database/EloquentWhereHasTest.php | 7 +- ...baseEmulatePreparesMySqlConnectionTest.php | 8 +- .../MySql/DatabaseMySqlConnectionTest.php | 25 +- ...SqlSchemaBuilderAlterTableWithEnumTest.php | 8 +- .../MySql/DatabaseMySqlSchemaBuilderTest.php | 8 +- .../Integration/Database/MySql/EscapeTest.php | 8 +- .../Database/MySql/FulltextTest.php | 8 +- .../DatabasePostgresConnectionTest.php | 21 +- .../Database/Postgres/EscapeTest.php | 8 +- .../Database/Postgres/FulltextTest.php | 8 +- .../Postgres/PostgresSchemaBuilderTest.php | 8 +- .../DatabaseSqlServerConnectionTest.php | 13 +- .../Sqlite/DatabaseSqliteConnectionTest.php | 5 +- .../Integration/Filesystem/FilesystemTest.php | 5 +- tests/Integration/Filesystem/StorageTest.php | 5 +- .../Foundation/ExceptionHandlerTest.php | 5 +- .../FoundationServiceProvidersTest.php | 3 +- .../Generators/FactoryMakeCommandTest.php | 1 - .../Generators/ResourceMakeCommandTest.php | 6 +- tests/Integration/Queue/CustomPayloadTest.php | 5 +- .../Integration/Routing/RouteRedirectTest.php | 5 +- tests/Mail/MailManagerTest.php | 5 +- tests/Queue/QueueDatabaseQueueUnitTest.php | 5 +- tests/Queue/RedisQueueIntegrationTest.php | 56 +- tests/Routing/RouteUriTest.php | 5 +- tests/Routing/RoutingUrlGeneratorTest.php | 9 +- tests/Support/ConfigurationUrlParserTest.php | 5 +- tests/Support/SupportCollectionTest.php | 1219 +++++------------ tests/Support/SupportHelpersTest.php | 7 +- tests/Support/SupportStrTest.php | 28 +- tests/Testing/Concerns/TestDatabasesTest.php | 5 +- tests/Testing/ParallelTestingTest.php | 5 +- .../TranslationMessageSelectorTest.php | 5 +- tests/Validation/ValidationValidatorTest.php | 49 +- tests/View/Blade/BladeEchoHandlerTest.php | 9 +- .../View/Blade/BladeForeachStatementsTest.php | 5 +- .../View/Blade/BladeForelseStatementsTest.php | 5 +- tests/View/ViewBladeCompilerTest.php | 4 +- tests/View/ViewFileViewFinderTest.php | 5 +- 67 files changed, 543 insertions(+), 1300 deletions(-) diff --git a/tests/Auth/AuthAccessGateTest.php b/tests/Auth/AuthAccessGateTest.php index c6ed6c2cbcc4..3f143f1651e5 100644 --- a/tests/Auth/AuthAccessGateTest.php +++ b/tests/Auth/AuthAccessGateTest.php @@ -8,6 +8,7 @@ use Illuminate\Auth\Access\Response; use Illuminate\Container\Container; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; @@ -555,9 +556,7 @@ public function testForUserMethodAttachesANewUserToANewGateInstanceWithGuessCall $this->assertSame(3, $counter); } - /** - * @dataProvider notCallableDataProvider - */ + #[DataProvider('notCallableDataProvider')] public function testDefineSecondParameterShouldBeStringOrCallable($callback) { $this->expectException(InvalidArgumentException::class); @@ -1036,12 +1035,11 @@ public function testEveryAbilityCheckFailsIfNonePass() } /** - * @dataProvider hasAbilitiesTestDataProvider - * * @param array $abilitiesToSet * @param array|string $abilitiesToCheck * @param bool $expectedHasValue */ + #[DataProvider('hasAbilitiesTestDataProvider')] public function testHasAbilities($abilitiesToSet, $abilitiesToCheck, $expectedHasValue) { $gate = $this->getBasicGate(); diff --git a/tests/Broadcasting/BroadcasterTest.php b/tests/Broadcasting/BroadcasterTest.php index d19ecfdc186a..eca82ca9754d 100644 --- a/tests/Broadcasting/BroadcasterTest.php +++ b/tests/Broadcasting/BroadcasterTest.php @@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -314,9 +315,7 @@ public function testUserAuthenticationWithoutResolve() $this->assertNull($this->broadcaster->resolveAuthenticatedUser(new Request(['socket_id' => '1234.1234']))); } - /** - * @dataProvider channelNameMatchPatternProvider - */ + #[DataProvider('channelNameMatchPatternProvider')] public function testChannelNameMatchPattern($channel, $pattern, $shouldMatch) { $this->assertEquals($shouldMatch, $this->broadcaster->channelNameMatchesPattern($channel, $pattern)); diff --git a/tests/Broadcasting/UsePusherChannelsNamesTest.php b/tests/Broadcasting/UsePusherChannelsNamesTest.php index c2b87d57026b..122e83e8c3f4 100644 --- a/tests/Broadcasting/UsePusherChannelsNamesTest.php +++ b/tests/Broadcasting/UsePusherChannelsNamesTest.php @@ -4,13 +4,12 @@ use Illuminate\Broadcasting\Broadcasters\Broadcaster; use Illuminate\Broadcasting\Broadcasters\UsePusherChannelConventions; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class UsePusherChannelsNamesTest extends TestCase { - /** - * @dataProvider channelsProvider - */ + #[DataProvider('channelsProvider')] public function testChannelNameNormalization($requestChannelName, $normalizedName) { $broadcaster = new FakeBroadcasterUsingPusherChannelsNames; @@ -31,9 +30,7 @@ public function testChannelNameNormalizationSpecialCase() ); } - /** - * @dataProvider channelsProvider - */ + #[DataProvider('channelsProvider')] public function testIsGuardedChannel($requestChannelName, $_, $guarded) { $broadcaster = new FakeBroadcasterUsingPusherChannelsNames; diff --git a/tests/Bus/BusBatchTest.php b/tests/Bus/BusBatchTest.php index 49c394611185..9599e175f060 100644 --- a/tests/Bus/BusBatchTest.php +++ b/tests/Bus/BusBatchTest.php @@ -4,8 +4,8 @@ use Carbon\CarbonImmutable; use Illuminate\Bus\Batch; -use Illuminate\Bus\Batchable; use Illuminate\Bus\BatchFactory; +use Illuminate\Bus\Batchable; use Illuminate\Bus\DatabaseBatchRepository; use Illuminate\Bus\PendingBatch; use Illuminate\Bus\Queueable; @@ -19,6 +19,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\CallQueuedClosure; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use RuntimeException; use stdClass; @@ -414,9 +415,7 @@ public function test_options_serialization_on_postgres() $builder->shouldHaveReceived('first'); } - /** - * @dataProvider serializedOptions - */ + #[DataProvider('serializedOptions')] public function test_options_unserialize_on_postgres($serialize, $options) { $factory = m::mock(BatchFactory::class); diff --git a/tests/Cache/CacheMemcachedConnectorTest.php b/tests/Cache/CacheMemcachedConnectorTest.php index 402b210b0dbe..f853afa2ee78 100755 --- a/tests/Cache/CacheMemcachedConnectorTest.php +++ b/tests/Cache/CacheMemcachedConnectorTest.php @@ -5,6 +5,7 @@ use Illuminate\Cache\MemcachedConnector; use Memcached; use Mockery as m; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use stdClass; @@ -48,9 +49,7 @@ public function testServersAreAddedCorrectlyWithPersistentConnection() $this->assertSame($result, $memcached); } - /** - * @requires extension memcached - */ + #[RequiresPhpExtension('memcached')] public function testServersAreAddedCorrectlyWithValidOptions() { $validOptions = [ @@ -71,9 +70,7 @@ public function testServersAreAddedCorrectlyWithValidOptions() $this->assertSame($result, $memcached); } - /** - * @requires extension memcached - */ + #[RequiresPhpExtension('memcached')] public function testServersAreAddedCorrectlyWithSaslCredentials() { $saslCredentials = ['foo', 'bar']; diff --git a/tests/Cache/CacheMemcachedStoreTest.php b/tests/Cache/CacheMemcachedStoreTest.php index a61af86e16f2..e477ac7f3f09 100755 --- a/tests/Cache/CacheMemcachedStoreTest.php +++ b/tests/Cache/CacheMemcachedStoreTest.php @@ -6,12 +6,11 @@ use Illuminate\Support\Carbon; use Memcached; use Mockery as m; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use stdClass; -/** - * @requires extension memcached - */ +#[RequiresPhpExtension('memcached')] class CacheMemcachedStoreTest extends TestCase { protected function tearDown(): void diff --git a/tests/Cache/CacheRepositoryTest.php b/tests/Cache/CacheRepositoryTest.php index 56f70c58edd4..5c4b77ce070f 100755 --- a/tests/Cache/CacheRepositoryTest.php +++ b/tests/Cache/CacheRepositoryTest.php @@ -19,6 +19,7 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Carbon; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class CacheRepositoryTest extends TestCase @@ -280,10 +281,9 @@ public static function dataProviderTestGetSeconds() } /** - * @dataProvider dataProviderTestGetSeconds - * * @param mixed $duration */ + #[DataProvider('dataProviderTestGetSeconds')] public function testGetSeconds($duration) { $repo = $this->getRepository(); diff --git a/tests/Cache/RedisCacheIntegrationTest.php b/tests/Cache/RedisCacheIntegrationTest.php index 410a02c6f82a..ff99dd0bfd81 100644 --- a/tests/Cache/RedisCacheIntegrationTest.php +++ b/tests/Cache/RedisCacheIntegrationTest.php @@ -5,6 +5,7 @@ use Illuminate\Cache\RedisStore; use Illuminate\Cache\Repository; use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RedisCacheIntegrationTest extends TestCase @@ -24,10 +25,9 @@ protected function tearDown(): void } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testRedisCacheAddTwice($driver) { $store = new RedisStore($this->redis[$driver]); @@ -40,10 +40,9 @@ public function testRedisCacheAddTwice($driver) /** * Breaking change. * - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testRedisCacheAddFalse($driver) { $store = new RedisStore($this->redis[$driver]); @@ -56,10 +55,9 @@ public function testRedisCacheAddFalse($driver) /** * Breaking change. * - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testRedisCacheAddNull($driver) { $store = new RedisStore($this->redis[$driver]); diff --git a/tests/Console/Scheduling/EventTest.php b/tests/Console/Scheduling/EventTest.php index 8d7883b9cb35..4cc6c02d0f5a 100644 --- a/tests/Console/Scheduling/EventTest.php +++ b/tests/Console/Scheduling/EventTest.php @@ -6,6 +6,7 @@ use Illuminate\Console\Scheduling\EventMutex; use Illuminate\Support\Str; use Mockery as m; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use PHPUnit\Framework\TestCase; class EventTest extends TestCase @@ -17,9 +18,7 @@ protected function tearDown(): void parent::tearDown(); } - /** - * @requires OS Linux|Darwin - */ + #[RequiresOperatingSystem('Linux|Darwin')] public function testBuildCommandUsingUnix() { $event = new Event(m::mock(EventMutex::class), 'php -i'); @@ -27,9 +26,7 @@ public function testBuildCommandUsingUnix() $this->assertSame("php -i > '/dev/null' 2>&1", $event->buildCommand()); } - /** - * @requires OS Windows - */ + #[RequiresOperatingSystem('Windows')] public function testBuildCommandUsingWindows() { $event = new Event(m::mock(EventMutex::class), 'php -i'); @@ -37,9 +34,7 @@ public function testBuildCommandUsingWindows() $this->assertSame('php -i > "NUL" 2>&1', $event->buildCommand()); } - /** - * @requires OS Linux|Darwin - */ + #[RequiresOperatingSystem('Linux|Darwin')] public function testBuildCommandInBackgroundUsingUnix() { $event = new Event(m::mock(EventMutex::class), 'php -i'); @@ -50,9 +45,7 @@ public function testBuildCommandInBackgroundUsingUnix() $this->assertSame("(php -i > '/dev/null' 2>&1 ; '".PHP_BINARY."' 'artisan' schedule:finish {$scheduleId} \"$?\") > '/dev/null' 2>&1 &", $event->buildCommand()); } - /** - * @requires OS Windows - */ + #[RequiresOperatingSystem('Windows')] public function testBuildCommandInBackgroundUsingWindows() { $event = new Event(m::mock(EventMutex::class), 'php -i'); diff --git a/tests/Database/DatabaseConnectorTest.php b/tests/Database/DatabaseConnectorTest.php index 79ee6d0606c4..7ada98829e8a 100755 --- a/tests/Database/DatabaseConnectorTest.php +++ b/tests/Database/DatabaseConnectorTest.php @@ -10,6 +10,8 @@ use Mockery as m; use PDO; use PDOStatement; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use stdClass; @@ -27,9 +29,7 @@ public function testOptionResolution() $this->assertEquals([0 => 'baz', 1 => 'bar', 2 => 'boom'], $connector->getOptions(['options' => [0 => 'baz', 2 => 'boom']])); } - /** - * @dataProvider mySqlConnectProvider - */ + #[DataProvider('mySqlConnectProvider')] public function testMySqlConnectCallsCreateConnectionWithProperArguments($dsn, $config) { $connector = $this->getMockBuilder(MySqlConnector::class)->onlyMethods(['createConnection', 'getOptions'])->getMock(); @@ -90,11 +90,10 @@ public function testPostgresConnectCallsCreateConnectionWithProperArguments() } /** - * @dataProvider provideSearchPaths - * * @param string $searchPath * @param string $expectedSql */ + #[DataProvider('provideSearchPaths')] public function testPostgresSearchPathIsSet($searchPath, $expectedSql) { $dsn = 'pgsql:host=foo;dbname=\'bar\''; @@ -317,9 +316,7 @@ public function testSqlServerConnectCallsCreateConnectionWithOptionalArguments() $this->assertSame($result, $connection); } - /** - * @requires extension odbc - */ + #[RequiresPhpExtension('odbc')] public function testSqlServerConnectCallsCreateConnectionWithPreferredODBC() { $config = ['odbc' => true, 'odbc_datasource_name' => 'server=localhost;database=test;']; diff --git a/tests/Database/DatabaseMySqlSchemaStateTest.php b/tests/Database/DatabaseMySqlSchemaStateTest.php index 63a7107e7caa..0468a0d501d5 100644 --- a/tests/Database/DatabaseMySqlSchemaStateTest.php +++ b/tests/Database/DatabaseMySqlSchemaStateTest.php @@ -5,14 +5,13 @@ use Generator; use Illuminate\Database\MySqlConnection; use Illuminate\Database\Schema\MySqlSchemaState; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionMethod; class DatabaseMySqlSchemaStateTest extends TestCase { - /** - * @dataProvider provider - */ + #[DataProvider('provider')] public function testConnectionString(string $expectedConnectionString, array $expectedVariables, array $dbConfig): void { $connection = $this->createMock(MySqlConnection::class); diff --git a/tests/Encryption/EncrypterTest.php b/tests/Encryption/EncrypterTest.php index c6a0f1d28143..64f2e9d39502 100755 --- a/tests/Encryption/EncrypterTest.php +++ b/tests/Encryption/EncrypterTest.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Encryption\Encrypter; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use RuntimeException; @@ -221,9 +222,7 @@ public static function provideTamperedData() ]; } - /** - * @dataProvider provideTamperedData - */ + #[DataProvider('provideTamperedData')] public function testTamperedPayloadWillGetRejected($payload) { $this->expectException(DecryptException::class); diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php index d6cc99c64dcd..3d509e0c7745 100644 --- a/tests/Filesystem/FilesystemAdapterTest.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -17,6 +17,7 @@ use League\Flysystem\UnableToRetrieveMetadata; use League\Flysystem\UnableToWriteFile; use Mockery as m; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -426,9 +427,7 @@ public function testPutFileWithoutPath() $this->assertSame('normal file content', $filesystemAdapter->read($storagePath)); } - /** - * @requires extension ftp - */ + #[RequiresPhpExtension('ftp')] public function testCreateFtpDriver() { $filesystem = new FilesystemManager(new Application); diff --git a/tests/Filesystem/FilesystemManagerTest.php b/tests/Filesystem/FilesystemManagerTest.php index ef1eb632f92a..8850c5557a06 100644 --- a/tests/Filesystem/FilesystemManagerTest.php +++ b/tests/Filesystem/FilesystemManagerTest.php @@ -6,6 +6,7 @@ use Illuminate\Filesystem\FilesystemManager; use Illuminate\Foundation\Application; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use PHPUnit\Framework\TestCase; class FilesystemManagerTest extends TestCase @@ -98,9 +99,7 @@ public function testCanBuildScopedDisks() } } - /** - * @requires OS Linux|Darwin - */ + #[RequiresOperatingSystem('Linux|Darwin')] public function testCanBuildScopedDisksWithVisibility() { try { diff --git a/tests/Filesystem/FilesystemTest.php b/tests/Filesystem/FilesystemTest.php index 3bad6c52a015..54fc3b0b2bc2 100755 --- a/tests/Filesystem/FilesystemTest.php +++ b/tests/Filesystem/FilesystemTest.php @@ -9,6 +9,8 @@ use Mockery as m; use PHPUnit\Framework\Attributes\AfterClass; use PHPUnit\Framework\Attributes\BeforeClass; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use SplFileInfo; @@ -95,9 +97,7 @@ public function testReplaceInFileCorrectlyReplaces() $this->assertStringEqualsFile($tempFile, 'Hello Taylor'); } - /** - * @requires OS Linux|Darwin - */ + #[RequiresOperatingSystem('Linux|Darwin')] public function testReplaceWhenUnixSymlinkExists() { $tempFile = self::$tempDir.'/file.txt'; @@ -426,9 +426,7 @@ public function testSizeOutputsSize() $this->assertEquals($size, $files->size(self::$tempDir.'/foo.txt')); } - /** - * @requires extension fileinfo - */ + #[RequiresPhpExtension('fileinfo')] public function testMimeTypeOutputsMimeType() { file_put_contents(self::$tempDir.'/foo.txt', 'foo'); @@ -525,10 +523,8 @@ public function testMakeDirectory() $this->assertFileExists(self::$tempDir.'/created'); } - /** - * @requires extension pcntl - * @requires OS Linux|Darwin - */ + #[RequiresOperatingSystem('Linux|Darwin')] + #[RequiresPhpExtension('pcntl')] public function testSharedGet() { $content = str_repeat('123456', 1000000); diff --git a/tests/Hashing/HasherTest.php b/tests/Hashing/HasherTest.php index 3559cc0303d3..70c6c3d175b0 100755 --- a/tests/Hashing/HasherTest.php +++ b/tests/Hashing/HasherTest.php @@ -8,6 +8,7 @@ use Illuminate\Hashing\ArgonHasher; use Illuminate\Hashing\BcryptHasher; use Illuminate\Hashing\HashManager; +use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use RuntimeException; @@ -82,9 +83,7 @@ public function testBasicArgon2idHashing() $this->assertTrue($this->hashManager->isHashed($value)); } - /** - * @depends testBasicBcryptHashing - */ + #[Depends('testBasicBcryptHashing')] public function testBasicBcryptVerification() { $this->expectException(RuntimeException::class); @@ -94,9 +93,7 @@ public function testBasicBcryptVerification() (new BcryptHasher(['verify' => true]))->check('password', $argonHashed); } - /** - * @depends testBasicArgon2iHashing - */ + #[Depends('testBasicArgon2iHashing')] public function testBasicArgon2iVerification() { $this->expectException(RuntimeException::class); @@ -106,9 +103,7 @@ public function testBasicArgon2iVerification() (new ArgonHasher(['verify' => true]))->check('password', $bcryptHashed); } - /** - * @depends testBasicArgon2idHashing - */ + #[Depends('testBasicArgon2idHashing')] public function testBasicArgon2idVerification() { $this->expectException(RuntimeException::class); diff --git a/tests/Http/HttpJsonResponseTest.php b/tests/Http/HttpJsonResponseTest.php index 48b5aef73267..a2b296da59b7 100644 --- a/tests/Http/HttpJsonResponseTest.php +++ b/tests/Http/HttpJsonResponseTest.php @@ -7,14 +7,13 @@ use Illuminate\Http\JsonResponse; use InvalidArgumentException; use JsonSerializable; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; class HttpJsonResponseTest extends TestCase { - /** - * @dataProvider setAndRetrieveDataProvider - */ + #[DataProvider('setAndRetrieveDataProvider')] public function testSetAndRetrieveData($data) { $response = new JsonResponse($data); @@ -67,9 +66,7 @@ public function testSetAndRetrieveStatusCode() $this->assertSame(404, $response->getStatusCode()); } - /** - * @dataProvider jsonErrorDataProvider - */ + #[DataProvider('jsonErrorDataProvider')] public function testInvalidArgumentExceptionOnJsonError($data) { $this->expectException(InvalidArgumentException::class); @@ -77,9 +74,7 @@ public function testInvalidArgumentExceptionOnJsonError($data) new JsonResponse(['data' => $data]); } - /** - * @dataProvider jsonErrorDataProvider - */ + #[DataProvider('jsonErrorDataProvider')] public function testGracefullyHandledSomeJsonErrorsWithPartialOutputOnError($data) { new JsonResponse(['data' => $data], 200, [], JSON_PARTIAL_OUTPUT_ON_ERROR); diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index 124f0bdbd33a..10db3c4701a5 100644 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -12,6 +12,7 @@ use Illuminate\Tests\Database\Fixtures\Models\Money\Price; use InvalidArgumentException; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use RuntimeException; use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException; @@ -80,9 +81,7 @@ public function testDecodedPathMethod() $this->assertSame('foo bar', $request->decodedPath()); } - /** - * @dataProvider segmentProvider - */ + #[DataProvider('segmentProvider')] public function testSegmentMethod($path, $segment, $expected) { $request = Request::create($path); @@ -99,9 +98,7 @@ public static function segmentProvider() ]; } - /** - * @dataProvider segmentsProvider - */ + #[DataProvider('segmentsProvider')] public function testSegmentsMethod($path, $expected) { $request = Request::create($path); @@ -1068,9 +1065,7 @@ public static function getPrefersCases() ]; } - /** - * @dataProvider getPrefersCases - */ + #[DataProvider('getPrefersCases')] public function testPrefersMethod($accept, $prefers, $expected) { $this->assertSame( diff --git a/tests/Http/HttpTestingFileFactoryTest.php b/tests/Http/HttpTestingFileFactoryTest.php index c2824b6fe327..5ee649cce689 100644 --- a/tests/Http/HttpTestingFileFactoryTest.php +++ b/tests/Http/HttpTestingFileFactoryTest.php @@ -3,13 +3,14 @@ namespace Illuminate\Tests\Http; use Illuminate\Http\Testing\FileFactory; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; /** - * @requires extension gd - * * @link https://www.php.net/manual/en/function.gd-info.php */ +#[RequiresPhpExtension('gd')] class HttpTestingFileFactoryTest extends TestCase { public function testImagePng() @@ -118,7 +119,7 @@ public function testCreateWithoutMimeType() ); } - /** @dataProvider generateImageDataProvider */ + #[DataProvider('generateImageDataProvider')] public function testCallingCreateWithoutGDLoadedThrowsAnException(string $fileExtension, string $driver) { if ($this->isGDSupported($driver)) { diff --git a/tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php b/tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php index c5fc77aec88d..df78219bb62a 100644 --- a/tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php +++ b/tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php @@ -7,10 +7,9 @@ use Illuminate\Support\Facades\Route; use Illuminate\Support\Str; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - */ +#[RequiresPhpExtension('pdo_mysql')] class ApiAuthenticationWithEloquentTest extends TestCase { protected function getEnvironmentSetUp($app) diff --git a/tests/Integration/Cache/MemcachedCacheLockTestCase.php b/tests/Integration/Cache/MemcachedCacheLockTestCase.php index 7f3e93f8c7c0..706bb8b3ae37 100644 --- a/tests/Integration/Cache/MemcachedCacheLockTestCase.php +++ b/tests/Integration/Cache/MemcachedCacheLockTestCase.php @@ -4,10 +4,9 @@ use Illuminate\Contracts\Cache\LockTimeoutException; use Illuminate\Support\Facades\Cache; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension memcached - */ +#[RequiresPhpExtension('memcached')] class MemcachedCacheLockTestCase extends MemcachedIntegrationTestCase { public function testMemcachedLocksCanBeAcquiredAndReleased() diff --git a/tests/Integration/Cache/MemcachedTaggedCacheTestCase.php b/tests/Integration/Cache/MemcachedTaggedCacheTestCase.php index 4aab9422a8fd..ee7787aa407e 100644 --- a/tests/Integration/Cache/MemcachedTaggedCacheTestCase.php +++ b/tests/Integration/Cache/MemcachedTaggedCacheTestCase.php @@ -3,10 +3,9 @@ namespace Illuminate\Tests\Integration\Cache; use Illuminate\Support\Facades\Cache; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension memcached - */ +#[RequiresPhpExtension('memcached')] class MemcachedTaggedCacheTestCase extends MemcachedIntegrationTestCase { public function testMemcachedCanStoreAndRetrieveTaggedCacheItems() diff --git a/tests/Integration/Cache/PhpRedisCacheLockTest.php b/tests/Integration/Cache/PhpRedisCacheLockTest.php index 0ca4ea85f960..fe40f2ac3fe3 100644 --- a/tests/Integration/Cache/PhpRedisCacheLockTest.php +++ b/tests/Integration/Cache/PhpRedisCacheLockTest.php @@ -5,6 +5,7 @@ use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; use Illuminate\Support\Facades\Cache; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Redis; class PhpRedisCacheLockTest extends TestCase @@ -138,9 +139,7 @@ public function testRedisLockCanBeAcquiredAndReleasedWithMsgpackSerialization() $this->assertNull($store->lockConnection()->get($store->getPrefix().'foo')); } - /** - * @requires extension lzf - */ + #[RequiresPhpExtension('lzf')] public function testRedisLockCanBeAcquiredAndReleasedWithLzfCompression() { if (! defined('Redis::COMPRESSION_LZF')) { @@ -167,9 +166,7 @@ public function testRedisLockCanBeAcquiredAndReleasedWithLzfCompression() $this->assertNull($store->lockConnection()->get($store->getPrefix().'foo')); } - /** - * @requires extension zstd - */ + #[RequiresPhpExtension('zstd')] public function testRedisLockCanBeAcquiredAndReleasedWithZstdCompression() { if (! defined('Redis::COMPRESSION_ZSTD')) { @@ -215,9 +212,7 @@ public function testRedisLockCanBeAcquiredAndReleasedWithZstdCompression() $this->assertNull($store->lockConnection()->get($store->getPrefix().'foo')); } - /** - * @requires extension lz4 - */ + #[RequiresPhpExtension('lz4')] public function testRedisLockCanBeAcquiredAndReleasedWithLz4Compression() { if (! defined('Redis::COMPRESSION_LZ4')) { @@ -263,9 +258,7 @@ public function testRedisLockCanBeAcquiredAndReleasedWithLz4Compression() $this->assertNull($store->lockConnection()->get($store->getPrefix().'foo')); } - /** - * @requires extension Lzf - */ + #[RequiresPhpExtension('lzf')] public function testRedisLockCanBeAcquiredAndReleasedWithSerializationAndCompression() { if (! defined('Redis::COMPRESSION_LZF')) { diff --git a/tests/Integration/Cache/Psr6RedisTest.php b/tests/Integration/Cache/Psr6RedisTest.php index a242a2f77e29..062d5ec4dbfb 100644 --- a/tests/Integration/Cache/Psr6RedisTest.php +++ b/tests/Integration/Cache/Psr6RedisTest.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Cache; use Illuminate\Tests\Integration\Cache\Fixtures\Unserializable; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class Psr6RedisTest extends TestCase { @@ -25,9 +26,7 @@ protected function tearDown(): void $this->tearDownRedis(); } - /** - * @dataProvider redisClientDataProvider - */ + #[DataProvider('redisClientDataProvider')] public function testTransactionIsNotOpenedWhenSerializationFails($redisClient): void { $this->app['config']['cache.default'] = 'redis'; diff --git a/tests/Integration/Console/CommandEventsTest.php b/tests/Integration/Console/CommandEventsTest.php index 167835eb9b7f..cc63e22dc4fc 100644 --- a/tests/Integration/Console/CommandEventsTest.php +++ b/tests/Integration/Console/CommandEventsTest.php @@ -12,6 +12,7 @@ use Illuminate\Support\Str; use Orchestra\Testbench\Foundation\Application as Testbench; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class CommandEventsTest extends TestCase { @@ -48,9 +49,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @dataProvider foregroundCommandEventsProvider - */ + #[DataProvider('foregroundCommandEventsProvider')] public function testCommandEventsReceiveParsedInput($callback) { $this->app[ConsoleKernel::class]->registerCommand(new CommandEventsTestCommand); diff --git a/tests/Integration/Console/CommandSchedulingTest.php b/tests/Integration/Console/CommandSchedulingTest.php index 1e02c3b3d2fa..1a4c918aa5e0 100644 --- a/tests/Integration/Console/CommandSchedulingTest.php +++ b/tests/Integration/Console/CommandSchedulingTest.php @@ -6,6 +6,7 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class CommandSchedulingTest extends TestCase { @@ -62,9 +63,7 @@ protected function tearDown(): void parent::tearDown(); } - /** - * @dataProvider executionProvider - */ + #[DataProvider('executionProvider')] public function testExecutionOrder($background, $expected) { $schedule = $this->app->make(Schedule::class); diff --git a/tests/Integration/Console/Scheduling/SubMinuteSchedulingTest.php b/tests/Integration/Console/Scheduling/SubMinuteSchedulingTest.php index bc7b98d5b1b4..f40626a9dbe5 100644 --- a/tests/Integration/Console/Scheduling/SubMinuteSchedulingTest.php +++ b/tests/Integration/Console/Scheduling/SubMinuteSchedulingTest.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\Sleep; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SubMinuteSchedulingTest extends TestCase { @@ -45,7 +46,7 @@ public function test_it_doesnt_wait_for_sub_minute_events_when_none_are_schedule Sleep::assertNeverSlept(); } - /** @dataProvider frequencyProvider */ + #[DataProvider('frequencyProvider')] public function test_it_runs_sub_minute_callbacks($frequency, $expectedRuns) { $runs = 0; diff --git a/tests/Integration/Database/EloquentModelCustomCastingTest.php b/tests/Integration/Database/EloquentModelCustomCastingTest.php index b27149129fd1..3c7ade235a56 100644 --- a/tests/Integration/Database/EloquentModelCustomCastingTest.php +++ b/tests/Integration/Database/EloquentModelCustomCastingTest.php @@ -8,15 +8,14 @@ use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Contracts\Database\Eloquent\SerializesCastableAttributes; use Illuminate\Database\Capsule\Manager as DB; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model as Eloquent; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; -/** - * @group integration - */ +#[Group('integration')] class EloquentModelCustomCastingTest extends TestCase { protected function setUp(): void @@ -67,9 +66,7 @@ protected function tearDown(): void $this->schema()->drop('members'); } - /** - * @requires extension gmp - */ + #[RequiresPhpExtension('gmp')] public function testSavingCastedAttributesToDatabase() { /** @var \Illuminate\Tests\Integration\Database\CustomCasts $model */ @@ -106,9 +103,7 @@ public function testSavingCastedAttributesToDatabase() $this->assertInstanceOf(GMP::class, $model->amount); } - /** - * @requires extension gmp - */ + #[RequiresPhpExtension('gmp')] public function testInvalidArgumentExceptionOnInvalidValue() { /** @var \Illuminate\Tests\Integration\Database\CustomCasts $model */ @@ -127,9 +122,7 @@ public function testInvalidArgumentExceptionOnInvalidValue() $this->assertSame('address_line_two_value', $model->address->lineTwo); } - /** - * @requires extension gmp - */ + #[RequiresPhpExtension('gmp')] public function testInvalidArgumentExceptionOnNull() { /** @var \Illuminate\Tests\Integration\Database\CustomCasts $model */ @@ -148,9 +141,7 @@ public function testInvalidArgumentExceptionOnNull() $this->assertSame('address_line_two_value', $model->address->lineTwo); } - /** - * @requires extension gmp - */ + #[RequiresPhpExtension('gmp')] public function testModelsWithCustomCastsCanBeConvertedToArrays() { /** @var \Illuminate\Tests\Integration\Database\CustomCasts $model */ diff --git a/tests/Integration/Database/EloquentWhereHasTest.php b/tests/Integration/Database/EloquentWhereHasTest.php index 22cfaf5d5a75..26a52c0e1651 100644 --- a/tests/Integration/Database/EloquentWhereHasTest.php +++ b/tests/Integration/Database/EloquentWhereHasTest.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class EloquentWhereHasTest extends DatabaseTestCase { @@ -49,9 +50,8 @@ protected function defineDatabaseMigrationsAfterDatabaseRefreshed() /** * Check that the 'whereRelation' callback function works. - * - * @dataProvider dataProviderWhereRelationCallback */ + #[DataProvider('dataProviderWhereRelationCallback')] public function testWhereRelationCallback($callbackEloquent, $callbackQuery) { $userWhereRelation = User::whereRelation('posts', $callbackEloquent); @@ -69,9 +69,8 @@ public function testWhereRelationCallback($callbackEloquent, $callbackQuery) /** * Check that the 'orWhereRelation' callback function works. - * - * @dataProvider dataProviderWhereRelationCallback */ + #[DataProvider('dataProviderWhereRelationCallback')] public function testOrWhereRelationCallback($callbackEloquent, $callbackQuery) { $userOrWhereRelation = User::orWhereRelation('posts', $callbackEloquent); diff --git a/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php b/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php index 9848da4a642b..62592a40486f 100755 --- a/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php +++ b/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php @@ -3,11 +3,11 @@ namespace Illuminate\Tests\Integration\Database\MySql; use PDO; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_mysql')] class DatabaseEmulatePreparesMySqlConnectionTest extends DatabaseMySqlConnectionTest { protected function getEnvironmentSetUp($app) diff --git a/tests/Integration/Database/MySql/DatabaseMySqlConnectionTest.php b/tests/Integration/Database/MySql/DatabaseMySqlConnectionTest.php index a365157cf924..b1cb6a67f2c6 100644 --- a/tests/Integration/Database/MySql/DatabaseMySqlConnectionTest.php +++ b/tests/Integration/Database/MySql/DatabaseMySqlConnectionTest.php @@ -5,11 +5,12 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_mysql')] class DatabaseMySqlConnectionTest extends MySqlTestCase { const TABLE = 'player'; @@ -32,9 +33,7 @@ protected function destroyDatabaseMigrations() Schema::drop(self::TABLE); } - /** - * @dataProvider floatComparisonsDataProvider - */ + #[DataProvider('floatComparisonsDataProvider')] public function testJsonFloatComparison($value, $operator, $shouldMatch) { DB::table(self::TABLE)->insert([self::JSON_COL => '{"rank":'.self::FLOAT_VAL.'}']); @@ -68,9 +67,7 @@ public function testFloatValueStoredCorrectly() $this->assertEquals(self::FLOAT_VAL, DB::table(self::TABLE)->value(self::FLOAT_COL)); } - /** - * @dataProvider jsonWhereNullDataProvider - */ + #[DataProvider('jsonWhereNullDataProvider')] public function testJsonWhereNull($expected, $key, array $value = ['value' => 123]) { DB::table(self::TABLE)->insert([self::JSON_COL => json_encode($value)]); @@ -78,9 +75,7 @@ public function testJsonWhereNull($expected, $key, array $value = ['value' => 12 $this->assertSame($expected, DB::table(self::TABLE)->whereNull(self::JSON_COL.'->'.$key)->exists()); } - /** - * @dataProvider jsonWhereNullDataProvider - */ + #[DataProvider('jsonWhereNullDataProvider')] public function testJsonWhereNotNull($expected, $key, array $value = ['value' => 123]) { DB::table(self::TABLE)->insert([self::JSON_COL => json_encode($value)]); @@ -122,9 +117,7 @@ public function testJsonPathUpdate() $this->assertSame(1, $updatedCount); } - /** - * @dataProvider jsonContainsKeyDataProvider - */ + #[DataProvider('jsonContainsKeyDataProvider')] public function testWhereJsonContainsKey($count, $column) { DB::table(self::TABLE)->insert([ diff --git a/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php b/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php index 18b156dc98da..d8a2e9aa8f9e 100644 --- a/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php +++ b/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php @@ -5,11 +5,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use stdClass; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_mysql')] class DatabaseMySqlSchemaBuilderAlterTableWithEnumTest extends MySqlTestCase { protected function defineDatabaseMigrationsAfterDatabaseRefreshed() diff --git a/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderTest.php b/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderTest.php index bcbcd6d12bdd..f493b687e522 100644 --- a/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderTest.php +++ b/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderTest.php @@ -5,11 +5,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_mysql')] class DatabaseMySqlSchemaBuilderTest extends MySqlTestCase { public function testAddCommentToTable() diff --git a/tests/Integration/Database/MySql/EscapeTest.php b/tests/Integration/Database/MySql/EscapeTest.php index 9ad6d6e8a41f..74c490a6bb8a 100644 --- a/tests/Integration/Database/MySql/EscapeTest.php +++ b/tests/Integration/Database/MySql/EscapeTest.php @@ -3,11 +3,11 @@ namespace Illuminate\Tests\Integration\Database\MySql; use RuntimeException; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_mysql')] class EscapeTest extends MySqlTestCase { public function testEscapeInt() diff --git a/tests/Integration/Database/MySql/FulltextTest.php b/tests/Integration/Database/MySql/FulltextTest.php index a98d0c74b48a..69b7e33b8a1c 100644 --- a/tests/Integration/Database/MySql/FulltextTest.php +++ b/tests/Integration/Database/MySql/FulltextTest.php @@ -5,11 +5,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_mysql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_mysql')] class FulltextTest extends MySqlTestCase { protected function defineDatabaseMigrationsAfterDatabaseRefreshed() diff --git a/tests/Integration/Database/Postgres/DatabasePostgresConnectionTest.php b/tests/Integration/Database/Postgres/DatabasePostgresConnectionTest.php index 41c238787712..7b4aab0fb019 100644 --- a/tests/Integration/Database/Postgres/DatabasePostgresConnectionTest.php +++ b/tests/Integration/Database/Postgres/DatabasePostgresConnectionTest.php @@ -5,11 +5,12 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_pgsql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_pgsql')] class DatabasePostgresConnectionTest extends PostgresTestCase { protected function defineDatabaseMigrationsAfterDatabaseRefreshed() @@ -26,9 +27,7 @@ protected function destroyDatabaseMigrations() Schema::drop('json_table'); } - /** - * @dataProvider jsonWhereNullDataProvider - */ + #[DataProvider('jsonWhereNullDataProvider')] public function testJsonWhereNull($expected, $key, array $value = ['value' => 123]) { DB::table('json_table')->insert(['json_col' => json_encode($value)]); @@ -36,9 +35,7 @@ public function testJsonWhereNull($expected, $key, array $value = ['value' => 12 $this->assertSame($expected, DB::table('json_table')->whereNull("json_col->$key")->exists()); } - /** - * @dataProvider jsonWhereNullDataProvider - */ + #[DataProvider('jsonWhereNullDataProvider')] public function testJsonWhereNotNull($expected, $key, array $value = ['value' => 123]) { DB::table('json_table')->insert(['json_col' => json_encode($value)]); @@ -91,9 +88,7 @@ public function testJsonPathUpdate() $this->assertSame(1, $updatedCount); } - /** - * @dataProvider jsonContainsKeyDataProvider - */ + #[DataProvider('jsonContainsKeyDataProvider')] public function testWhereJsonContainsKey($count, $column) { DB::table('json_table')->insert([ diff --git a/tests/Integration/Database/Postgres/EscapeTest.php b/tests/Integration/Database/Postgres/EscapeTest.php index dc382b4a1143..9feaedb2fd9f 100644 --- a/tests/Integration/Database/Postgres/EscapeTest.php +++ b/tests/Integration/Database/Postgres/EscapeTest.php @@ -2,12 +2,12 @@ namespace Illuminate\Tests\Integration\Database\Postgres; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use RuntimeException; -/** - * @requires extension pdo_pgsql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_pgsql')] class EscapeTest extends PostgresTestCase { public function testEscapeInt() diff --git a/tests/Integration/Database/Postgres/FulltextTest.php b/tests/Integration/Database/Postgres/FulltextTest.php index 39ddb6837022..81befb9fcbbe 100644 --- a/tests/Integration/Database/Postgres/FulltextTest.php +++ b/tests/Integration/Database/Postgres/FulltextTest.php @@ -5,11 +5,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_pgsql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_pgsql')] class FulltextTest extends PostgresTestCase { protected function defineDatabaseMigrationsAfterDatabaseRefreshed() diff --git a/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php b/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php index 8efa387060ca..3aa249c2aece 100644 --- a/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php +++ b/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php @@ -5,11 +5,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_pgsql - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_pgsql')] class PostgresSchemaBuilderTest extends PostgresTestCase { protected function getEnvironmentSetUp($app) diff --git a/tests/Integration/Database/SqlServer/DatabaseSqlServerConnectionTest.php b/tests/Integration/Database/SqlServer/DatabaseSqlServerConnectionTest.php index 28b27f89f80f..975eb8c67954 100644 --- a/tests/Integration/Database/SqlServer/DatabaseSqlServerConnectionTest.php +++ b/tests/Integration/Database/SqlServer/DatabaseSqlServerConnectionTest.php @@ -5,11 +5,12 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; -/** - * @requires extension pdo_sqlsrv - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] +#[RequiresPhpExtension('pdo_sqlsrv')] class DatabaseSqlServerConnectionTest extends SqlServerTestCase { protected function defineDatabaseMigrationsAfterDatabaseRefreshed() @@ -26,9 +27,7 @@ protected function destroyDatabaseMigrations() Schema::drop('json_table'); } - /** - * @dataProvider jsonContainsKeyDataProvider - */ + #[DataProvider('jsonContainsKeyDataProvider')] public function testWhereJsonContainsKey($count, $column) { DB::table('json_table')->insert([ diff --git a/tests/Integration/Database/Sqlite/DatabaseSqliteConnectionTest.php b/tests/Integration/Database/Sqlite/DatabaseSqliteConnectionTest.php index 212ee52be7d8..f62ee3d22f09 100644 --- a/tests/Integration/Database/Sqlite/DatabaseSqliteConnectionTest.php +++ b/tests/Integration/Database/Sqlite/DatabaseSqliteConnectionTest.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; +use PHPUnit\Framework\Attributes\DataProvider; class DatabaseSqliteConnectionTest extends DatabaseTestCase { @@ -38,9 +39,7 @@ protected function destroyDatabaseMigrations() Schema::drop('json_table'); } - /** - * @dataProvider jsonContainsKeyDataProvider - */ + #[DataProvider('jsonContainsKeyDataProvider')] public function testWhereJsonContainsKey($count, $column) { DB::table('json_table')->insert([ diff --git a/tests/Integration/Filesystem/FilesystemTest.php b/tests/Integration/Filesystem/FilesystemTest.php index 8bd38fe309fe..2bde297d09f9 100644 --- a/tests/Integration/Filesystem/FilesystemTest.php +++ b/tests/Integration/Filesystem/FilesystemTest.php @@ -4,11 +4,10 @@ use Illuminate\Support\Facades\File; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use Symfony\Component\Process\Process; -/** - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] class FilesystemTest extends TestCase { protected $stubFile; diff --git a/tests/Integration/Filesystem/StorageTest.php b/tests/Integration/Filesystem/StorageTest.php index 4193a629e178..95b4990bda04 100644 --- a/tests/Integration/Filesystem/StorageTest.php +++ b/tests/Integration/Filesystem/StorageTest.php @@ -5,11 +5,10 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use Symfony\Component\Process\Process; -/** - * @requires OS Linux|Darwin - */ +#[RequiresOperatingSystem('Linux|Darwin')] class StorageTest extends TestCase { protected $stubFile; diff --git a/tests/Integration/Foundation/ExceptionHandlerTest.php b/tests/Integration/Foundation/ExceptionHandlerTest.php index 622b4348d2e8..0dc552cbb0ed 100644 --- a/tests/Integration/Foundation/ExceptionHandlerTest.php +++ b/tests/Integration/Foundation/ExceptionHandlerTest.php @@ -6,6 +6,7 @@ use Illuminate\Auth\Access\Response; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Process\PhpProcess; class ExceptionHandlerTest extends TestCase @@ -120,9 +121,7 @@ public function testItHasFallbackErrorMessageForUnknownStatusCodes() ]); } - /** - * @dataProvider exitCodesProvider - */ + #[DataProvider('exitCodesProvider')] public function testItReturnsNonZeroExitCodesForUncaughtExceptions($providers, $successful) { $basePath = static::applicationBasePath(); diff --git a/tests/Integration/Foundation/FoundationServiceProvidersTest.php b/tests/Integration/Foundation/FoundationServiceProvidersTest.php index bfc39cd44b3c..0cb2a3e5e6d8 100644 --- a/tests/Integration/Foundation/FoundationServiceProvidersTest.php +++ b/tests/Integration/Foundation/FoundationServiceProvidersTest.php @@ -4,6 +4,7 @@ use Illuminate\Support\ServiceProvider; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class FoundationServiceProvidersTest extends TestCase { @@ -12,7 +13,7 @@ protected function getPackageProviders($app) return [HeadServiceProvider::class]; } - /** @test */ + #[Test] public function it_can_boot_service_provider_registered_from_another_service_provider() { $this->assertTrue($this->app['tail.registered']); diff --git a/tests/Integration/Generators/FactoryMakeCommandTest.php b/tests/Integration/Generators/FactoryMakeCommandTest.php index 02ec76943c99..fccbe1fb0282 100644 --- a/tests/Integration/Generators/FactoryMakeCommandTest.php +++ b/tests/Integration/Generators/FactoryMakeCommandTest.php @@ -8,7 +8,6 @@ class FactoryMakeCommandTest extends TestCase 'database/factories/FooFactory.php', ]; - /** @test */ public function testItCanGenerateFactoryFile() { $this->artisan('make:factory', ['name' => 'FooFactory']) diff --git a/tests/Integration/Generators/ResourceMakeCommandTest.php b/tests/Integration/Generators/ResourceMakeCommandTest.php index b50b40872a85..eb1457a9b650 100644 --- a/tests/Integration/Generators/ResourceMakeCommandTest.php +++ b/tests/Integration/Generators/ResourceMakeCommandTest.php @@ -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); @@ -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); diff --git a/tests/Integration/Queue/CustomPayloadTest.php b/tests/Integration/Queue/CustomPayloadTest.php index 5ae3a8f43017..e3f7cf28b9a8 100644 --- a/tests/Integration/Queue/CustomPayloadTest.php +++ b/tests/Integration/Queue/CustomPayloadTest.php @@ -8,6 +8,7 @@ use Illuminate\Queue\Queue; use Illuminate\Support\ServiceProvider; use Orchestra\Testbench\Concerns\CreatesApplication; +use PHPUnit\Framework\Attributes\DataProvider; class CustomPayloadTest extends TestCase { @@ -25,9 +26,7 @@ public static function websites() yield ['blog.laravel.com']; } - /** - * @dataProvider websites - */ + #[DataProvider('websites')] public function test_custom_payload_gets_cleared_for_each_data_provider(string $websites) { $dispatcher = $this->app->make(QueueingDispatcher::class); diff --git a/tests/Integration/Routing/RouteRedirectTest.php b/tests/Integration/Routing/RouteRedirectTest.php index edf0882963f1..e46e8e7b4717 100644 --- a/tests/Integration/Routing/RouteRedirectTest.php +++ b/tests/Integration/Routing/RouteRedirectTest.php @@ -6,12 +6,11 @@ use Illuminate\Routing\Middleware\SubstituteBindings; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class RouteRedirectTest extends TestCase { - /** - * @dataProvider routeRedirectDataSets - */ + #[DataProvider('routeRedirectDataSets')] public function testRouteRedirect($redirectFrom, $redirectTo, $requestUri, $redirectUri) { $this->withoutExceptionHandling(); diff --git a/tests/Mail/MailManagerTest.php b/tests/Mail/MailManagerTest.php index deb824da5ec0..4ae036416be9 100644 --- a/tests/Mail/MailManagerTest.php +++ b/tests/Mail/MailManagerTest.php @@ -4,13 +4,12 @@ use InvalidArgumentException; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; class MailManagerTest extends TestCase { - /** - * @dataProvider emptyTransportConfigDataProvider - */ + #[DataProvider('emptyTransportConfigDataProvider')] public function testEmptyTransportConfig($transport) { $this->app['config']->set('mail.mailers.custom_smtp', [ diff --git a/tests/Queue/QueueDatabaseQueueUnitTest.php b/tests/Queue/QueueDatabaseQueueUnitTest.php index e4bfe062c018..eee521c085de 100644 --- a/tests/Queue/QueueDatabaseQueueUnitTest.php +++ b/tests/Queue/QueueDatabaseQueueUnitTest.php @@ -8,6 +8,7 @@ use Illuminate\Queue\Queue; use Illuminate\Support\Str; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionClass; use stdClass; @@ -19,9 +20,7 @@ protected function tearDown(): void m::close(); } - /** - * @dataProvider pushJobsDataProvider - */ + #[DataProvider('pushJobsDataProvider')] public function testPushProperlyPushesJobOntoDatabase($uuid, $job, $displayNameStartsWith, $jobStartsWith) { Str::createUuidsUsing(function () use ($uuid) { diff --git a/tests/Queue/RedisQueueIntegrationTest.php b/tests/Queue/RedisQueueIntegrationTest.php index e7d26522f1e4..a195775cf82b 100644 --- a/tests/Queue/RedisQueueIntegrationTest.php +++ b/tests/Queue/RedisQueueIntegrationTest.php @@ -12,6 +12,8 @@ use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; class RedisQueueIntegrationTest extends TestCase @@ -45,10 +47,9 @@ protected function tearDown(): void } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testExpiredJobsArePopped($driver) { $this->setQueue($driver); @@ -77,14 +78,12 @@ public function testExpiredJobsArePopped($driver) } /** - * @dataProvider redisDriverProvider - * - * @requires extension pcntl - * * @param mixed $driver * * @throws \Exception */ + #[DataProvider('redisDriverProvider')] + #[RequiresPhpExtension('pcntl')] public function testBlockingPop($driver) { $this->tearDownRedis(); @@ -105,10 +104,9 @@ public function testBlockingPop($driver) } // /** - // * @dataProvider redisDriverProvider - // * // * @param string $driver // */ + // #[DataProvider('redisDriverProvider')] // public function testMigrateMoreThan100Jobs($driver) // { // $this->setQueue($driver); @@ -122,10 +120,9 @@ public function testBlockingPop($driver) // } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testPopProperlyPopsJobOffOfRedis($driver) { $this->setQueue($driver); @@ -157,10 +154,9 @@ public function testPopProperlyPopsJobOffOfRedis($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testPopProperlyPopsDelayedJobOffOfRedis($driver) { $this->setQueue($driver); @@ -184,10 +180,9 @@ public function testPopProperlyPopsDelayedJobOffOfRedis($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testPopPopsDelayedJobOffOfRedisWhenExpireNull($driver) { $this->setQueue($driver, 'default', null, null); @@ -214,10 +209,9 @@ public function testPopPopsDelayedJobOffOfRedisWhenExpireNull($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testBlockingPopProperlyPopsJobOffOfRedis($driver) { $this->setQueue($driver, 'default', null, 60, 5); @@ -235,10 +229,9 @@ public function testBlockingPopProperlyPopsJobOffOfRedis($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testBlockingPopProperlyPopsExpiredJobs($driver) { Str::createUuidsUsing(function () { @@ -266,10 +259,9 @@ public function testBlockingPopProperlyPopsExpiredJobs($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testNotExpireJobsWhenExpireNull($driver) { $this->setQueue($driver, 'default', null, null); @@ -315,10 +307,9 @@ public function testNotExpireJobsWhenExpireNull($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testExpireJobsWhenExpireSet($driver) { $this->setQueue($driver, 'default', null, 30); @@ -344,10 +335,9 @@ public function testExpireJobsWhenExpireSet($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testRelease($driver) { $this->setQueue($driver); @@ -385,10 +375,9 @@ public function testRelease($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testReleaseInThePast($driver) { $this->setQueue($driver); @@ -403,10 +392,9 @@ public function testReleaseInThePast($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testDelete($driver) { $this->setQueue($driver); @@ -427,10 +415,9 @@ public function testDelete($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testClear($driver) { $this->setQueue($driver); @@ -447,10 +434,9 @@ public function testClear($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testSize($driver) { $this->setQueue($driver); @@ -468,10 +454,9 @@ public function testSize($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testPushJobQueuedEvent($driver) { $events = m::mock(Dispatcher::class); @@ -493,10 +478,9 @@ public function testPushJobQueuedEvent($driver) } /** - * @dataProvider redisDriverProvider - * * @param string $driver */ + #[DataProvider('redisDriverProvider')] public function testBulkJobQueuedEvent($driver) { $events = m::mock(Dispatcher::class); diff --git a/tests/Routing/RouteUriTest.php b/tests/Routing/RouteUriTest.php index b9e0688b1be1..076d5deb7a72 100644 --- a/tests/Routing/RouteUriTest.php +++ b/tests/Routing/RouteUriTest.php @@ -3,13 +3,12 @@ namespace Illuminate\Tests\Routing; use Illuminate\Routing\RouteUri; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class RouteUriTest extends TestCase { - /** - * @dataProvider uriProvider - */ + #[DataProvider('uriProvider')] public function testRouteUrisAreProperlyParsed($uri, $expectedParsedUri, $expectedBindingFields) { $parsed = RouteUri::parse($uri); diff --git a/tests/Routing/RoutingUrlGeneratorTest.php b/tests/Routing/RoutingUrlGeneratorTest.php index 2c6079adf36b..6fdd50f2ce2a 100755 --- a/tests/Routing/RoutingUrlGeneratorTest.php +++ b/tests/Routing/RoutingUrlGeneratorTest.php @@ -10,6 +10,7 @@ use Illuminate\Routing\RouteCollection; use Illuminate\Routing\UrlGenerator; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; use Symfony\Component\Routing\Exception\RouteNotFoundException; @@ -587,9 +588,7 @@ public static function providerRouteParameters() ]; } - /** - * @dataProvider providerRouteParameters - */ + #[DataProvider('providerRouteParameters')] public function testUrlGenerationForControllersRequiresPassingOfRequiredParameters($parameters) { $this->expectException(UrlGenerationException::class); @@ -641,9 +640,7 @@ public static function provideParametersAndExpectedMeaningfulExceptionMessages() ]; } - /** - * @dataProvider provideParametersAndExpectedMeaningfulExceptionMessages - */ + #[DataProvider('provideParametersAndExpectedMeaningfulExceptionMessages')] public function testUrlGenerationThrowsExceptionForMissingParametersWithMeaningfulMessage($parameters, $expectedMeaningfulExceptionMessage) { $this->expectException(UrlGenerationException::class); diff --git a/tests/Support/ConfigurationUrlParserTest.php b/tests/Support/ConfigurationUrlParserTest.php index 9035d08a45b6..55434eefa156 100644 --- a/tests/Support/ConfigurationUrlParserTest.php +++ b/tests/Support/ConfigurationUrlParserTest.php @@ -3,13 +3,12 @@ namespace Illuminate\Tests\Support; use Illuminate\Support\ConfigurationUrlParser; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ConfigurationUrlParserTest extends TestCase { - /** - * @dataProvider databaseUrls - */ + #[DataProvider('databaseUrls')] public function testDatabaseUrlsAreParsed($config, $expectedOutput) { $this->assertEquals($expectedOutput, (new ConfigurationUrlParser)->parseConfiguration($config)); diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 60d982ea8848..117d9ae05e5e 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -19,29 +19,26 @@ use IteratorAggregate; use JsonSerializable; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionClass; -use stdClass; use Symfony\Component\VarDumper\VarDumper; use Traversable; use UnexpectedValueException; +use stdClass; include_once 'Enums.php'; class SupportCollectionTest extends TestCase { - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstReturnsFirstItemInCollection($collection) { $c = new $collection(['foo', 'bar']); $this->assertSame('foo', $c->first()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstWithCallback($collection) { $data = new $collection(['foo', 'bar', 'baz']); @@ -51,9 +48,7 @@ public function testFirstWithCallback($collection) $this->assertSame('bar', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstWithCallbackAndDefault($collection) { $data = new $collection(['foo', 'bar']); @@ -63,9 +58,7 @@ public function testFirstWithCallbackAndDefault($collection) $this->assertSame('default', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstWithDefaultAndWithoutCallback($collection) { $data = new $collection; @@ -77,9 +70,7 @@ public function testFirstWithDefaultAndWithoutCallback($collection) $this->assertSame('foo', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSoleReturnsFirstItemInCollectionIfOnlyOneExists($collection) { $collection = new $collection([ @@ -92,9 +83,7 @@ public function testSoleReturnsFirstItemInCollectionIfOnlyOneExists($collection) $this->assertSame(['name' => 'foo'], $collection->sole('name', 'foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSoleThrowsExceptionIfNoItemsExist($collection) { $this->expectException(ItemNotFoundException::class); @@ -107,9 +96,7 @@ public function testSoleThrowsExceptionIfNoItemsExist($collection) $collection->where('name', 'INVALID')->sole(); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSoleThrowsExceptionIfMoreThanOneItemExists($collection) { $this->expectExceptionObject(new MultipleItemsFoundException(2)); @@ -123,9 +110,7 @@ public function testSoleThrowsExceptionIfMoreThanOneItemExists($collection) $collection->where('name', 'foo')->sole(); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSoleReturnsFirstItemInCollectionIfOnlyOneExistsWithCallback($collection) { $data = new $collection(['foo', 'bar', 'baz']); @@ -135,9 +120,7 @@ public function testSoleReturnsFirstItemInCollectionIfOnlyOneExistsWithCallback( $this->assertSame('bar', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSoleThrowsExceptionIfNoItemsExistWithCallback($collection) { $this->expectException(ItemNotFoundException::class); @@ -149,9 +132,7 @@ public function testSoleThrowsExceptionIfNoItemsExistWithCallback($collection) }); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSoleThrowsExceptionIfMoreThanOneItemExistsWithCallback($collection) { $this->expectExceptionObject(new MultipleItemsFoundException(2)); @@ -163,9 +144,7 @@ public function testSoleThrowsExceptionIfMoreThanOneItemExistsWithCallback($coll }); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailReturnsFirstItemInCollection($collection) { $collection = new $collection([ @@ -178,9 +157,7 @@ public function testFirstOrFailReturnsFirstItemInCollection($collection) $this->assertSame(['name' => 'foo'], $collection->firstOrFail('name', 'foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailThrowsExceptionIfNoItemsExist($collection) { $this->expectException(ItemNotFoundException::class); @@ -193,9 +170,7 @@ public function testFirstOrFailThrowsExceptionIfNoItemsExist($collection) $collection->where('name', 'INVALID')->firstOrFail(); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailDoesntThrowExceptionIfMoreThanOneItemExists($collection) { $collection = new $collection([ @@ -207,9 +182,7 @@ public function testFirstOrFailDoesntThrowExceptionIfMoreThanOneItemExists($coll $this->assertSame(['name' => 'foo'], $collection->where('name', 'foo')->firstOrFail()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailReturnsFirstItemInCollectionIfOnlyOneExistsWithCallback($collection) { $data = new $collection(['foo', 'bar', 'baz']); @@ -219,9 +192,7 @@ public function testFirstOrFailReturnsFirstItemInCollectionIfOnlyOneExistsWithCa $this->assertSame('bar', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailThrowsExceptionIfNoItemsExistWithCallback($collection) { $this->expectException(ItemNotFoundException::class); @@ -233,9 +204,7 @@ public function testFirstOrFailThrowsExceptionIfNoItemsExistWithCallback($collec }); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailDoesntThrowExceptionIfMoreThanOneItemExistsWithCallback($collection) { $data = new $collection(['foo', 'bar', 'bar']); @@ -248,9 +217,7 @@ public function testFirstOrFailDoesntThrowExceptionIfMoreThanOneItemExistsWithCa ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstOrFailStopsIteratingAtFirstMatch($collection) { $data = new $collection([ @@ -270,9 +237,7 @@ function () { })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFirstWhere($collection) { $data = new $collection([ @@ -291,9 +256,7 @@ public function testFirstWhere($collection) $this->assertNull($data->firstWhere(fn ($value) => ($value['nonexistent'] ?? null) === 'key')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testLastReturnsLastItemInCollection($collection) { $c = new $collection(['foo', 'bar']); @@ -303,9 +266,7 @@ public function testLastReturnsLastItemInCollection($collection) $this->assertNull($c->last()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testLastWithCallback($collection) { $data = new $collection([100, 200, 300]); @@ -325,9 +286,7 @@ public function testLastWithCallback($collection) $this->assertNull($result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testLastWithCallbackAndDefault($collection) { $data = new $collection(['foo', 'bar']); @@ -343,9 +302,7 @@ public function testLastWithCallbackAndDefault($collection) $this->assertSame('bar', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testLastWithDefaultAndWithoutCallback($collection) { $data = new $collection; @@ -391,9 +348,7 @@ public function testShiftReturnsAndRemovesFirstXItemsInCollection() $this->assertEquals(new Collection(['foo', 'bar', 'baz']), (new Collection(['foo', 'bar', 'baz']))->shift(6)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliding($collection) { // Default parameters: $size = 2, $step = 1 @@ -450,9 +405,7 @@ public function testSliding($collection) $this->assertInstanceOf($collection, $chunks->skip(1)->first()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEmptyCollectionIsEmpty($collection) { $c = new $collection; @@ -460,9 +413,7 @@ public function testEmptyCollectionIsEmpty($collection) $this->assertTrue($c->isEmpty()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEmptyCollectionIsNotEmpty($collection) { $c = new $collection(['foo', 'bar']); @@ -471,9 +422,7 @@ public function testEmptyCollectionIsNotEmpty($collection) $this->assertTrue($c->isNotEmpty()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollectionIsConstructed($collection) { $data = new $collection('foo'); @@ -492,9 +441,7 @@ public function testCollectionIsConstructed($collection) $this->assertEmpty($data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollectionShuffleWithSeed($collection) { $data = new $collection(range(0, 100, 10)); @@ -505,9 +452,7 @@ public function testCollectionShuffleWithSeed($collection) $this->assertEquals($firstRandom, $secondRandom); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSkipMethod($collection) { $data = new $collection([1, 2, 3, 4, 5, 6]); @@ -519,9 +464,7 @@ public function testSkipMethod($collection) $this->assertSame([], $data->skip(10)->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSkipUntil($collection) { $data = new $collection([1, 1, 2, 2, 3, 3, 4, 4]); @@ -557,9 +500,7 @@ public function testSkipUntil($collection) $this->assertSame([], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSkipWhile($collection) { $data = new $collection([1, 1, 2, 2, 3, 3, 4, 4]); @@ -595,9 +536,7 @@ public function testSkipWhile($collection) $this->assertSame([3, 3, 4, 4], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGetArrayableItems($collection) { $data = new $collection; @@ -635,9 +574,7 @@ public function testGetArrayableItems($collection) $this->assertSame(['foo' => 'bar'], $array); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testToArrayCallsToArrayOnEachItemInCollection($collection) { $item1 = m::mock(Arrayable::class); @@ -662,9 +599,7 @@ public function testLazyReturnsLazyCollection() $this->assertSame([1, 2, 3, 4, 5], $lazy->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testJsonSerializeCallsToArrayOrJsonSerializeOnEachItemInCollection($collection) { $item1 = m::mock(JsonSerializable::class); @@ -677,9 +612,7 @@ public function testJsonSerializeCallsToArrayOrJsonSerializeOnEachItemInCollecti $this->assertEquals(['foo.json', 'bar.array'], $results); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testToJsonEncodesTheJsonSerializeResult($collection) { $c = $this->getMockBuilder($collection)->onlyMethods(['jsonSerialize'])->getMock(); @@ -688,9 +621,7 @@ public function testToJsonEncodesTheJsonSerializeResult($collection) $this->assertJsonStringEqualsJsonString(json_encode(['foo']), $results); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCastingToStringJsonEncodesTheToArrayResult($collection) { $c = $this->getMockBuilder($collection)->onlyMethods(['jsonSerialize'])->getMock(); @@ -811,18 +742,14 @@ public function testForgetCollectionOfKeys() $this->assertTrue(isset($c['name'])); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCountable($collection) { $c = new $collection(['foo', 'bar']); $this->assertCount(2, $c); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCountByStandalone($collection) { $c = new $collection(['foo', 'foo', 'foo', 'bar', 'bar', 'foobar']); @@ -835,9 +762,7 @@ public function testCountByStandalone($collection) $this->assertEquals([1 => 3, 5 => 3], $c->countBy()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCountByWithKey($collection) { $c = new $collection([ @@ -847,9 +772,7 @@ public function testCountByWithKey($collection) $this->assertEquals(['a' => 4, 'b' => 3], $c->countBy('key')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCountableByWithCallback($collection) { $c = new $collection(['alice', 'aaron', 'bob', 'carla']); @@ -875,9 +798,7 @@ public function testAdd() $this->assertEquals([1, 2, '', null, false, [], 'name'], $c->add('name')->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testContainsOneItem($collection) { $this->assertFalse((new $collection([]))->containsOneItem()); @@ -892,18 +813,14 @@ public function testIterable() $this->assertEquals(['foo'], $c->getIterator()->getArrayCopy()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCachingIterator($collection) { $c = new $collection(['foo']); $this->assertInstanceOf(CachingIterator::class, $c->getCachingIterator()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFilter($collection) { $c = new $collection([['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']]); @@ -923,9 +840,7 @@ public function testFilter($collection) $this->assertEquals([1, 2, 3], $c->filter()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderKeyBy($collection) { $c = new $collection([ @@ -936,9 +851,7 @@ public function testHigherOrderKeyBy($collection) $this->assertEquals(['id1' => 'first', 'id2' => 'second'], $c->keyBy->id->map->name->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderUnique($collection) { $c = new $collection([ @@ -949,9 +862,7 @@ public function testHigherOrderUnique($collection) $this->assertCount(1, $c->unique->id); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderFilter($collection) { $c = new $collection([ @@ -978,9 +889,7 @@ public function active() $this->assertCount(1, $c->filter->active()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhere($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); @@ -1118,9 +1027,7 @@ public function testWhere($collection) $this->assertEquals([['v' => 2, 'g' => null]], $c->where('v', 2)->whereNull('g')->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereStrict($collection) { $c = new $collection([['v' => 3], ['v' => '3']]); @@ -1131,9 +1038,7 @@ public function testWhereStrict($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereInstanceOf($collection) { $c = new $collection([new stdClass, new stdClass, new $collection, new stdClass, new Str]); @@ -1142,9 +1047,7 @@ public function testWhereInstanceOf($collection) $this->assertCount(4, $c->whereInstanceOf([stdClass::class, Str::class])); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereIn($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); @@ -1153,18 +1056,14 @@ public function testWhereIn($collection) $this->assertEquals([['v' => 1]], $c->whereIn('v', [1])->whereIn('v', [1, 3])->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereInStrict($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); $this->assertEquals([['v' => 1], ['v' => 3]], $c->whereInStrict('v', [1, 3])->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNotIn($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); @@ -1172,18 +1071,14 @@ public function testWhereNotIn($collection) $this->assertEquals([['v' => 4]], $c->whereNotIn('v', [2])->whereNotIn('v', [1, 3])->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNotInStrict($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); $this->assertEquals([['v' => 2], ['v' => '3'], ['v' => 4]], $c->whereNotInStrict('v', [1, 3])->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testValues($collection) { $c = new $collection([['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']]); @@ -1192,18 +1087,14 @@ public function testValues($collection) })->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testValuesResetKey($collection) { $data = new $collection([1 => 'a', 2 => 'b', 3 => 'c']); $this->assertEquals([0 => 'a', 1 => 'b', 2 => 'c'], $data->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testValue($collection) { $c = new $collection([['id' => 1, 'name' => 'Hello'], ['id' => 2, 'name' => 'World']]); @@ -1221,9 +1112,7 @@ public function testValue($collection) $this->assertEquals('bar', $c->where('id', 2)->value('pivot.value')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testBetween($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); @@ -1234,9 +1123,7 @@ public function testBetween($collection) $this->assertEquals([['v' => 3], ['v' => '3']], $c->whereBetween('v', [3, 3])->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNotBetween($collection) { $c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]); @@ -1246,9 +1133,7 @@ public function testWhereNotBetween($collection) $this->assertEquals([['v' => 1], ['v' => '2'], ['v' => '4']], $c->whereNotBetween('v', [3, 3])->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFlatten($collection) { // Flat arrays are unaffected @@ -1284,9 +1169,7 @@ public function testFlatten($collection) $this->assertEquals(['#foo', '#bar', '#zap', '#baz'], $c->flatten()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFlattenWithDepth($collection) { // No depth flattens recursively @@ -1301,9 +1184,7 @@ public function testFlattenWithDepth($collection) $this->assertEquals(['#foo', '#bar', ['#baz'], '#zap'], $c->flatten(2)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFlattenIgnoresKeys($collection) { // No depth ignores keys @@ -1315,54 +1196,42 @@ public function testFlattenIgnoresKeys($collection) $this->assertEquals(['#foo', '#bar', '#baz', '#zap'], $c->flatten(1)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMergeNull($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'Hello'], $c->merge(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMergeArray($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'Hello', 'id' => 1], $c->merge(['id' => 1])->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMergeCollection($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'World', 'id' => 1], $c->merge(new $collection(['name' => 'World', 'id' => 1]))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMergeRecursiveNull($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'Hello'], $c->mergeRecursive(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMergeRecursiveArray($collection) { $c = new $collection(['name' => 'Hello', 'id' => 1]); $this->assertEquals(['name' => 'Hello', 'id' => [1, 2]], $c->mergeRecursive(['id' => 2])->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMergeRecursiveCollection($collection) { $c = new $collection(['name' => 'Hello', 'id' => 1, 'meta' => ['tags' => ['a', 'b'], 'roles' => 'admin']]); @@ -1372,18 +1241,14 @@ public function testMergeRecursiveCollection($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReplaceNull($collection) { $c = new $collection(['a', 'b', 'c']); $this->assertEquals(['a', 'b', 'c'], $c->replace(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReplaceArray($collection) { $c = new $collection(['a', 'b', 'c']); @@ -1396,9 +1261,7 @@ public function testReplaceArray($collection) $this->assertEquals(['name' => 'taylor', 'family' => 'otwell', 'age' => 26], $c->replace(['name' => 'taylor', 'age' => 26])->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReplaceCollection($collection) { $c = new $collection(['a', 'b', 'c']); @@ -1420,18 +1283,14 @@ public function testReplaceCollection($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReplaceRecursiveNull($collection) { $c = new $collection(['a', 'b', ['c', 'd']]); $this->assertEquals(['a', 'b', ['c', 'd']], $c->replaceRecursive(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReplaceRecursiveArray($collection) { $c = new $collection(['a', 'b', ['c', 'd']]); @@ -1441,9 +1300,7 @@ public function testReplaceRecursiveArray($collection) $this->assertEquals(['z', 'b', ['c', 'e'], 'f'], $c->replaceRecursive(['z', 2 => [1 => 'e'], 'f'])->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReplaceRecursiveCollection($collection) { $c = new $collection(['a', 'b', ['c', 'd']]); @@ -1453,45 +1310,35 @@ public function testReplaceRecursiveCollection($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnionNull($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'Hello'], $c->union(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnionArray($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'Hello', 'id' => 1], $c->union(['id' => 1])->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnionCollection($collection) { $c = new $collection(['name' => 'Hello']); $this->assertEquals(['name' => 'Hello', 'id' => 1], $c->union(new $collection(['name' => 'World', 'id' => 1]))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffCollection($collection) { $c = new $collection(['id' => 1, 'first_word' => 'Hello']); $this->assertEquals(['id' => 1], $c->diff(new $collection(['first_word' => 'Hello', 'last_word' => 'World']))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffUsingWithCollection($collection) { $c = new $collection(['en_GB', 'fr', 'HR']); @@ -1501,27 +1348,21 @@ public function testDiffUsingWithCollection($collection) $this->assertEquals(['fr'], $c->diffUsing(new $collection(['en_gb', 'hr']), 'strcasecmp')->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffUsingWithNull($collection) { $c = new $collection(['en_GB', 'fr', 'HR']); $this->assertEquals(['en_GB', 'fr', 'HR'], $c->diffUsing(null, 'strcasecmp')->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffNull($collection) { $c = new $collection(['id' => 1, 'first_word' => 'Hello']); $this->assertEquals(['id' => 1, 'first_word' => 'Hello'], $c->diff(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffKeys($collection) { $c1 = new $collection(['id' => 1, 'first_word' => 'Hello']); @@ -1529,9 +1370,7 @@ public function testDiffKeys($collection) $this->assertEquals(['first_word' => 'Hello'], $c1->diffKeys($c2)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffKeysUsing($collection) { $c1 = new $collection(['id' => 1, 'first_word' => 'Hello']); @@ -1542,9 +1381,7 @@ public function testDiffKeysUsing($collection) $this->assertEquals(['first_word' => 'Hello'], $c1->diffKeysUsing($c2, 'strcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffAssoc($collection) { $c1 = new $collection(['id' => 1, 'first_word' => 'Hello', 'not_affected' => 'value']); @@ -1552,9 +1389,7 @@ public function testDiffAssoc($collection) $this->assertEquals(['id' => 1, 'first_word' => 'Hello'], $c1->diffAssoc($c2)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDiffAssocUsing($collection) { $c1 = new $collection(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red']); @@ -1565,9 +1400,7 @@ public function testDiffAssocUsing($collection) $this->assertEquals(['b' => 'brown', 'c' => 'blue', 'red'], $c1->diffAssocUsing($c2, 'strcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDuplicates($collection) { $duplicates = $collection::make([1, 2, 1, 'laravel', null, 'laravel', 'php', null])->duplicates()->all(); @@ -1587,9 +1420,7 @@ public function testDuplicates($collection) $this->assertSame([1 => $expected, 2 => $expected, 5 => '2'], $duplicates); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDuplicatesWithKey($collection) { $items = [['framework' => 'vue'], ['framework' => 'laravel'], ['framework' => 'laravel']]; @@ -1602,9 +1433,7 @@ public function testDuplicatesWithKey($collection) $this->assertSame([2 => 'vue'], $duplicates); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDuplicatesWithCallback($collection) { $items = [['framework' => 'vue'], ['framework' => 'laravel'], ['framework' => 'laravel']]; @@ -1614,9 +1443,7 @@ public function testDuplicatesWithCallback($collection) $this->assertSame([2 => 'laravel'], $duplicates); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDuplicatesWithStrict($collection) { $duplicates = $collection::make([1, 2, 1, 'laravel', null, 'laravel', 'php', null])->duplicatesStrict()->all(); @@ -1636,9 +1463,7 @@ public function testDuplicatesWithStrict($collection) $this->assertSame([2 => $expected, 5 => '2'], $duplicates); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEach($collection) { $c = new $collection($original = [1, 2, 'foo' => 'bar', 'bam' => 'baz']); @@ -1659,9 +1484,7 @@ public function testEach($collection) $this->assertEquals([1, 2, 'foo' => 'bar'], $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEachSpread($collection) { $c = new $collection([[1, 'a'], [2, 'b']]); @@ -1694,27 +1517,21 @@ public function testEachSpread($collection) $this->assertEquals([[1, 'a', 0], [2, 'b', 1]], $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectNull($collection) { $c = new $collection(['id' => 1, 'first_word' => 'Hello']); $this->assertEquals([], $c->intersect(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectCollection($collection) { $c = new $collection(['id' => 1, 'first_word' => 'Hello']); $this->assertEquals(['first_word' => 'Hello'], $c->intersect(new $collection(['first_world' => 'Hello', 'last_word' => 'World']))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectUsingWithNull($collection) { $collect = new $collection(['green', 'brown', 'blue']); @@ -1722,9 +1539,7 @@ public function testIntersectUsingWithNull($collection) $this->assertEquals([], $collect->intersectUsing(null, 'strcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectUsingCollection($collection) { $collect = new $collection(['green', 'brown', 'blue']); @@ -1732,9 +1547,7 @@ public function testIntersectUsingCollection($collection) $this->assertEquals(['green', 'brown'], $collect->intersectUsing(new $collection(['GREEN', 'brown', 'yellow']), 'strcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectAssocWithNull($collection) { $array1 = new $collection(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red']); @@ -1742,9 +1555,7 @@ public function testIntersectAssocWithNull($collection) $this->assertEquals([], $array1->intersectAssoc(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectAssocCollection($collection) { $array1 = new $collection(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red']); @@ -1753,9 +1564,7 @@ public function testIntersectAssocCollection($collection) $this->assertEquals(['a' => 'green'], $array1->intersectAssoc($array2)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectAssocUsingWithNull($collection) { $array1 = new $collection(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red']); @@ -1763,9 +1572,7 @@ public function testIntersectAssocUsingWithNull($collection) $this->assertEquals([], $array1->intersectAssocUsing(null, 'strcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectAssocUsingCollection($collection) { $array1 = new $collection(['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red']); @@ -1774,18 +1581,14 @@ public function testIntersectAssocUsingCollection($collection) $this->assertEquals(['b' => 'brown'], $array1->intersectAssocUsing($array2, 'strcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectByKeysNull($collection) { $c = new $collection(['name' => 'Mateus', 'age' => 18]); $this->assertEquals([], $c->intersectByKeys(null)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testIntersectByKeys($collection) { $c = new $collection(['name' => 'Mateus', 'age' => 18]); @@ -1795,9 +1598,7 @@ public function testIntersectByKeys($collection) $this->assertEquals(['name' => 'taylor', 'family' => 'otwell'], $c->intersectByKeys(new $collection(['height' => 180, 'name' => 'amir', 'family' => 'moharami']))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnique($collection) { $c = new $collection(['Hello', 'World', 'World']); @@ -1807,9 +1608,7 @@ public function testUnique($collection) $this->assertEquals([[1, 2], [2, 3], [3, 4]], $c->unique()->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUniqueWithCallback($collection) { $c = new $collection([ @@ -1842,9 +1641,7 @@ public function testUniqueWithCallback($collection) })->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUniqueStrict($collection) { $c = new $collection([ @@ -1874,27 +1671,21 @@ public function testUniqueStrict($collection) ], $c->uniqueStrict('id')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollapse($collection) { $data = new $collection([[$object1 = new stdClass], [$object2 = new stdClass]]); $this->assertEquals([$object1, $object2], $data->collapse()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollapseWithNestedCollections($collection) { $data = new $collection([new $collection([1, 2, 3]), new $collection([4, 5, 6])]); $this->assertEquals([1, 2, 3, 4, 5, 6], $data->collapse()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testJoin($collection) { $this->assertSame('a, b, c', (new $collection(['a', 'b', 'c']))->join(', ')); @@ -1908,9 +1699,7 @@ public function testJoin($collection) $this->assertSame('', (new $collection([]))->join(', ', ' and ')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCrossJoin($collection) { // Cross join with an array @@ -1940,9 +1729,7 @@ public function testCrossJoin($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSort($collection) { $data = (new $collection([5, 3, 1, 2, 4]))->sort(); @@ -1961,9 +1748,7 @@ public function testSort($collection) $this->assertEquals(['T1', 'T2', 'T10'], $data->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortDesc($collection) { $data = (new $collection([5, 3, 1, 2, 4]))->sortDesc(); @@ -1982,9 +1767,7 @@ public function testSortDesc($collection) $this->assertEquals(['T10', 'T2', 'T1'], $data->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortWithCallback($collection) { $data = (new $collection([5, 3, 1, 2, 4]))->sort(function ($a, $b) { @@ -1998,9 +1781,7 @@ public function testSortWithCallback($collection) $this->assertEquals(range(1, 5), array_values($data->all())); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortBy($collection) { $data = new $collection(['taylor', 'dayle']); @@ -2018,9 +1799,7 @@ public function testSortBy($collection) $this->assertEquals(['taylor', 'dayle'], array_values($data->all())); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortByString($collection) { $data = new $collection([['name' => 'taylor'], ['name' => 'dayle']]); @@ -2034,9 +1813,7 @@ public function testSortByString($collection) $this->assertEquals([['name' => 'dayle'], ['name' => 'taylor']], array_values($data->all())); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortByCallableString($collection) { $data = new $collection([['sort' => 2], ['sort' => 1]]); @@ -2045,9 +1822,7 @@ public function testSortByCallableString($collection) $this->assertEquals([['sort' => 1], ['sort' => 2]], array_values($data->all())); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortByAlwaysReturnsAssoc($collection) { $data = new $collection(['a' => 'taylor', 'b' => 'dayle']); @@ -2075,9 +1850,7 @@ public function testSortByAlwaysReturnsAssoc($collection) $this->assertEquals([1 => ['sort' => 1], 0 => ['sort' => 2]], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortKeys($collection) { $data = new $collection(['b' => 'dayle', 'a' => 'taylor']); @@ -2085,9 +1858,7 @@ public function testSortKeys($collection) $this->assertSame(['a' => 'taylor', 'b' => 'dayle'], $data->sortKeys()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortKeysDesc($collection) { $data = new $collection(['a' => 'taylor', 'b' => 'dayle']); @@ -2095,9 +1866,7 @@ public function testSortKeysDesc($collection) $this->assertSame(['b' => 'dayle', 'a' => 'taylor'], $data->sortKeysDesc()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSortKeysUsing($collection) { $data = new $collection(['B' => 'dayle', 'a' => 'taylor']); @@ -2105,9 +1874,7 @@ public function testSortKeysUsing($collection) $this->assertSame(['a' => 'taylor', 'B' => 'dayle'], $data->sortKeysUsing('strnatcasecmp')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReverse($collection) { $data = new $collection(['zaeed', 'alan']); @@ -2121,18 +1888,14 @@ public function testReverse($collection) $this->assertSame(['framework' => 'laravel', 'name' => 'taylor'], $reversed->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFlip($collection) { $data = new $collection(['name' => 'taylor', 'framework' => 'laravel']); $this->assertEquals(['taylor' => 'name', 'laravel' => 'framework'], $data->flip()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testChunk($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); @@ -2145,9 +1908,7 @@ public function testChunk($collection) $this->assertEquals([9 => 10], $data->get(3)->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testChunkWhenGivenZeroAsSize($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); @@ -2158,9 +1919,7 @@ public function testChunkWhenGivenZeroAsSize($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testChunkWhenGivenLessThanZero($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); @@ -2171,9 +1930,7 @@ public function testChunkWhenGivenLessThanZero($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitIn($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); @@ -2187,9 +1944,7 @@ public function testSplitIn($collection) $this->assertEquals([9, 10], $data->get(2)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testChunkWhileOnEqualElements($collection) { $data = (new $collection(['A', 'A', 'B', 'B', 'C', 'C', 'C'])) @@ -2204,9 +1959,7 @@ public function testChunkWhileOnEqualElements($collection) $this->assertEquals([4 => 'C', 5 => 'C', 6 => 'C'], $data->last()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testChunkWhileOnContiguouslyIncreasingIntegers($collection) { $data = (new $collection([1, 4, 9, 10, 11, 12, 15, 16, 19, 20, 21])) @@ -2223,9 +1976,7 @@ public function testChunkWhileOnContiguouslyIncreasingIntegers($collection) $this->assertEquals([8 => 19, 9 => 20, 10 => 21], $data->last()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEvery($collection) { $c = new $collection([]); @@ -2255,9 +2006,7 @@ public function testEvery($collection) $this->assertFalse($c->concat([['active' => false]])->every->active); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testExcept($collection) { $data = new $collection(['first' => 'Taylor', 'last' => 'Otwell', 'email' => 'taylorotwell@gmail.com']); @@ -2272,18 +2021,14 @@ public function testExcept($collection) $this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->except(collect(['last']))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testExceptSelf($collection) { $data = new $collection(['first' => 'Taylor', 'last' => 'Otwell']); $this->assertEquals(['first' => 'Taylor', 'last' => 'Otwell'], $data->except($data)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPluckWithArrayAndObjectValues($collection) { $data = new $collection([(object) ['name' => 'taylor', 'email' => 'foo'], ['name' => 'dayle', 'email' => 'bar']]); @@ -2291,9 +2036,7 @@ public function testPluckWithArrayAndObjectValues($collection) $this->assertEquals(['foo', 'bar'], $data->pluck('email')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPluckWithArrayAccessValues($collection) { $data = new $collection([ @@ -2305,9 +2048,7 @@ public function testPluckWithArrayAccessValues($collection) $this->assertEquals(['foo', 'bar'], $data->pluck('email')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPluckWithDotNotation($collection) { $data = new $collection([ @@ -2328,9 +2069,7 @@ public function testPluckWithDotNotation($collection) $this->assertEquals([['php', 'python'], ['php', 'asp', 'java']], $data->pluck('skill.backend')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPluckDuplicateKeysExist($collection) { $data = new collection([ @@ -2343,9 +2082,7 @@ public function testPluckDuplicateKeysExist($collection) $this->assertEquals(['Tesla' => 'black', 'Pagani' => 'orange'], $data->pluck('color', 'brand')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHas($collection) { $data = new $collection(['id' => 1, 'first' => 'Hello', 'second' => 'World']); @@ -2356,9 +2093,7 @@ public function testHas($collection) $this->assertTrue($data->has('first', 'second')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHasAny($collection) { $data = new $collection(['id' => 1, 'first' => 'Hello', 'second' => 'World']); @@ -2372,9 +2107,7 @@ public function testHasAny($collection) $this->assertFalse($data->hasAny([])); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testImplode($collection) { $data = new $collection([['name' => 'taylor', 'email' => 'foo'], ['name' => 'dayle', 'email' => 'bar']]); @@ -2402,9 +2135,7 @@ public function testImplode($collection) $this->assertSame('taylor-foo,dayle-bar', $data->implode(fn ($user) => $user['name'].'-'.$user['email'], ',')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTake($collection) { $data = new $collection(['taylor', 'dayle', 'shawn']); @@ -2457,9 +2188,7 @@ public function testPutWithNoKey() $this->assertEquals(['taylor', 'shawn', 'dayle'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testRandom($collection) { $data = new $collection([1, 2, 3, 4, 5, 6]); @@ -2507,9 +2236,7 @@ public function testRandom($collection) $this->assertCount(5, array_intersect_assoc($random->all(), $data->all())); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testRandomOnEmptyCollection($collection) { $data = new $collection; @@ -2523,9 +2250,7 @@ public function testRandomOnEmptyCollection($collection) $this->assertCount(0, $random); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeLast($collection) { $data = new $collection(['taylor', 'dayle', 'shawn']); @@ -2533,9 +2258,7 @@ public function testTakeLast($collection) $this->assertEquals([1 => 'dayle', 2 => 'shawn'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeUntilUsingValue($collection) { $data = new $collection([1, 2, 3, 4]); @@ -2545,9 +2268,7 @@ public function testTakeUntilUsingValue($collection) $this->assertSame([1, 2], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeUntilUsingCallback($collection) { $data = new $collection([1, 2, 3, 4]); @@ -2559,9 +2280,7 @@ public function testTakeUntilUsingCallback($collection) $this->assertSame([1, 2], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeUntilReturnsAllItemsForUnmetValue($collection) { $data = new $collection([1, 2, 3, 4]); @@ -2577,9 +2296,7 @@ public function testTakeUntilReturnsAllItemsForUnmetValue($collection) $this->assertSame($data->toArray(), $actual->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeUntilCanBeProxied($collection) { $data = new $collection([ @@ -2595,9 +2312,7 @@ public function testTakeUntilCanBeProxied($collection) $this->assertSame('Taylor', $actual->get(1)->name); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeWhileUsingValue($collection) { $data = new $collection([1, 1, 2, 2, 3, 3]); @@ -2607,9 +2322,7 @@ public function testTakeWhileUsingValue($collection) $this->assertSame([1, 1], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeWhileUsingCallback($collection) { $data = new $collection([1, 2, 3, 4]); @@ -2621,9 +2334,7 @@ public function testTakeWhileUsingCallback($collection) $this->assertSame([1, 2], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeWhileReturnsNoItemsForUnmetValue($collection) { $data = new $collection([1, 2, 3, 4]); @@ -2639,9 +2350,7 @@ public function testTakeWhileReturnsNoItemsForUnmetValue($collection) $this->assertSame([], $actual->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTakeWhileCanBeProxied($collection) { $data = new $collection([ @@ -2658,9 +2367,7 @@ public function testTakeWhileCanBeProxied($collection) $this->assertSame('Adam', $actual->get(1)->name); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMacroable($collection) { // Foo() macro : unique values starting with A @@ -2677,9 +2384,7 @@ public function testMacroable($collection) $this->assertSame(['a', 'aa', 'aaa'], $c->foo()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCanAddMethodsToProxy($collection) { $collection::macro('adults', function ($callback) { @@ -2695,18 +2400,14 @@ public function testCanAddMethodsToProxy($collection) $this->assertSame([['age' => 18], ['age' => 56]], $c->adults->age->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMakeMethod($collection) { $data = $collection::make('foo'); $this->assertEquals(['foo'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMakeMethodFromNull($collection) { $data = $collection::make(null); @@ -2716,9 +2417,7 @@ public function testMakeMethodFromNull($collection) $this->assertEquals([], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMakeMethodFromCollection($collection) { $firstCollection = $collection::make(['foo' => 'bar']); @@ -2726,72 +2425,56 @@ public function testMakeMethodFromCollection($collection) $this->assertEquals(['foo' => 'bar'], $secondCollection->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMakeMethodFromArray($collection) { $data = $collection::make(['foo' => 'bar']); $this->assertEquals(['foo' => 'bar'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithScalar($collection) { $data = $collection::wrap('foo'); $this->assertEquals(['foo'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithArray($collection) { $data = $collection::wrap(['foo']); $this->assertEquals(['foo'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithArrayable($collection) { $data = $collection::wrap($o = new TestArrayableObject); $this->assertEquals([$o], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithJsonable($collection) { $data = $collection::wrap($o = new TestJsonableObject); $this->assertEquals([$o], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithJsonSerialize($collection) { $data = $collection::wrap($o = new TestJsonSerializeObject); $this->assertEquals([$o], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithCollectionClass($collection) { $data = $collection::wrap($collection::make(['foo'])); $this->assertEquals(['foo'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWrapWithCollectionSubclass($collection) { $data = TestCollectionSubclass::wrap($collection::make(['foo'])); @@ -2799,34 +2482,26 @@ public function testWrapWithCollectionSubclass($collection) $this->assertInstanceOf(TestCollectionSubclass::class, $data); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnwrapCollection($collection) { $data = new $collection(['foo']); $this->assertEquals(['foo'], $collection::unwrap($data)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnwrapCollectionWithArray($collection) { $this->assertEquals(['foo'], $collection::unwrap(['foo'])); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnwrapCollectionWithScalar($collection) { $this->assertSame('foo', $collection::unwrap('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEmptyMethod($collection) { $collection = $collection::empty(); @@ -2834,9 +2509,7 @@ public function testEmptyMethod($collection) $this->assertCount(0, $collection->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTimesMethod($collection) { $two = $collection::times(2, function ($number) { @@ -2859,9 +2532,7 @@ public function testTimesMethod($collection) $this->assertEquals(range(1, 5), $range->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testRangeMethod($collection) { $this->assertSame( @@ -2895,9 +2566,7 @@ public function testRangeMethod($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConstructMakeFromObject($collection) { $object = new stdClass; @@ -2906,18 +2575,14 @@ public function testConstructMakeFromObject($collection) $this->assertEquals(['foo' => 'bar'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConstructMethod($collection) { $data = new $collection('foo'); $this->assertEquals(['foo'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConstructMethodFromNull($collection) { $data = new $collection(null); @@ -2927,9 +2592,7 @@ public function testConstructMethodFromNull($collection) $this->assertEquals([], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConstructMethodFromCollection($collection) { $firstCollection = new $collection(['foo' => 'bar']); @@ -2937,18 +2600,14 @@ public function testConstructMethodFromCollection($collection) $this->assertEquals(['foo' => 'bar'], $secondCollection->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConstructMethodFromArray($collection) { $data = new $collection(['foo' => 'bar']); $this->assertEquals(['foo' => 'bar'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConstructMethodFromObject($collection) { $object = new stdClass; @@ -2985,9 +2644,7 @@ public function testSplice() $this->assertEquals(['foo', 'bar', 'baz'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGetPluckValueWithAccessors($collection) { $model = new TestAccessorEloquentTestStub(['some' => 'foo']); @@ -2997,9 +2654,7 @@ public function testGetPluckValueWithAccessors($collection) $this->assertEquals(['foo', 'bar'], $data->pluck('some')->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMap($collection) { $data = new $collection([1, 2, 3]); @@ -3016,9 +2671,7 @@ public function testMap($collection) $this->assertEquals(['first' => 'first-rolyat', 'last' => 'last-llewto'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapSpread($collection) { $c = new $collection([[1, 'a'], [2, 'b']]); @@ -3040,9 +2693,7 @@ public function testMapSpread($collection) $this->assertEquals(['1-a-0', '2-b-1'], $result->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testFlatMap($collection) { $data = new $collection([ @@ -3055,9 +2706,7 @@ public function testFlatMap($collection) $this->assertEquals(['programming', 'basketball', 'music', 'powerlifting'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapToDictionary($collection) { $data = new $collection([ @@ -3076,9 +2725,7 @@ public function testMapToDictionary($collection) $this->assertIsArray($groups->get('A')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapToDictionaryWithNumericKeys($collection) { $data = new $collection([1, 2, 3, 2, 1]); @@ -3090,9 +2737,7 @@ public function testMapToDictionaryWithNumericKeys($collection) $this->assertEquals([1 => [0, 4], 2 => [1, 3], 3 => [2]], $groups->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapToGroups($collection) { $data = new $collection([ @@ -3111,9 +2756,7 @@ public function testMapToGroups($collection) $this->assertInstanceOf($collection, $groups->get('A')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapToGroupsWithNumericKeys($collection) { $data = new $collection([1, 2, 3, 2, 1]); @@ -3126,9 +2769,7 @@ public function testMapToGroupsWithNumericKeys($collection) $this->assertEquals([1, 2, 3, 2, 1], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapWithKeys($collection) { $data = new $collection([ @@ -3145,9 +2786,7 @@ public function testMapWithKeys($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapWithKeysIntegerKeys($collection) { $data = new $collection([ @@ -3164,9 +2803,7 @@ public function testMapWithKeysIntegerKeys($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapWithKeysMultipleRows($collection) { $data = new $collection([ @@ -3190,9 +2827,7 @@ public function testMapWithKeysMultipleRows($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapWithKeysCallbackKey($collection) { $data = new $collection([ @@ -3209,9 +2844,7 @@ public function testMapWithKeysCallbackKey($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapInto($collection) { $data = new $collection([ @@ -3224,9 +2857,7 @@ public function testMapInto($collection) $this->assertSame('second', $data->get(1)->value); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testNth($collection) { $data = new $collection([ @@ -3251,9 +2882,7 @@ public function testNth($collection) $this->assertEquals(['e'], $data->nth(2, -2)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMapWithKeysOverwritingKeys($collection) { $data = new $collection([ @@ -3282,9 +2911,7 @@ public function testTransform() $this->assertEquals(['first' => 'first-rolyat', 'last' => 'last-llewto'], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByAttribute($collection) { $data = new $collection([['rating' => 1, 'url' => '1'], ['rating' => 1, 'url' => '1'], ['rating' => 2, 'url' => '2']]); @@ -3296,9 +2923,7 @@ public function testGroupByAttribute($collection) $this->assertEquals([1 => [['rating' => 1, 'url' => '1'], ['rating' => 1, 'url' => '1']], 2 => [['rating' => 2, 'url' => '2']]], $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByAttributeWithStringableKey($collection) { $data = new $collection($payload = [ @@ -3320,9 +2945,7 @@ public function __toString() $this->assertEquals(['1' => [$payload[0], $payload[1]], '2' => [$payload[2]]], $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByCallable($collection) { $data = new $collection([['rating' => 1, 'url' => '1'], ['rating' => 1, 'url' => '1'], ['rating' => 2, 'url' => '2']]); @@ -3344,9 +2967,7 @@ public function sortByUrl(array $value) return $value['url']; } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByAttributeWithBackedEnumKey($collection) { $data = new $collection([ @@ -3358,9 +2979,7 @@ public function testGroupByAttributeWithBackedEnumKey($collection) $this->assertEquals([TestBackedEnum::A->value => [['rating' => TestBackedEnum::A, 'url' => '1']], TestBackedEnum::B->value => [['rating' => TestBackedEnum::B, 'url' => '1']]], $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByAttributePreservingKeys($collection) { $data = new $collection([10 => ['rating' => 1, 'url' => '1'], 20 => ['rating' => 1, 'url' => '1'], 30 => ['rating' => 2, 'url' => '2']]); @@ -3375,9 +2994,7 @@ public function testGroupByAttributePreservingKeys($collection) $this->assertEquals($expected_result, $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByClosureWhereItemsHaveSingleGroup($collection) { $data = new $collection([['rating' => 1, 'url' => '1'], ['rating' => 1, 'url' => '1'], ['rating' => 2, 'url' => '2']]); @@ -3389,9 +3006,7 @@ public function testGroupByClosureWhereItemsHaveSingleGroup($collection) $this->assertEquals([1 => [['rating' => 1, 'url' => '1'], ['rating' => 1, 'url' => '1']], 2 => [['rating' => 2, 'url' => '2']]], $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByClosureWhereItemsHaveSingleGroupPreservingKeys($collection) { $data = new $collection([10 => ['rating' => 1, 'url' => '1'], 20 => ['rating' => 1, 'url' => '1'], 30 => ['rating' => 2, 'url' => '2']]); @@ -3408,9 +3023,7 @@ public function testGroupByClosureWhereItemsHaveSingleGroupPreservingKeys($colle $this->assertEquals($expected_result, $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByClosureWhereItemsHaveMultipleGroups($collection) { $data = new $collection([ @@ -3440,9 +3053,7 @@ public function testGroupByClosureWhereItemsHaveMultipleGroups($collection) $this->assertEquals($expected_result, $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByClosureWhereItemsHaveMultipleGroupsPreservingKeys($collection) { $data = new $collection([ @@ -3472,9 +3083,7 @@ public function testGroupByClosureWhereItemsHaveMultipleGroupsPreservingKeys($co $this->assertEquals($expected_result, $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGroupByMultiLevelAndClosurePreservingKeys($collection) { $data = new $collection([ @@ -3517,9 +3126,7 @@ function ($item) { $this->assertEquals($expected_result, $result->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testKeyByAttribute($collection) { $data = new $collection([['rating' => 1, 'name' => '1'], ['rating' => 2, 'name' => '2'], ['rating' => 3, 'name' => '3']]); @@ -3533,9 +3140,7 @@ public function testKeyByAttribute($collection) $this->assertEquals([2 => ['rating' => 1, 'name' => '1'], 4 => ['rating' => 2, 'name' => '2'], 6 => ['rating' => 3, 'name' => '3']], $result->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testKeyByClosure($collection) { $data = new $collection([ @@ -3551,9 +3156,7 @@ public function testKeyByClosure($collection) ], $result->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testKeyByObject($collection) { $data = new $collection([ @@ -3569,9 +3172,7 @@ public function testKeyByObject($collection) ], $result->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testContains($collection) { $c = new $collection([1, 3, 5]); @@ -3630,9 +3231,7 @@ public function testContains($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDoesntContain($collection) { $c = new $collection([1, 3, 5]); @@ -3691,9 +3290,7 @@ public function testDoesntContain($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSome($collection) { $c = new $collection([1, 3, 5]); @@ -3732,9 +3329,7 @@ public function testSome($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testContainsStrict($collection) { $c = new $collection([1, 3, 5, '02']); @@ -3780,9 +3375,7 @@ public function testContainsStrict($collection) $this->assertTrue($c->containsStrict('')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testContainsWithOperator($collection) { $c = new $collection([['v' => 1], ['v' => 3], ['v' => '4'], ['v' => 5]]); @@ -3793,9 +3386,7 @@ public function testContainsWithOperator($collection) $this->assertTrue($c->contains('v', '>', 4)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGettingSumFromCollection($collection) { $c = new $collection([(object) ['foo' => 50], (object) ['foo' => 50]]); @@ -3807,27 +3398,21 @@ public function testGettingSumFromCollection($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCanSumValuesWithoutACallback($collection) { $c = new $collection([1, 2, 3, 4, 5]); $this->assertEquals(15, $c->sum()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGettingSumFromEmptyCollection($collection) { $c = new $collection; $this->assertEquals(0, $c->sum('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testValueRetrieverAcceptsDotNotation($collection) { $c = new $collection([ @@ -3894,9 +3479,7 @@ public function testPullReturnsDefault() $this->assertSame('foo', $value); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testRejectRemovesElementsPassingTruthTest($collection) { $c = new $collection(['foo', 'bar']); @@ -3924,9 +3507,7 @@ public function testRejectRemovesElementsPassingTruthTest($collection) })->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testRejectWithoutAnArgumentRemovesTruthyValues($collection) { $data1 = new $collection([ @@ -3947,9 +3528,7 @@ public function testRejectWithoutAnArgumentRemovesTruthyValues($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSearchReturnsIndexOfFirstFoundItem($collection) { $c = new $collection([1, 2, 3, 4, 5, 2, 5, 'foo' => 'bar']); @@ -3965,9 +3544,7 @@ public function testSearchReturnsIndexOfFirstFoundItem($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSearchInStrictMode($collection) { $c = new $collection([false, 0, 1, [], '']); @@ -3980,9 +3557,7 @@ public function testSearchInStrictMode($collection) $this->assertEquals(4, $c->search('', true)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSearchReturnsFalseWhenItemIsNotFound($collection) { $c = new $collection([1, 2, 3, 4, 5, 'foo' => 'bar']); @@ -3997,9 +3572,7 @@ public function testSearchReturnsFalseWhenItemIsNotFound($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testKeys($collection) { $c = new $collection(['name' => 'taylor', 'framework' => 'laravel']); @@ -4009,9 +3582,7 @@ public function testKeys($collection) $this->assertEquals([0, 1], $c->keys()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPaginate($collection) { $c = new $collection(['one', 'two', 'three', 'four']); @@ -4087,9 +3658,7 @@ public function testPushWithMultipleItems() $this->assertSame($expected, $actual); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testZip($collection) { $c = new $collection([1, 2, 3]); @@ -4118,9 +3687,7 @@ public function testZip($collection) $this->assertEquals([3, 6, null], $c->get(2)->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPadPadsArrayWithValue($collection) { $c = new $collection([1, 2, 3]); @@ -4140,9 +3707,7 @@ public function testPadPadsArrayWithValue($collection) $this->assertEquals([1, 2, 3, 4, 5], $c->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGettingMaxItemsFromCollection($collection) { $c = new $collection([(object) ['foo' => 10], (object) ['foo' => 20]]); @@ -4163,9 +3728,7 @@ public function testGettingMaxItemsFromCollection($collection) $this->assertNull($c->max()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGettingMinItemsFromCollection($collection) { $c = new $collection([(object) ['foo' => 10], (object) ['foo' => 20]]); @@ -4196,9 +3759,7 @@ public function testGettingMinItemsFromCollection($collection) $this->assertNull($c->min()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testOnly($collection) { $data = new $collection(['first' => 'Taylor', 'last' => 'Otwell', 'email' => 'taylorotwell@gmail.com']); @@ -4213,9 +3774,7 @@ public function testOnly($collection) $this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->only(collect(['first', 'email']))->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGettingAvgItemsFromCollection($collection) { $c = new $collection([(object) ['foo' => 10], (object) ['foo' => 20]]); @@ -4257,9 +3816,7 @@ public function testGettingAvgItemsFromCollection($collection) $this->assertEquals(3, $c->avg('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testJsonSerialize($collection) { $c = new $collection([ @@ -4279,9 +3836,7 @@ public function testJsonSerialize($collection) ], $c->jsonSerialize()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCombineWithArray($collection) { $c = new $collection([1, 2, 3]); @@ -4322,9 +3877,7 @@ public function testCombineWithArray($collection) $this->assertSame($expected, $actual); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCombineWithCollection($collection) { $expected = [ @@ -4340,9 +3893,7 @@ public function testCombineWithCollection($collection) $this->assertSame($expected, $actual); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConcatWithArray($collection) { $expected = [ @@ -4368,9 +3919,7 @@ public function testConcatWithArray($collection) $this->assertSame($expected, $actual); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testConcatWithCollection($collection) { $expected = [ @@ -4398,9 +3947,7 @@ public function testConcatWithCollection($collection) $this->assertSame($expected, $actual); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDump($collection) { $log = new Collection; @@ -4416,9 +3963,7 @@ public function testDump($collection) VarDumper::setHandler(null); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReduce($collection) { $data = new $collection([1, 2, 3]); @@ -4435,9 +3980,7 @@ public function testReduce($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReduceSpread($collection) { $data = new $collection([-1, 0, 1, 2, 3, 4, 5]); @@ -4455,9 +3998,7 @@ public function testReduceSpread($collection) $this->assertEquals(-1, $min); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testReduceSpreadThrowsAnExceptionIfReducerDoesNotReturnAnArray($collection) { $data = new $collection([1]); @@ -4469,9 +4010,7 @@ public function testReduceSpreadThrowsAnExceptionIfReducerDoesNotReturnAnArray($ }, null); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testRandomThrowsAnExceptionUsingAmountBiggerThanCollectionSize($collection) { $this->expectException(InvalidArgumentException::class); @@ -4480,9 +4019,7 @@ public function testRandomThrowsAnExceptionUsingAmountBiggerThanCollectionSize($ $data->random(4); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPipe($collection) { $data = new $collection([1, 2, 3]); @@ -4492,9 +4029,7 @@ public function testPipe($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPipeInto($collection) { $data = new $collection([ @@ -4506,9 +4041,7 @@ public function testPipeInto($collection) $this->assertSame($data, $instance->value); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPipeThrough($collection) { $data = new $collection([1, 2, 3]); @@ -4525,9 +4058,7 @@ function ($data) { $this->assertEquals(15, $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMedianValueWithArrayCollection($collection) { $data = new $collection([1, 2, 2, 4]); @@ -4535,9 +4066,7 @@ public function testMedianValueWithArrayCollection($collection) $this->assertEquals(2, $data->median()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMedianValueByKey($collection) { $data = new $collection([ @@ -4549,9 +4078,7 @@ public function testMedianValueByKey($collection) $this->assertEquals(2, $data->median('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMedianOnCollectionWithNull($collection) { $data = new $collection([ @@ -4563,9 +4090,7 @@ public function testMedianOnCollectionWithNull($collection) $this->assertEquals(2, $data->median('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEvenMedianCollection($collection) { $data = new $collection([ @@ -4575,9 +4100,7 @@ public function testEvenMedianCollection($collection) $this->assertEquals(1.5, $data->median('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMedianOutOfOrderCollection($collection) { $data = new $collection([ @@ -4588,27 +4111,21 @@ public function testMedianOutOfOrderCollection($collection) $this->assertEquals(3, $data->median('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMedianOnEmptyCollectionReturnsNull($collection) { $data = new $collection; $this->assertNull($data->median()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testModeOnNullCollection($collection) { $data = new $collection; $this->assertNull($data->mode()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testMode($collection) { $data = new $collection([1, 2, 3, 4, 4, 5]); @@ -4616,9 +4133,7 @@ public function testMode($collection) $this->assertEquals([4], $data->mode()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testModeValueByKey($collection) { $data = new $collection([ @@ -4637,108 +4152,84 @@ public function testModeValueByKey($collection) $this->assertEquals($data2->mode('foo'), $data->mode('foo')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWithMultipleModeValues($collection) { $data = new $collection([1, 2, 2, 1]); $this->assertEquals([1, 2], $data->mode()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliceOffset($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([4, 5, 6, 7, 8], $data->slice(3)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliceNegativeOffset($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([6, 7, 8], $data->slice(-3)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliceOffsetAndLength($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([4, 5, 6], $data->slice(3, 3)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliceOffsetAndNegativeLength($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([4, 5, 6, 7], $data->slice(3, -1)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliceNegativeOffsetAndLength($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([4, 5, 6], $data->slice(-5, 3)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSliceNegativeOffsetAndNegativeLength($collection) { $data = new $collection([1, 2, 3, 4, 5, 6, 7, 8]); $this->assertEquals([3, 4, 5, 6], $data->slice(-6, -2)->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollectionFromTraversable($collection) { $data = new $collection(new ArrayObject([1, 2, 3])); $this->assertEquals([1, 2, 3], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollectionFromTraversableWithKeys($collection) { $data = new $collection(new ArrayObject(['foo' => 1, 'bar' => 2, 'baz' => 3])); $this->assertEquals(['foo' => 1, 'bar' => 2, 'baz' => 3], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollectionFromEnum($collection) { $data = new $collection(TestEnum::A); $this->assertEquals([TestEnum::A], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollectionFromBackedEnum($collection) { $data = new $collection(TestBackedEnum::A); $this->assertEquals([TestBackedEnum::A], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitCollectionWithADivisibleCount($collection) { $data = new $collection(['a', 'b', 'c', 'd']); @@ -4769,9 +4260,7 @@ public function testSplitCollectionWithADivisibleCount($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitCollectionWithAnUndivisableCount($collection) { $data = new $collection(['a', 'b', 'c']); @@ -4788,9 +4277,7 @@ public function testSplitCollectionWithAnUndivisableCount($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitCollectionWithCountLessThenDivisor($collection) { $data = new $collection(['a']); @@ -4807,9 +4294,7 @@ public function testSplitCollectionWithCountLessThenDivisor($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitCollectionIntoThreeWithCountOfFour($collection) { $data = new $collection(['a', 'b', 'c', 'd']); @@ -4827,9 +4312,7 @@ public function testSplitCollectionIntoThreeWithCountOfFour($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitCollectionIntoThreeWithCountOfFive($collection) { $data = new $collection(['a', 'b', 'c', 'd', 'e']); @@ -4847,9 +4330,7 @@ public function testSplitCollectionIntoThreeWithCountOfFive($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitCollectionIntoSixWithCountOfTen($collection) { $data = new $collection(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']); @@ -4870,9 +4351,7 @@ public function testSplitCollectionIntoSixWithCountOfTen($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testSplitEmptyCollection($collection) { $data = new $collection; @@ -4889,9 +4368,7 @@ public function testSplitEmptyCollection($collection) ); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderCollectionGroupBy($collection) { $data = new $collection([ @@ -4912,9 +4389,7 @@ public function testHigherOrderCollectionGroupBy($collection) ], $data->groupBy->uppercase()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderCollectionMap($collection) { $person1 = (object) ['name' => 'Taylor']; @@ -4929,9 +4404,7 @@ public function testHigherOrderCollectionMap($collection) $this->assertEquals(['TAYLOR', 'TAYLOR'], $data->each->uppercase()->map->name->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderCollectionMapFromArrays($collection) { $person1 = ['name' => 'Taylor']; @@ -4946,9 +4419,7 @@ public function testHigherOrderCollectionMapFromArrays($collection) $this->assertEquals(['TAYLOR', 'TAYLOR'], $data->each->uppercase()->map->name->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPartition($collection) { $data = new $collection(range(1, 10)); @@ -4961,9 +4432,7 @@ public function testPartition($collection) $this->assertEquals([6, 7, 8, 9, 10], $secondPartition->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPartitionCallbackWithKey($collection) { $data = new $collection(['zero', 'one', 'two', 'three']); @@ -4976,9 +4445,7 @@ public function testPartitionCallbackWithKey($collection) $this->assertEquals(['one', 'three'], $odd->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPartitionByKey($collection) { $courses = new $collection([ @@ -4991,9 +4458,7 @@ public function testPartitionByKey($collection) $this->assertSame([['free' => false, 'title' => 'Premium']], $premium->values()->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPartitionWithOperators($collection) { $data = new $collection([ @@ -5028,9 +4493,7 @@ public function testPartitionWithOperators($collection) ], $minors->values()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPartitionPreservesKeys($collection) { $courses = new $collection([ @@ -5043,9 +4506,7 @@ public function testPartitionPreservesKeys($collection) $this->assertSame(['b' => ['free' => false]], $premium->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPartitionEmptyCollection($collection) { $data = new $collection; @@ -5055,9 +4516,7 @@ public function testPartitionEmptyCollection($collection) })); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderPartition($collection) { $courses = new $collection([ @@ -5071,9 +4530,7 @@ public function testHigherOrderPartition($collection) $this->assertSame(['b' => ['free' => false]], $premium->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testTap($collection) { $data = new $collection([1, 2, 3]); @@ -5090,9 +4547,7 @@ public function testTap($collection) $this->assertSame([1, 2, 3], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhen($collection) { $data = new $collection(['michael', 'tom']); @@ -5112,9 +4567,7 @@ public function testWhen($collection) $this->assertSame(['michael', 'tom'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhenDefault($collection) { $data = new $collection(['michael', 'tom']); @@ -5128,9 +4581,7 @@ public function testWhenDefault($collection) $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhenEmpty($collection) { $data = new $collection(['michael', 'tom']); @@ -5150,9 +4601,7 @@ public function testWhenEmpty($collection) $this->assertSame(['adam'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhenEmptyDefault($collection) { $data = new $collection(['michael', 'tom']); @@ -5166,9 +4615,7 @@ public function testWhenEmptyDefault($collection) $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhenNotEmpty($collection) { $data = new $collection(['michael', 'tom']); @@ -5188,9 +4635,7 @@ public function testWhenNotEmpty($collection) $this->assertSame([], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhenNotEmptyDefault($collection) { $data = new $collection(['michael', 'tom']); @@ -5204,9 +4649,7 @@ public function testWhenNotEmptyDefault($collection) $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderWhenAndUnless($collection) { $data = new $collection(['michael', 'tom']); @@ -5228,9 +4671,7 @@ public function testHigherOrderWhenAndUnless($collection) $this->assertSame(['michael', 'tom', 'chris', 'adam'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHigherOrderWhenAndUnlessWithProxy($collection) { $data = new $collection(['michael', 'tom']); @@ -5252,9 +4693,7 @@ public function testHigherOrderWhenAndUnlessWithProxy($collection) $this->assertSame(['michael', 'tom', 'chris', 'adam'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnless($collection) { $data = new $collection(['michael', 'tom']); @@ -5274,9 +4713,7 @@ public function testUnless($collection) $this->assertSame(['michael', 'tom'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnlessDefault($collection) { $data = new $collection(['michael', 'tom']); @@ -5290,9 +4727,7 @@ public function testUnlessDefault($collection) $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnlessEmpty($collection) { $data = new $collection(['michael', 'tom']); @@ -5312,9 +4747,7 @@ public function testUnlessEmpty($collection) $this->assertSame([], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnlessEmptyDefault($collection) { $data = new $collection(['michael', 'tom']); @@ -5328,9 +4761,7 @@ public function testUnlessEmptyDefault($collection) $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnlessNotEmpty($collection) { $data = new $collection(['michael', 'tom']); @@ -5350,9 +4781,7 @@ public function testUnlessNotEmpty($collection) $this->assertSame(['adam'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUnlessNotEmptyDefault($collection) { $data = new $collection(['michael', 'tom']); @@ -5366,9 +4795,7 @@ public function testUnlessNotEmptyDefault($collection) $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testHasReturnsValidResults($collection) { $data = new $collection(['foo' => 'one', 'bar' => 'two', 1 => 'three']); @@ -5390,9 +4817,7 @@ public function testPutAddsItemToCollection() $this->assertSame(['foo' => 3, 'bar' => ['nested' => 'two']], $data->toArray()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testItThrowsExceptionWhenTryingToAccessNoProxyProperty($collection) { $data = new $collection; @@ -5401,27 +4826,21 @@ public function testItThrowsExceptionWhenTryingToAccessNoProxyProperty($collecti $data->foo; } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGetWithNullReturnsNull($collection) { $data = new $collection([1, 2, 3]); $this->assertNull($data->get(null)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGetWithDefaultValue($collection) { $data = new $collection(['name' => 'taylor', 'framework' => 'laravel']); $this->assertEquals('34', $data->get('age', 34)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testGetWithCallbackAsDefaultValue($collection) { $data = new $collection(['name' => 'taylor', 'framework' => 'laravel']); @@ -5431,9 +4850,7 @@ public function testGetWithCallbackAsDefaultValue($collection) $this->assertEquals('taylor@example.com', $result); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNull($collection) { $data = new $collection([ @@ -5451,9 +4868,7 @@ public function testWhereNull($collection) $this->assertSame([], $data->whereNull()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNullWithoutKey($collection) { $collection = new $collection([1, null, 3, 'null', false, true]); @@ -5462,9 +4877,7 @@ public function testWhereNullWithoutKey($collection) ], $collection->whereNull()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNotNull($collection) { $data = new $collection($originalData = [ @@ -5485,9 +4898,7 @@ public function testWhereNotNull($collection) $this->assertSame($originalData, $data->whereNotNull()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testWhereNotNullWithoutKey($collection) { $data = new $collection([1, null, 3, 'null', false, true]); @@ -5501,9 +4912,7 @@ public function testWhereNotNullWithoutKey($collection) ], $data->whereNotNull()->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testCollect($collection) { $data = $collection::make([ @@ -5521,9 +4930,7 @@ public function testCollect($collection) ], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testUndot($collection) { $data = $collection::make([ @@ -5557,9 +4964,7 @@ public function testUndot($collection) ], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testDot($collection) { $data = $collection::make([ @@ -5593,9 +4998,7 @@ public function testDot($collection) ], $data->all()); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEnsureForScalar($collection) { $data = $collection::make([1, 2, 3]); @@ -5606,9 +5009,7 @@ public function testEnsureForScalar($collection) $data->ensure('int'); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEnsureForObjects($collection) { $data = $collection::make([new stdClass, new stdClass, new stdClass]); @@ -5619,9 +5020,7 @@ public function testEnsureForObjects($collection) $data->ensure(stdClass::class); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testEnsureForInheritance($collection) { $data = $collection::make([new \Error, new \Error]); @@ -5632,9 +5031,7 @@ public function testEnsureForInheritance($collection) $data->ensure(\Throwable::class); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPercentageWithFlatCollection($collection) { $collection = new $collection([1, 1, 2, 2, 2, 3]); @@ -5645,9 +5042,7 @@ public function testPercentageWithFlatCollection($collection) $this->assertSame(0.0, $collection->percentage(fn ($value) => $value === 5)); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPercentageWithNestedCollection($collection) { $collection = new $collection([ @@ -5663,9 +5058,7 @@ public function testPercentageWithNestedCollection($collection) $this->assertSame(0.0, $collection->percentage(fn ($value) => $value['foo'] === 'test')); } - /** - * @dataProvider collectionClassProvider - */ + #[DataProvider('collectionClassProvider')] public function testPercentageReturnsNullForEmptyCollections($collection) { $collection = new $collection([]); diff --git a/tests/Support/SupportHelpersTest.php b/tests/Support/SupportHelpersTest.php index b91fa854e43b..d0088136e822 100755 --- a/tests/Support/SupportHelpersTest.php +++ b/tests/Support/SupportHelpersTest.php @@ -15,11 +15,12 @@ use IteratorAggregate; use LogicException; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionClass; use RuntimeException; -use stdClass; use Traversable; +use stdClass; class SupportHelpersTest extends TestCase { @@ -1045,9 +1046,7 @@ public static function providesPregReplaceArrayData() ]; } - /** - * @dataProvider providesPregReplaceArrayData - */ + #[DataProvider('providesPregReplaceArrayData')] public function testPregReplaceArray($pattern, $replacements, $subject, $expectedOutput) { $this->assertSame( diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index 9e676b1ba229..8297e7645ffe 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -4,6 +4,7 @@ use Exception; use Illuminate\Support\Str; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Ramsey\Uuid\UuidInterface; use ReflectionClass; @@ -286,17 +287,13 @@ public function testStrAfterLast() $this->assertSame('foo', Str::afterLast('----foo', '---')); } - /** - * @dataProvider strContainsProvider - */ + #[DataProvider('strContainsProvider')] public function testStrContains($haystack, $needles, $expected, $ignoreCase = false) { $this->assertEquals($expected, Str::contains($haystack, $needles, $ignoreCase)); } - /** - * @dataProvider strContainsAllProvider - */ + #[DataProvider('strContainsAllProvider')] public function testStrContainsAll($haystack, $needles, $expected, $ignoreCase = false) { $this->assertEquals($expected, Str::containsAll($haystack, $needles, $ignoreCase)); @@ -411,17 +408,13 @@ public function testIsUrl() $this->assertFalse(Str::isUrl('invalid url')); } - /** - * @dataProvider validUuidList - */ + #[DataProvider('validUuidList')] public function testIsUuidWithValidUuid($uuid) { $this->assertTrue(Str::isUuid($uuid)); } - /** - * @dataProvider invalidUuidList - */ + #[DataProvider('invalidUuidList')] public function testIsUuidWithInvalidUuid($uuid) { $this->assertFalse(Str::isUuid($uuid)); @@ -520,8 +513,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 @@ -1051,9 +1043,7 @@ public function testRepeat() $this->assertSame('', Str::repeat('', 5)); } - /** - * @dataProvider specialCharacterProvider - */ + #[DataProvider('specialCharacterProvider')] public function testTransliterate(string $value, string $expected): void { $this->assertSame($expected, Str::transliterate($value)); @@ -1079,9 +1069,7 @@ public function testTransliterateOverrideUnknown(): void $this->assertSame('Hello', Str::transliterate('🎂', 'Hello')); } - /** - * @dataProvider specialCharacterProvider - */ + #[DataProvider('specialCharacterProvider')] public function testTransliterateStrict(string $value, string $expected): void { $this->assertSame($expected, Str::transliterate($value, '?', true)); diff --git a/tests/Testing/Concerns/TestDatabasesTest.php b/tests/Testing/Concerns/TestDatabasesTest.php index 5e6e9e19956f..e5e1f110d884 100644 --- a/tests/Testing/Concerns/TestDatabasesTest.php +++ b/tests/Testing/Concerns/TestDatabasesTest.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Testing\Concerns\TestDatabases; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionMethod; @@ -46,9 +47,7 @@ public function testSwitchToDatabaseWithoutUrl() $this->switchToDatabase('my_database_test_1'); } - /** - * @dataProvider databaseUrls - */ + #[DataProvider('databaseUrls')] public function testSwitchToDatabaseWithUrl($testDatabase, $url, $testUrl) { DB::shouldReceive('purge')->once(); diff --git a/tests/Testing/ParallelTestingTest.php b/tests/Testing/ParallelTestingTest.php index 521cf16cfb15..ba3853d67ddc 100644 --- a/tests/Testing/ParallelTestingTest.php +++ b/tests/Testing/ParallelTestingTest.php @@ -4,6 +4,7 @@ use Illuminate\Container\Container; use Illuminate\Testing\ParallelTesting; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ParallelTestingTest extends TestCase @@ -17,9 +18,7 @@ protected function setUp(): void $_SERVER['LARAVEL_PARALLEL_TESTING'] = 1; } - /** - * @dataProvider callbacks - */ + #[DataProvider('callbacks')] public function testCallbacks($callback) { $parallelTesting = new ParallelTesting(Container::getInstance()); diff --git a/tests/Translation/TranslationMessageSelectorTest.php b/tests/Translation/TranslationMessageSelectorTest.php index cd53a7de17f0..5aae067445a9 100755 --- a/tests/Translation/TranslationMessageSelectorTest.php +++ b/tests/Translation/TranslationMessageSelectorTest.php @@ -3,13 +3,12 @@ namespace Illuminate\Tests\Translation; use Illuminate\Translation\MessageSelector; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class TranslationMessageSelectorTest extends TestCase { - /** - * @dataProvider chooseTestData - */ + #[DataProvider('chooseTestData')] public function testChoose($expected, $id, $number) { $selector = new MessageSelector; diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 51133741082d..77d75893518c 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -31,11 +31,13 @@ use InvalidArgumentException; use Mockery as m; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use RuntimeException; -use stdClass; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\UploadedFile; +use stdClass; class ValidationValidatorTest extends TestCase { @@ -1663,7 +1665,7 @@ public function testProhibits() $this->assertFalse($v->messages()->has('foo.1.email')); } - /** @dataProvider prohibitedRulesData */ + #[DataProvider('prohibitedRulesData')] public function testProhibitedRulesAreConsistent($rules, $data, $result) { $trans = $this->getIlluminateArrayTranslator(); @@ -3226,9 +3228,8 @@ public function testValidateMax() * @param mixed $input * @param mixed $allowed * @param bool $passes - * - * @dataProvider multipleOfDataProvider */ + #[DataProvider('multipleOfDataProvider')] public function testValidateMultipleOf($input, $allowed, $passes) { $trans = $this->getIlluminateArrayTranslator(); @@ -3964,9 +3965,7 @@ public function testValidateUrlWithProtocols() $this->assertFalse($v->passes()); } - /** - * @dataProvider validUrls - */ + #[DataProvider('validUrls')] public function testValidateUrlWithValidUrls($validUrl) { $trans = $this->getIlluminateArrayTranslator(); @@ -3974,9 +3973,7 @@ public function testValidateUrlWithValidUrls($validUrl) $this->assertTrue($v->passes()); } - /** - * @dataProvider invalidUrls - */ + #[DataProvider('invalidUrls')] public function testValidateUrlWithInvalidUrls($invalidUrl) { $trans = $this->getIlluminateArrayTranslator(); @@ -4248,9 +4245,7 @@ public static function invalidUrls() ]; } - /** - * @dataProvider activeUrlDataProvider - */ + #[DataProvider('activeUrlDataProvider')] public function testValidateActiveUrl($data, $outcome) { $trans = $this->getIlluminateArrayTranslator(); @@ -4556,9 +4551,7 @@ public function testValidateMimeEnforcesPhpCheck() $this->assertTrue($v->passes()); } - /** - * @requires extension fileinfo - */ + #[RequiresPhpExtension('fileinfo')] public function testValidateFile() { $trans = $this->getIlluminateArrayTranslator(); @@ -7807,9 +7800,7 @@ public function testMultiplePassesCalls() $this->assertFalse($v->passes()); } - /** - * @dataProvider validUuidList - */ + #[DataProvider('validUuidList')] public function testValidateWithValidUuid($uuid) { $trans = $this->getIlluminateArrayTranslator(); @@ -7817,9 +7808,7 @@ public function testValidateWithValidUuid($uuid) $this->assertTrue($v->passes()); } - /** - * @dataProvider invalidUuidList - */ + #[DataProvider('invalidUuidList')] public function testValidateWithInvalidUuid($uuid) { $trans = $this->getIlluminateArrayTranslator(); @@ -8097,9 +8086,7 @@ public static function providesPassingExcludeIfData() ]; } - /** - * @dataProvider providesPassingExcludeIfData - */ + #[DataProvider('providesPassingExcludeIfData')] public function testExcludeIf($rules, $data, $expectedValidatedData) { $validator = new Validator( @@ -8212,9 +8199,7 @@ public static function providesFailingExcludeIfData() ]; } - /** - * @dataProvider providesFailingExcludeIfData - */ + #[DataProvider('providesFailingExcludeIfData')] public function testExcludeIfWhenValidationFails($rules, $data, $expectedMessages) { $validator = new Validator( @@ -8254,9 +8239,7 @@ public static function providesPassingExcludeData() ]; } - /** - * @dataProvider providesPassingExcludeData - */ + #[DataProvider('providesPassingExcludeData')] public function testExclude($rules, $data, $expectedValidatedData) { $validator = new Validator( @@ -8824,7 +8807,7 @@ public function testItTrimsSpaceFromParameters() ], $validator->messages()->keys()); } - /** @dataProvider outsideRangeExponents */ + #[DataProvider('outsideRangeExponents')] public function testItLimitsLengthOfScientificNotationExponent($value) { $trans = $this->getIlluminateArrayTranslator(); @@ -8848,7 +8831,7 @@ public static function outsideRangeExponents() ]; } - /** @dataProvider withinRangeExponents */ + #[DataProvider('withinRangeExponents')] public function testItAllowsScientificNotationWithinRange($value, $rule) { $trans = $this->getIlluminateArrayTranslator(); diff --git a/tests/View/Blade/BladeEchoHandlerTest.php b/tests/View/Blade/BladeEchoHandlerTest.php index 16ac1aaea354..55e48b005c6a 100644 --- a/tests/View/Blade/BladeEchoHandlerTest.php +++ b/tests/View/Blade/BladeEchoHandlerTest.php @@ -5,6 +5,7 @@ use Exception; use Illuminate\Support\Fluent; use Illuminate\Support\Str; +use PHPUnit\Framework\Attributes\DataProvider; class BladeEchoHandlerTest extends AbstractBladeTestCase { @@ -49,9 +50,7 @@ public function testWhitespaceIsPreservedCorrectly() ); } - /** - * @dataProvider handlerLogicDataProvider - */ + #[DataProvider('handlerLogicDataProvider')] public function testHandlerLogicWorksCorrectly($blade) { $this->expectException(Exception::class); @@ -80,9 +79,7 @@ public static function handlerLogicDataProvider() ]; } - /** - * @dataProvider nonStringableDataProvider - */ + #[DataProvider('nonStringableDataProvider')] public function testHandlerWorksWithNonStringables($blade, $expectedOutput) { app()->singleton('blade.compiler', function () { diff --git a/tests/View/Blade/BladeForeachStatementsTest.php b/tests/View/Blade/BladeForeachStatementsTest.php index 1b4ce8ada8f3..80ba9736767b 100644 --- a/tests/View/Blade/BladeForeachStatementsTest.php +++ b/tests/View/Blade/BladeForeachStatementsTest.php @@ -3,6 +3,7 @@ namespace Illuminate\Tests\View\Blade; use Illuminate\Contracts\View\ViewCompilationException; +use PHPUnit\Framework\Attributes\DataProvider; class BladeForeachStatementsTest extends AbstractBladeTestCase { @@ -94,9 +95,7 @@ public function testLoopContentHolderIsExtractedFromForeachStatements() $this->assertEquals($expected, $this->compiler->compileString($string)); } - /** - * @dataProvider invalidForeachStatementsDataProvider - */ + #[DataProvider('invalidForeachStatementsDataProvider')] public function testForeachStatementsThrowHumanizedMessageWhenInvalidStatement($initialStatement) { $this->expectException(ViewCompilationException::class); diff --git a/tests/View/Blade/BladeForelseStatementsTest.php b/tests/View/Blade/BladeForelseStatementsTest.php index 3fb033b4e964..67e0cd38f355 100644 --- a/tests/View/Blade/BladeForelseStatementsTest.php +++ b/tests/View/Blade/BladeForelseStatementsTest.php @@ -3,6 +3,7 @@ namespace Illuminate\Tests\View\Blade; use Illuminate\Contracts\View\ViewCompilationException; +use PHPUnit\Framework\Attributes\DataProvider; class BladeForelseStatementsTest extends AbstractBladeTestCase { @@ -80,9 +81,7 @@ public function testNestedForelseStatementsAreCompiled() $this->assertEquals($expected, $this->compiler->compileString($string)); } - /** - * @dataProvider invalidForelseStatementsDataProvider - */ + #[DataProvider('invalidForelseStatementsDataProvider')] public function testForelseStatementsThrowHumanizedMessageWhenInvalidStatement($initialStatement) { $this->expectException(ViewCompilationException::class); diff --git a/tests/View/ViewBladeCompilerTest.php b/tests/View/ViewBladeCompilerTest.php index b7ef8a4ea75c..c3955945e8ff 100644 --- a/tests/View/ViewBladeCompilerTest.php +++ b/tests/View/ViewBladeCompilerTest.php @@ -6,6 +6,7 @@ use Illuminate\View\Compilers\BladeCompiler; use InvalidArgumentException; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ViewBladeCompilerTest extends TestCase @@ -122,11 +123,10 @@ public function testRawTagsCanBeSetToLegacyValues() } /** - * @dataProvider appendViewPathDataProvider - * * @param string $content * @param string $compiled */ + #[DataProvider('appendViewPathDataProvider')] public function testIncludePathToTemplate($content, $compiled) { $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__); diff --git a/tests/View/ViewFileViewFinderTest.php b/tests/View/ViewFileViewFinderTest.php index 80d0ad3f90f8..92f8e954bf9d 100755 --- a/tests/View/ViewFileViewFinderTest.php +++ b/tests/View/ViewFileViewFinderTest.php @@ -6,6 +6,7 @@ use Illuminate\View\FileViewFinder; use InvalidArgumentException; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ViewFileViewFinderTest extends TestCase @@ -153,9 +154,7 @@ public static function pathsProvider() ]; } - /** - * @dataProvider pathsProvider - */ + #[DataProvider('pathsProvider')] public function testNormalizedPaths($originalPath, $exceptedPath) { $finder = $this->getFinder(); From 15f524b09df957ef7519859092dd137a8a9a702f Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 23 Oct 2023 12:18:37 +0000 Subject: [PATCH 03/13] Apply fixes from StyleCI --- tests/Bus/BusBatchTest.php | 2 +- tests/Integration/Database/EloquentModelCustomCastingTest.php | 2 +- .../MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php | 2 +- tests/Integration/Database/MySql/EscapeTest.php | 2 +- tests/Support/SupportCollectionTest.php | 2 +- tests/Support/SupportHelpersTest.php | 2 +- tests/Validation/ValidationValidatorTest.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Bus/BusBatchTest.php b/tests/Bus/BusBatchTest.php index 9599e175f060..9f870f9adc9d 100644 --- a/tests/Bus/BusBatchTest.php +++ b/tests/Bus/BusBatchTest.php @@ -4,8 +4,8 @@ use Carbon\CarbonImmutable; use Illuminate\Bus\Batch; -use Illuminate\Bus\BatchFactory; use Illuminate\Bus\Batchable; +use Illuminate\Bus\BatchFactory; use Illuminate\Bus\DatabaseBatchRepository; use Illuminate\Bus\PendingBatch; use Illuminate\Bus\Queueable; diff --git a/tests/Integration/Database/EloquentModelCustomCastingTest.php b/tests/Integration/Database/EloquentModelCustomCastingTest.php index 3c7ade235a56..0d2e15c54f41 100644 --- a/tests/Integration/Database/EloquentModelCustomCastingTest.php +++ b/tests/Integration/Database/EloquentModelCustomCastingTest.php @@ -8,8 +8,8 @@ use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Contracts\Database\Eloquent\SerializesCastableAttributes; use Illuminate\Database\Capsule\Manager as DB; -use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Schema\Blueprint; use InvalidArgumentException; use PHPUnit\Framework\Attributes\Group; diff --git a/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php b/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php index d8a2e9aa8f9e..ad1290f384f8 100644 --- a/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php +++ b/tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php @@ -4,9 +4,9 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -use stdClass; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use stdClass; #[RequiresOperatingSystem('Linux|Darwin')] #[RequiresPhpExtension('pdo_mysql')] diff --git a/tests/Integration/Database/MySql/EscapeTest.php b/tests/Integration/Database/MySql/EscapeTest.php index 74c490a6bb8a..3f50939d49a0 100644 --- a/tests/Integration/Database/MySql/EscapeTest.php +++ b/tests/Integration/Database/MySql/EscapeTest.php @@ -2,9 +2,9 @@ namespace Illuminate\Tests\Integration\Database\MySql; -use RuntimeException; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use PHPUnit\Framework\Attributes\RequiresPhpExtension; +use RuntimeException; #[RequiresOperatingSystem('Linux|Darwin')] #[RequiresPhpExtension('pdo_mysql')] diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 117d9ae05e5e..a52f2a4dae02 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -22,10 +22,10 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionClass; +use stdClass; use Symfony\Component\VarDumper\VarDumper; use Traversable; use UnexpectedValueException; -use stdClass; include_once 'Enums.php'; diff --git a/tests/Support/SupportHelpersTest.php b/tests/Support/SupportHelpersTest.php index d0088136e822..c0fddec3ec76 100755 --- a/tests/Support/SupportHelpersTest.php +++ b/tests/Support/SupportHelpersTest.php @@ -19,8 +19,8 @@ use PHPUnit\Framework\TestCase; use ReflectionClass; use RuntimeException; -use Traversable; use stdClass; +use Traversable; class SupportHelpersTest extends TestCase { diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 77d75893518c..a57688f81baf 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -35,9 +35,9 @@ use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use RuntimeException; +use stdClass; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\UploadedFile; -use stdClass; class ValidationValidatorTest extends TestCase { From 2771ea71909a2f9656a97ada9d5763bbd967faf3 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 23 Oct 2023 20:19:19 +0800 Subject: [PATCH 04/13] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c4810f62af9f..135cb5ac0dee 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,7 @@ "league/flysystem-read-only": "^3.3", "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "dev-phpunit11", + "orchestra/testbench-core": "^9.0", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^11.0", From 124496d0c4efa31c18133260eb43f940784dc86f Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 24 Oct 2023 06:09:53 +0800 Subject: [PATCH 05/13] wip Signed-off-by: Mior Muhammad Zaki --- tests/Database/DatabaseEloquentIrregularPluralTest.php | 10 +++------- tests/Integration/Auth/ForgotPasswordTest.php | 9 +++------ .../Auth/ForgotPasswordWithoutDefaultRoutesTest.php | 10 +++------- .../Foundation/FoundationServiceProvidersTest.php | 4 +--- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/tests/Database/DatabaseEloquentIrregularPluralTest.php b/tests/Database/DatabaseEloquentIrregularPluralTest.php index 95a305c3d529..9ca4cedc4aa0 100644 --- a/tests/Database/DatabaseEloquentIrregularPluralTest.php +++ b/tests/Database/DatabaseEloquentIrregularPluralTest.php @@ -5,7 +5,6 @@ use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Carbon; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class DatabaseEloquentIrregularPluralTest extends TestCase @@ -72,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'); @@ -105,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' => 'bobby@example.com']); diff --git a/tests/Integration/Auth/ForgotPasswordTest.php b/tests/Integration/Auth/ForgotPasswordTest.php index 576271619897..0380196de9ca 100644 --- a/tests/Integration/Auth/ForgotPasswordTest.php +++ b/tests/Integration/Auth/ForgotPasswordTest.php @@ -44,8 +44,7 @@ protected function defineRoutes($router) })->name('custom.password.reset'); } - #[Test] - public function it_can_send_forgot_password_email() + public function testItCanSendForgotPasswordEmail() { Notification::fake(); @@ -68,8 +67,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(); @@ -96,8 +94,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(); diff --git a/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php b/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php index af2969915d9c..e34dcd78b82d 100644 --- a/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php +++ b/tests/Integration/Auth/ForgotPasswordWithoutDefaultRoutesTest.php @@ -10,7 +10,6 @@ use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser; use Orchestra\Testbench\Factories\UserFactory; use Orchestra\Testbench\TestCase; -use PHPUnit\Framework\Attributes\Test; class ForgotPasswordWithoutDefaultRoutesTest extends TestCase { @@ -40,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.'); @@ -67,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(); @@ -95,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(); diff --git a/tests/Integration/Foundation/FoundationServiceProvidersTest.php b/tests/Integration/Foundation/FoundationServiceProvidersTest.php index 0cb2a3e5e6d8..2a091b169192 100644 --- a/tests/Integration/Foundation/FoundationServiceProvidersTest.php +++ b/tests/Integration/Foundation/FoundationServiceProvidersTest.php @@ -4,7 +4,6 @@ use Illuminate\Support\ServiceProvider; use Orchestra\Testbench\TestCase; -use PHPUnit\Framework\Attributes\Test; class FoundationServiceProvidersTest extends TestCase { @@ -13,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']); From 2fede3f6e085fa3f5ad6256f38a55cbd0b345742 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 23 Oct 2023 22:10:08 +0000 Subject: [PATCH 06/13] Apply fixes from StyleCI --- tests/Integration/Auth/ForgotPasswordTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Integration/Auth/ForgotPasswordTest.php b/tests/Integration/Auth/ForgotPasswordTest.php index 0380196de9ca..46a682c229d8 100644 --- a/tests/Integration/Auth/ForgotPasswordTest.php +++ b/tests/Integration/Auth/ForgotPasswordTest.php @@ -10,7 +10,6 @@ use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser; use Orchestra\Testbench\Factories\UserFactory; use Orchestra\Testbench\TestCase; -use PHPUnit\Framework\Attributes\Test; class ForgotPasswordTest extends TestCase { From 745c635eb393f7acb2abbb3d7a666b2eda0eb0d1 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 25 Oct 2023 10:34:12 +0800 Subject: [PATCH 07/13] wip Signed-off-by: Mior Muhammad Zaki --- tests/Auth/AuthPasswordBrokerTest.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/Auth/AuthPasswordBrokerTest.php b/tests/Auth/AuthPasswordBrokerTest.php index f89971b4c7cf..f37b5e82dc40 100755 --- a/tests/Auth/AuthPasswordBrokerTest.php +++ b/tests/Auth/AuthPasswordBrokerTest.php @@ -22,12 +22,8 @@ protected function tearDown(): void public function testIfUserIsNotFoundErrorRedirectIsReturned() { $mocks = $this->getMocks(); - $broker = $this->getMockBuilder(PasswordBroker::class) - ->onlyMethods(['getUser']) - ->addMethods(['makeErrorRedirect']) - ->setConstructorArgs(array_values($mocks)) - ->getMock(); - $broker->expects($this->once())->method('getUser')->willReturn(null); + $broker = m::mock(PasswordBroker::class, array_values($mocks))->makePartial(); + $broker->shouldReceive('getUser')->once()->andReturnNull(); $this->assertSame(PasswordBrokerContract::INVALID_USER, $broker->sendResetLink(['credentials'])); } @@ -35,7 +31,7 @@ public function testIfUserIsNotFoundErrorRedirectIsReturned() public function testIfTokenIsRecentlyCreated() { $mocks = $this->getMocks(); - $broker = $this->getMockBuilder(PasswordBroker::class)->addMethods(['emailResetLink', 'getUri'])->setConstructorArgs(array_values($mocks))->getMock(); + $broker = m::mock(PasswordBroker::class, array_values($mocks))->makePartial(); $mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(['foo'])->andReturn($user = m::mock(CanResetPassword::class)); $mocks['tokens']->shouldReceive('recentlyCreatedToken')->once()->with($user)->andReturn(true); $user->shouldReceive('sendPasswordResetNotification')->with('token'); @@ -65,7 +61,7 @@ public function testUserIsRetrievedByCredentials() public function testBrokerCreatesTokenAndRedirectsWithoutError() { $mocks = $this->getMocks(); - $broker = $this->getMockBuilder(PasswordBroker::class)->addMethods(['emailResetLink', 'getUri'])->setConstructorArgs(array_values($mocks))->getMock(); + $broker = m::mock(PasswordBroker::class, array_values($mocks))->makePartial(); $mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(['foo'])->andReturn($user = m::mock(CanResetPassword::class)); $mocks['tokens']->shouldReceive('recentlyCreatedToken')->once()->with($user)->andReturn(false); $mocks['tokens']->shouldReceive('create')->once()->with($user)->andReturn('token'); @@ -99,12 +95,9 @@ public function testRedirectReturnedByRemindWhenRecordDoesntExistInTable() public function testResetRemovesRecordOnReminderTableAndCallsCallback() { unset($_SERVER['__password.reset.test']); - $broker = $this->getMockBuilder(PasswordBroker::class) - ->onlyMethods(['validateReset']) - ->addMethods(['getPassword', 'getToken']) - ->setConstructorArgs(array_values($mocks = $this->getMocks())) - ->getMock(); - $broker->expects($this->once())->method('validateReset')->willReturn($user = m::mock(CanResetPassword::class)); + $mocks = $this->getMocks(); + $broker = m::mock(PasswordBroker::class, array_values($mocks))->makePartial()->shouldAllowMockingProtectedMethods(); + $broker->shouldReceive('validateReset')->once()->andReturn($user = m::mock(CanResetPassword::class)); $mocks['tokens']->shouldReceive('delete')->once()->with($user); $callback = function ($user, $password) { $_SERVER['__password.reset.test'] = compact('user', 'password'); @@ -125,7 +118,7 @@ public function testExecutesCallbackInsteadOfSendingNotification() }; $mocks = $this->getMocks(); - $broker = $this->getMockBuilder(PasswordBroker::class)->addMethods(['emailResetLink', 'getUri'])->setConstructorArgs(array_values($mocks))->getMock(); + $broker = m::mock(PasswordBroker::class, array_values($mocks))->makePartial(); $mocks['users']->shouldReceive('retrieveByCredentials')->once()->with(['foo'])->andReturn($user = m::mock(CanResetPassword::class)); $mocks['tokens']->shouldReceive('recentlyCreatedToken')->once()->with($user)->andReturn(false); $mocks['tokens']->shouldReceive('create')->once()->with($user)->andReturn('token'); From 0bbe9bacff6ee1f3a02d4226a8eb42ac0c903365 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 25 Oct 2023 10:39:49 +0800 Subject: [PATCH 08/13] wip Signed-off-by: Mior Muhammad Zaki --- tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php | 5 ++++- tests/Database/DatabaseConnectionTest.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php b/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php index 55d03551a542..03c3152d6efe 100644 --- a/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php +++ b/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php @@ -9,7 +9,10 @@ class DatabaseConcernsBuildsQueriesTraitTest extends TestCase { public function testTapCallbackInstance() { - $mock = $this->getMockForTrait(BuildsQueries::class); + $mock = new class { + use BuildsQueries; + }; + $mock->tap(function ($builder) use ($mock) { $this->assertEquals($mock, $builder); }); diff --git a/tests/Database/DatabaseConnectionTest.php b/tests/Database/DatabaseConnectionTest.php index 0df367eed634..8709e339c226 100755 --- a/tests/Database/DatabaseConnectionTest.php +++ b/tests/Database/DatabaseConnectionTest.php @@ -116,11 +116,11 @@ public function testSelectResultsetsReturnsMultipleRowset() $statement->expects($this->once())->method('bindValue')->with(1, 'foo', 2); $statement->expects($this->once())->method('execute'); $statement->expects($this->atLeastOnce())->method('fetchAll')->willReturn(['boom']); - $statement->expects($this->atLeastOnce())->method('nextRowset')->will($this->returnCallback(function () { + $statement->expects($this->atLeastOnce())->method('nextRowset')->willReturnCallback(function () { static $i = 1; return ++$i <= 2; - })); + }); $pdo->expects($this->once())->method('prepare')->with('CALL a_procedure(?)')->willReturn($statement); $mock = $this->getMockConnection(['prepareBindings'], $writePdo); $mock->setReadPdo($pdo); From 7e59f1df4f92799ecfebf1deecf8b54f8ca454a6 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 25 Oct 2023 02:40:13 +0000 Subject: [PATCH 09/13] Apply fixes from StyleCI --- tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php b/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php index 03c3152d6efe..730b91855ff1 100644 --- a/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php +++ b/tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php @@ -9,7 +9,8 @@ class DatabaseConcernsBuildsQueriesTraitTest extends TestCase { public function testTapCallbackInstance() { - $mock = new class { + $mock = new class + { use BuildsQueries; }; From f6af2e10de99b82820da93ab0380db14604e30bb Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 25 Oct 2023 11:59:15 +0800 Subject: [PATCH 10/13] wip Signed-off-by: Mior Muhammad Zaki --- .../Testing/DatabaseMigrationsTest.php | 67 +++++++++++++------ .../Testing/RefreshDatabaseTest.php | 66 ++++++++++++------ .../CanConfigureMigrationCommandsTest.php | 2 +- tests/Queue/QueueDatabaseQueueUnitTest.php | 4 +- tests/Queue/QueueSqsJobTest.php | 23 ++----- 5 files changed, 104 insertions(+), 58 deletions(-) diff --git a/tests/Foundation/Testing/DatabaseMigrationsTest.php b/tests/Foundation/Testing/DatabaseMigrationsTest.php index 133a7f5fdd06..ba592f941d4d 100644 --- a/tests/Foundation/Testing/DatabaseMigrationsTest.php +++ b/tests/Foundation/Testing/DatabaseMigrationsTest.php @@ -3,12 +3,18 @@ namespace Illuminate\Tests\Foundation\Testing; use Illuminate\Contracts\Console\Kernel; +use Illuminate\Foundation\Testing\Concerns\InteractsWithConsole; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\RefreshDatabaseState; +use Illuminate\Support\Facades\Facade; use Mockery as m; +use Orchestra\Testbench\Concerns\Testing; +use Orchestra\Testbench\Foundation\Application as Testbench; use PHPUnit\Framework\TestCase; use ReflectionMethod; +use function Orchestra\Testbench\package_path; + class DatabaseMigrationsTest extends TestCase { protected $traitObject; @@ -17,18 +23,13 @@ protected function setUp(): void { RefreshDatabaseState::$migrated = false; - $this->traitObject = $this->getMockForAbstractClass(DatabaseMigrationsTestMockClass::class, [], '', true, true, true, [ - 'artisan', - 'beforeApplicationDestroyed', - ]); - - $kernelObj = m::mock(); - $kernelObj->shouldReceive('setArtisan') - ->with(null); + $this->traitObject = m::mock(DatabaseMigrationsTestMockClass::class)->makePartial(); + $this->traitObject->prepare(); + } - $this->traitObject->app = [ - Kernel::class => $kernelObj, - ]; + protected function tearDown(): void + { + unset($this->traitObject); } private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) @@ -44,8 +45,8 @@ private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) public function testRefreshTestDatabaseDefault() { $this->traitObject - ->expects($this->once()) - ->method('artisan') + ->shouldReceive('artisan') + ->once() ->with('migrate:fresh', [ '--drop-views' => false, '--drop-types' => false, @@ -62,8 +63,8 @@ public function testRefreshTestDatabaseWithDropViewsOption() $this->traitObject->dropViews = true; $this->traitObject - ->expects($this->once()) - ->method('artisan') + ->shouldReceive('artisan') + ->once() ->with('migrate:fresh', [ '--drop-views' => true, '--drop-types' => false, @@ -80,8 +81,8 @@ public function testRefreshTestDatabaseWithDropTypesOption() $this->traitObject->dropTypes = true; $this->traitObject - ->expects($this->once()) - ->method('artisan') + ->shouldReceive('artisan') + ->once() ->with('migrate:fresh', [ '--drop-views' => false, '--drop-types' => true, @@ -97,10 +98,38 @@ public function testRefreshTestDatabaseWithDropTypesOption() class DatabaseMigrationsTestMockClass { use DatabaseMigrations; - - public $app; + use InteractsWithConsole; + use Testing; public $dropViews = false; public $dropTypes = false; + + public function prepare() + { + $this->app = $this->refreshApplication(); + $this->withoutMockingConsoleOutput(); + } + + public function __destruct() + { + $this->tearDownTheTestEnvironment(); + } + + protected function setUpTraits() + { + return []; + } + + protected function setUpTheTestEnvironmentTraitToBeIgnored(string $use): bool + { + return true; + } + + protected function refreshApplication() + { + return Testbench::create( + basePath: package_path('vendor/orchestra/testbench-core/laravel') + ); + } } diff --git a/tests/Foundation/Testing/RefreshDatabaseTest.php b/tests/Foundation/Testing/RefreshDatabaseTest.php index a5acc8275c85..197642563be5 100644 --- a/tests/Foundation/Testing/RefreshDatabaseTest.php +++ b/tests/Foundation/Testing/RefreshDatabaseTest.php @@ -2,12 +2,15 @@ namespace Illuminate\Tests\Foundation\Testing; -use Illuminate\Contracts\Console\Kernel; +use Illuminate\Foundation\Testing\Concerns\InteractsWithConsole; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabaseState; use Mockery as m; +use Orchestra\Testbench\Concerns\Testing; +use Orchestra\Testbench\Foundation\Application as Testbench; use PHPUnit\Framework\TestCase; use ReflectionMethod; +use function Orchestra\Testbench\package_path; class RefreshDatabaseTest extends TestCase { @@ -17,18 +20,13 @@ protected function setUp(): void { RefreshDatabaseState::$migrated = false; - $this->traitObject = $this->getMockForAbstractClass(RefreshDatabaseTestMockClass::class, [], '', true, true, true, [ - 'artisan', - 'beginDatabaseTransaction', - ]); - - $kernelObj = m::mock(); - $kernelObj->shouldReceive('setArtisan') - ->with(null); + $this->traitObject = m::mock(RefreshDatabaseTestMockClass::class)->makePartial(); + $this->traitObject->prepare(); + } - $this->traitObject->app = [ - Kernel::class => $kernelObj, - ]; + protected function tearDown(): void + { + unset($this->traitObject); } private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) @@ -44,8 +42,8 @@ private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) public function testRefreshTestDatabaseDefault() { $this->traitObject - ->expects($this->once()) - ->method('artisan') + ->shouldReceive('artisan') + ->once() ->with('migrate:fresh', [ '--drop-views' => false, '--drop-types' => false, @@ -62,8 +60,8 @@ public function testRefreshTestDatabaseWithDropViewsOption() $this->traitObject->dropViews = true; $this->traitObject - ->expects($this->once()) - ->method('artisan') + ->shouldReceive('artisan') + ->once() ->with('migrate:fresh', [ '--drop-views' => true, '--drop-types' => false, @@ -80,8 +78,8 @@ public function testRefreshTestDatabaseWithDropTypesOption() $this->traitObject->dropTypes = true; $this->traitObject - ->expects($this->once()) - ->method('artisan') + ->shouldReceive('artisan') + ->once() ->with('migrate:fresh', [ '--drop-views' => false, '--drop-types' => true, @@ -96,11 +94,39 @@ public function testRefreshTestDatabaseWithDropTypesOption() class RefreshDatabaseTestMockClass { + use InteractsWithConsole; use RefreshDatabase; - - public $app; + use Testing; public $dropViews = false; public $dropTypes = false; + + public function prepare() + { + $this->app = $this->refreshApplication(); + $this->withoutMockingConsoleOutput(); + } + + public function __destruct() + { + $this->tearDownTheTestEnvironment(); + } + + protected function setUpTraits() + { + return []; + } + + protected function setUpTheTestEnvironmentTraitToBeIgnored(string $use): bool + { + return true; + } + + public function refreshApplication() + { + return Testbench::create( + basePath: package_path('vendor/orchestra/testbench-core/laravel') + ); + } } diff --git a/tests/Foundation/Testing/Traits/CanConfigureMigrationCommandsTest.php b/tests/Foundation/Testing/Traits/CanConfigureMigrationCommandsTest.php index 4a5a49696f1e..58f54a633931 100644 --- a/tests/Foundation/Testing/Traits/CanConfigureMigrationCommandsTest.php +++ b/tests/Foundation/Testing/Traits/CanConfigureMigrationCommandsTest.php @@ -12,7 +12,7 @@ class CanConfigureMigrationCommandsTest extends TestCase protected function setUp(): void { - $this->traitObject = $this->getMockForAbstractClass(CanConfigureMigrationCommandsTestMockClass::class); + $this->traitObject = new CanConfigureMigrationCommandsTestMockClass(); } private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) diff --git a/tests/Queue/QueueDatabaseQueueUnitTest.php b/tests/Queue/QueueDatabaseQueueUnitTest.php index eee521c085de..fee6daff4ac1 100644 --- a/tests/Queue/QueueDatabaseQueueUnitTest.php +++ b/tests/Queue/QueueDatabaseQueueUnitTest.php @@ -98,7 +98,7 @@ public function testFailureToCreatePayloadFromObject() $job = new stdClass; $job->invalid = "\xc3\x28"; - $queue = $this->getMockForAbstractClass(Queue::class); + $queue = m::mock(Queue::class)->makePartial(); $class = new ReflectionClass(Queue::class); $createPayload = $class->getMethod('createPayload'); @@ -112,7 +112,7 @@ public function testFailureToCreatePayloadFromArray() { $this->expectException('InvalidArgumentException'); - $queue = $this->getMockForAbstractClass(Queue::class); + $queue = m::mock(Queue::class)->makePartial(); $class = new ReflectionClass(Queue::class); $createPayload = $class->getMethod('createPayload'); diff --git a/tests/Queue/QueueSqsJobTest.php b/tests/Queue/QueueSqsJobTest.php index bebe16b8209a..83706d769585 100644 --- a/tests/Queue/QueueSqsJobTest.php +++ b/tests/Queue/QueueSqsJobTest.php @@ -45,10 +45,7 @@ protected function setUp(): void $this->queueUrl = $this->baseUrl.'/'.$this->account.'/'.$this->queueName; // Get a mock of the SqsClient - $this->mockedSqsClient = $this->getMockBuilder(SqsClient::class) - ->addMethods(['deleteMessage']) - ->disableOriginalConstructor() - ->getMock(); + $this->mockedSqsClient = m::mock(SqsClient::class)->makePartial(); // Use Mockery to mock the IoC Container $this->mockedContainer = m::mock(Container::class); @@ -83,27 +80,21 @@ public function testFireProperlyCallsTheJobHandler() public function testDeleteRemovesTheJobFromSqs() { - $this->mockedSqsClient = $this->getMockBuilder(SqsClient::class) - ->addMethods(['deleteMessage']) - ->disableOriginalConstructor() - ->getMock(); - $queue = $this->getMockBuilder(SqsQueue::class)->onlyMethods(['getQueue'])->setConstructorArgs([$this->mockedSqsClient, $this->queueName, $this->account])->getMock(); + $this->mockedSqsClient = m::mock(SqsClient::class)->makePartial(); + $queue = m::mock(SqsQueue::class, [$this->mockedSqsClient, $this->queueName, $this->account])->makePartial(); $queue->setContainer($this->mockedContainer); $job = $this->getJob(); - $job->getSqs()->expects($this->once())->method('deleteMessage')->with(['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $this->mockedReceiptHandle]); + $job->getSqs()->shouldReceive('deleteMessage')->once()->with(['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $this->mockedReceiptHandle]); $job->delete(); } public function testReleaseProperlyReleasesTheJobOntoSqs() { - $this->mockedSqsClient = $this->getMockBuilder(SqsClient::class) - ->addMethods(['changeMessageVisibility']) - ->disableOriginalConstructor() - ->getMock(); - $queue = $this->getMockBuilder(SqsQueue::class)->onlyMethods(['getQueue'])->setConstructorArgs([$this->mockedSqsClient, $this->queueName, $this->account])->getMock(); + $this->mockedSqsClient = m::mock(SqsClient::class)->makePartial(); + $queue = m::mock(SqsQueue::class, [$this->mockedSqsClient, $this->queueName, $this->account])->makePartial(); $queue->setContainer($this->mockedContainer); $job = $this->getJob(); - $job->getSqs()->expects($this->once())->method('changeMessageVisibility')->with(['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $this->mockedReceiptHandle, 'VisibilityTimeout' => $this->releaseDelay]); + $job->getSqs()->shouldReceive('changeMessageVisibility')->once()->with(['QueueUrl' => $this->queueUrl, 'ReceiptHandle' => $this->mockedReceiptHandle, 'VisibilityTimeout' => $this->releaseDelay]); $job->release($this->releaseDelay); $this->assertTrue($job->isReleased()); } From 05d4cdccdbdc994d1a4894086baf132bd22ae64b Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 25 Oct 2023 04:00:27 +0000 Subject: [PATCH 11/13] Apply fixes from StyleCI --- tests/Foundation/Testing/DatabaseMigrationsTest.php | 2 -- tests/Foundation/Testing/RefreshDatabaseTest.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Foundation/Testing/DatabaseMigrationsTest.php b/tests/Foundation/Testing/DatabaseMigrationsTest.php index ba592f941d4d..ccb65ab9af27 100644 --- a/tests/Foundation/Testing/DatabaseMigrationsTest.php +++ b/tests/Foundation/Testing/DatabaseMigrationsTest.php @@ -2,11 +2,9 @@ namespace Illuminate\Tests\Foundation\Testing; -use Illuminate\Contracts\Console\Kernel; use Illuminate\Foundation\Testing\Concerns\InteractsWithConsole; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\RefreshDatabaseState; -use Illuminate\Support\Facades\Facade; use Mockery as m; use Orchestra\Testbench\Concerns\Testing; use Orchestra\Testbench\Foundation\Application as Testbench; diff --git a/tests/Foundation/Testing/RefreshDatabaseTest.php b/tests/Foundation/Testing/RefreshDatabaseTest.php index 197642563be5..7296d6c34355 100644 --- a/tests/Foundation/Testing/RefreshDatabaseTest.php +++ b/tests/Foundation/Testing/RefreshDatabaseTest.php @@ -10,6 +10,7 @@ use Orchestra\Testbench\Foundation\Application as Testbench; use PHPUnit\Framework\TestCase; use ReflectionMethod; + use function Orchestra\Testbench\package_path; class RefreshDatabaseTest extends TestCase From c115d28a9333ffaab631b3c0790b056c6e4bf03c Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 25 Oct 2023 13:17:51 +0800 Subject: [PATCH 12/13] wip Signed-off-by: Mior Muhammad Zaki --- .../Testing/DatabaseMigrationsTest.php | 23 +++++++++++++------ .../Testing/RefreshDatabaseTest.php | 21 +++++++++++++---- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/tests/Foundation/Testing/DatabaseMigrationsTest.php b/tests/Foundation/Testing/DatabaseMigrationsTest.php index ccb65ab9af27..0d14f7909c22 100644 --- a/tests/Foundation/Testing/DatabaseMigrationsTest.php +++ b/tests/Foundation/Testing/DatabaseMigrationsTest.php @@ -19,15 +19,19 @@ class DatabaseMigrationsTest extends TestCase protected function setUp(): void { - RefreshDatabaseState::$migrated = false; - $this->traitObject = m::mock(DatabaseMigrationsTestMockClass::class)->makePartial(); - $this->traitObject->prepare(); + $this->traitObject->setUp(); } protected function tearDown(): void { - unset($this->traitObject); + $this->traitObject->tearDown(); + + if ($container = m::getContainer()) { + $this->addToAssertionCount($container->mockery_getExpectationCount()); + } + + m::close(); } private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) @@ -103,15 +107,20 @@ class DatabaseMigrationsTestMockClass public $dropTypes = false; - public function prepare() + public function setUp() { + RefreshDatabaseState::$migrated = false; + $this->app = $this->refreshApplication(); $this->withoutMockingConsoleOutput(); } - public function __destruct() + public function tearDown() { - $this->tearDownTheTestEnvironment(); + RefreshDatabaseState::$migrated = false; + + $this->callBeforeApplicationDestroyedCallbacks(); + $this->app?->flush(); } protected function setUpTraits() diff --git a/tests/Foundation/Testing/RefreshDatabaseTest.php b/tests/Foundation/Testing/RefreshDatabaseTest.php index 7296d6c34355..5a15a5d4958e 100644 --- a/tests/Foundation/Testing/RefreshDatabaseTest.php +++ b/tests/Foundation/Testing/RefreshDatabaseTest.php @@ -22,12 +22,18 @@ protected function setUp(): void RefreshDatabaseState::$migrated = false; $this->traitObject = m::mock(RefreshDatabaseTestMockClass::class)->makePartial(); - $this->traitObject->prepare(); + $this->traitObject->setUp(); } protected function tearDown(): void { - unset($this->traitObject); + $this->traitObject->tearDown(); + + if ($container = m::getContainer()) { + $this->addToAssertionCount($container->mockery_getExpectationCount()); + } + + m::close(); } private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName) @@ -103,15 +109,20 @@ class RefreshDatabaseTestMockClass public $dropTypes = false; - public function prepare() + public function setUp() { + RefreshDatabaseState::$migrated = false; + $this->app = $this->refreshApplication(); $this->withoutMockingConsoleOutput(); } - public function __destruct() + public function tearDown() { - $this->tearDownTheTestEnvironment(); + RefreshDatabaseState::$migrated = false; + + $this->callBeforeApplicationDestroyedCallbacks(); + $this->app?->flush(); } protected function setUpTraits() From a42b453c5930e02cd56b849387cbf50df7be1a16 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 26 Oct 2023 18:38:29 +0800 Subject: [PATCH 13/13] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 23a6847fb748..439d904e1aa3 100644 --- a/composer.json +++ b/composer.json @@ -108,7 +108,7 @@ "orchestra/testbench-core": "^9.0", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", - "phpunit/phpunit": "^11.0", + "phpunit/phpunit": "^10.1", "predis/predis": "^2.0.2", "symfony/cache": "^7.0", "symfony/http-client": "^7.0",