Skip to content

Commit

Permalink
[11.x] PHPUnit 11 Forward Compatibility (#48796)
Browse files Browse the repository at this point in the history
* wip

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

* wip

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

* Apply fixes from StyleCI

* wip

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

* wip

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

* Apply fixes from StyleCI

* wip

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

* wip

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

* Apply fixes from StyleCI

* wip

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

* Apply fixes from StyleCI

* wip

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

* Update composer.json

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
crynobone and StyleCIBot authored Oct 26, 2023
1 parent da71348 commit eb8b176
Show file tree
Hide file tree
Showing 65 changed files with 540 additions and 1,299 deletions.
8 changes: 3 additions & 5 deletions tests/Auth/AuthAccessGateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -555,9 +556,7 @@ public function testForUserMethodAttachesANewUserToANewGateInstanceWithGuessCall
$this->assertSame(3, $counter);
}

/**
* @dataProvider notCallableDataProvider
*/
#[DataProvider('notCallableDataProvider')]
public function testDefineSecondParameterShouldBeStringOrCallable($callback)
{
$this->expectException(InvalidArgumentException::class);
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions tests/Broadcasting/BroadcasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
9 changes: 3 additions & 6 deletions tests/Broadcasting/UsePusherChannelsNamesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,9 +30,7 @@ public function testChannelNameNormalizationSpecialCase()
);
}

/**
* @dataProvider channelsProvider
*/
#[DataProvider('channelsProvider')]
public function testIsGuardedChannel($requestChannelName, $_, $guarded)
{
$broadcaster = new FakeBroadcasterUsingPusherChannelsNames;
Expand Down
5 changes: 2 additions & 3 deletions tests/Bus/BusBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions tests/Cache/CacheMemcachedConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -48,9 +49,7 @@ public function testServersAreAddedCorrectlyWithPersistentConnection()
$this->assertSame($result, $memcached);
}

/**
* @requires extension memcached
*/
#[RequiresPhpExtension('memcached')]
public function testServersAreAddedCorrectlyWithValidOptions()
{
$validOptions = [
Expand All @@ -71,9 +70,7 @@ public function testServersAreAddedCorrectlyWithValidOptions()
$this->assertSame($result, $memcached);
}

/**
* @requires extension memcached
*/
#[RequiresPhpExtension('memcached')]
public function testServersAreAddedCorrectlyWithSaslCredentials()
{
$saslCredentials = ['foo', 'bar'];
Expand Down
5 changes: 2 additions & 3 deletions tests/Cache/CacheMemcachedStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
use Illuminate\Support\Carbon;
use Memcached;
use Mockery as m;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;

/**
* @requires extension memcached
*/
#[RequiresPhpExtension('memcached')]
class CacheMemcachedStoreTest extends TestCase
{
protected function tearDown(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Cache/CacheRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -280,10 +281,9 @@ public static function dataProviderTestGetSeconds()
}

/**
* @dataProvider dataProviderTestGetSeconds
*
* @param mixed $duration
*/
#[DataProvider('dataProviderTestGetSeconds')]
public function testGetSeconds($duration)
{
$repo = $this->getRepository();
Expand Down
10 changes: 4 additions & 6 deletions tests/Cache/RedisCacheIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]);
Expand All @@ -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]);
Expand All @@ -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]);
Expand Down
17 changes: 5 additions & 12 deletions tests/Console/Scheduling/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,29 +18,23 @@ 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');

$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');

$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');
Expand All @@ -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');
Expand Down
13 changes: 5 additions & 8 deletions tests/Database/DatabaseConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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\'';
Expand Down Expand Up @@ -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;'];
Expand Down
5 changes: 2 additions & 3 deletions tests/Database/DatabaseMySqlSchemaStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions tests/Encryption/EncrypterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Encryption\Encrypter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use RuntimeException;

Expand Down Expand Up @@ -221,9 +222,7 @@ public static function provideTamperedData()
];
}

/**
* @dataProvider provideTamperedData
*/
#[DataProvider('provideTamperedData')]
public function testTamperedPayloadWillGetRejected($payload)
{
$this->expectException(DecryptException::class);
Expand Down
5 changes: 2 additions & 3 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions tests/Filesystem/FilesystemManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,9 +99,7 @@ public function testCanBuildScopedDisks()
}
}

/**
* @requires OS Linux|Darwin
*/
#[RequiresOperatingSystem('Linux|Darwin')]
public function testCanBuildScopedDisksWithVisibility()
{
try {
Expand Down
Loading

0 comments on commit eb8b176

Please sign in to comment.