Skip to content

Commit 2641bc1

Browse files
authored
[9.x] use static data providers in tests (#45049)
* use static data providers * Fix remaining getTestDate() call
1 parent 0af8926 commit 2641bc1

32 files changed

+59
-59
lines changed

tests/Auth/AuthAccessGateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public function testDefineSecondParameterShouldBeStringOrCallable($callback)
570570
/**
571571
* @return array
572572
*/
573-
public function notCallableDataProvider()
573+
public static function notCallableDataProvider()
574574
{
575575
return [
576576
[1],
@@ -1051,7 +1051,7 @@ public function testHasAbilities($abilitiesToSet, $abilitiesToCheck, $expectedHa
10511051
$this->assertEquals($expectedHasValue, $gate->has($abilitiesToCheck));
10521052
}
10531053

1054-
public function hasAbilitiesTestDataProvider()
1054+
public static function hasAbilitiesTestDataProvider()
10551055
{
10561056
$abilities = ['foo' => 'foo', 'bar' => 'bar'];
10571057
$noAbilities = [];

tests/Broadcasting/BroadcasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function testChannelNameMatchPattern($channel, $pattern, $shouldMatch)
322322
$this->assertEquals($shouldMatch, $this->broadcaster->channelNameMatchesPattern($channel, $pattern));
323323
}
324324

325-
public function channelNameMatchPatternProvider()
325+
public static function channelNameMatchPatternProvider()
326326
{
327327
return [
328328
['something', 'something', true],

tests/Broadcasting/UsePusherChannelsNamesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testIsGuardedChannel($requestChannelName, $_, $guarded)
4444
);
4545
}
4646

47-
public function channelsProvider()
47+
public static function channelsProvider()
4848
{
4949
$prefixesInfos = [
5050
['prefix' => 'private-', 'guarded' => true],

tests/Bus/BusBatchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public function test_options_unserialize_on_postgres($serialize, $options)
448448
/**
449449
* @return array
450450
*/
451-
public function serializedOptions()
451+
public static function serializedOptions()
452452
{
453453
$options = [1, 2];
454454

tests/Cache/CacheRepositoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function setUp(): void
2727
{
2828
parent::setUp();
2929

30-
Carbon::setTestNow(Carbon::parse($this->getTestDate()));
30+
Carbon::setTestNow(Carbon::parse(self::getTestDate()));
3131
}
3232

3333
protected function tearDown(): void
@@ -261,12 +261,12 @@ public function testAddWithDatetimeInPastOrZeroSecondsReturnsImmediately()
261261
$this->assertFalse($result);
262262
}
263263

264-
public function dataProviderTestGetSeconds()
264+
public static function dataProviderTestGetSeconds()
265265
{
266266
return [
267-
[Carbon::parse($this->getTestDate())->addMinutes(5)],
268-
[(new DateTime($this->getTestDate()))->modify('+5 minutes')],
269-
[(new DateTimeImmutable($this->getTestDate()))->modify('+5 minutes')],
267+
[Carbon::parse(self::getTestDate())->addMinutes(5)],
268+
[(new DateTime(self::getTestDate()))->modify('+5 minutes')],
269+
[(new DateTimeImmutable(self::getTestDate()))->modify('+5 minutes')],
270270
[new DateInterval('PT5M')],
271271
[300],
272272
];
@@ -438,7 +438,7 @@ protected function getRepository()
438438
return $repository;
439439
}
440440

441-
protected function getTestDate()
441+
protected static function getTestDate()
442442
{
443443
return '2030-07-25 12:13:14 UTC';
444444
}

tests/Database/DatabaseConnectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testMySqlConnectCallsCreateConnectionWithProperArguments($dsn, $
4545
$this->assertSame($result, $connection);
4646
}
4747

48-
public function mySqlConnectProvider()
48+
public static function mySqlConnectProvider()
4949
{
5050
return [
5151
['mysql:host=foo;dbname=bar', ['host' => 'foo', 'database' => 'bar', 'collation' => 'utf8_unicode_ci', 'charset' => 'utf8']],
@@ -112,7 +112,7 @@ public function testPostgresSearchPathIsSet($searchPath, $expectedSql)
112112
$this->assertSame($result, $connection);
113113
}
114114

115-
public function provideSearchPaths()
115+
public static function provideSearchPaths()
116116
{
117117
return [
118118
'all-lowercase' => [

tests/Database/DatabaseMySqlSchemaStateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testConnectionString(string $expectedConnectionString, array $ex
3333
self::assertEquals($expectedVariables, $variables);
3434
}
3535

36-
public function provider(): Generator
36+
public static function provider(): Generator
3737
{
3838
yield 'default' => [
3939
' --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}"', [

tests/Http/HttpJsonResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testSetAndRetrieveData($data)
2323
$this->assertSame('bar', $response->getData()->foo);
2424
}
2525

26-
public function setAndRetrieveDataProvider()
26+
public static function setAndRetrieveDataProvider()
2727
{
2828
return [
2929
'Jsonable data' => [new JsonResponseTestJsonableObject],
@@ -85,7 +85,7 @@ public function testGracefullyHandledSomeJsonErrorsWithPartialOutputOnError($dat
8585
new JsonResponse(['data' => $data], 200, [], JSON_PARTIAL_OUTPUT_ON_ERROR);
8686
}
8787

88-
public function jsonErrorDataProvider()
88+
public static function jsonErrorDataProvider()
8989
{
9090
// Resources can't be encoded
9191
$resource = tmpfile();

tests/Http/HttpRequestTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testSegmentMethod($path, $segment, $expected)
8989
$this->assertEquals($expected, $request->segment($segment, 'default'));
9090
}
9191

92-
public function segmentProvider()
92+
public static function segmentProvider()
9393
{
9494
return [
9595
['', 1, 'default'],
@@ -111,7 +111,7 @@ public function testSegmentsMethod($path, $expected)
111111
$this->assertEquals(['foo', 'bar'], $request->segments());
112112
}
113113

114-
public function segmentsProvider()
114+
public static function segmentsProvider()
115115
{
116116
return [
117117
['', []],
@@ -1012,7 +1012,7 @@ public function testJSONEmulatingPHPBuiltInServer()
10121012
$this->assertEquals($payload, $data);
10131013
}
10141014

1015-
public function getPrefersCases()
1015+
public static function getPrefersCases()
10161016
{
10171017
return [
10181018
['application/json', ['json'], 'json'],

tests/Integration/Console/CommandSchedulingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testExecutionOrder($background)
9595
$this->assertLogged('before', 'handled', 'after');
9696
}
9797

98-
public function executionProvider()
98+
public static function executionProvider()
9999
{
100100
return [
101101
'Foreground' => [false],

0 commit comments

Comments
 (0)